33using System . IO ;
44using System . Linq ;
55using System . Threading ;
6- using System . Threading . Tasks ;
76using InEngine . Core . Exceptions ;
7+ using InEngine . Core . Logging ;
88using InEngine . Core . Queuing . Message ;
99
1010namespace InEngine . Core . Queuing . Clients
1111{
1212 public class FileClient : IQueueClient
1313 {
14+ public ILog Log { get ; set ; } = new Log ( ) ;
1415 public int Id { get ; set ; } = 0 ;
1516 public string QueueBaseName { get ; set ; }
1617 public string QueueName { get ; set ; }
@@ -72,13 +73,14 @@ public void Consume(CancellationToken cancellationToken)
7273 cancellationToken . ThrowIfCancellationRequested ( ) ;
7374 }
7475 }
75- catch ( OperationCanceledException )
76+ catch ( OperationCanceledException exception )
7677 {
78+ Log . Debug ( exception ) ;
7779 return ;
7880 }
7981 catch ( Exception exception )
8082 {
81- Console . WriteLine ( exception . Message ) ;
83+ Log . Error ( exception ) ;
8284 }
8385 }
8486
@@ -96,9 +98,10 @@ public ICommandEnvelope Consume()
9698 {
9799 fileInfo . MoveTo ( inProgressFilePath ) ;
98100 }
99- catch ( FileNotFoundException )
101+ catch ( FileNotFoundException exception )
100102 {
101103 // Another process probably consumed the file when it was read and moved.
104+ Log . Debug ( exception ) ;
102105 return null ;
103106 }
104107
@@ -114,6 +117,7 @@ public ICommandEnvelope Consume()
114117 }
115118 catch ( Exception exception )
116119 {
120+ Log . Error ( exception ) ;
117121 if ( command . CommandLifeCycle . ShouldRetry ( ) )
118122 File . Move ( inProgressFilePath , Path . Combine ( PendingQueuePath , fileInfo . Name ) ) ;
119123 else
@@ -127,6 +131,7 @@ public ICommandEnvelope Consume()
127131 }
128132 catch ( Exception exception )
129133 {
134+ Log . Error ( exception ) ;
130135 throw new CommandFailedException ( "Failed to move command from in-progress queue." , exception ) ;
131136 }
132137
0 commit comments