@@ -103,8 +103,10 @@ time:
103103
104104``` csharp
105105var consumer = new AsyncEventingBasicConsumer (channel );
106- consumer .Received += async (model , ea ) =>
106+ consumer .ReceivedAsync += async (model , ea ) =>
107107{
108+ var body = ea .Body .ToArray ();
109+ var message = Encoding .UTF8 .GetString (body );
108110 Console .WriteLine ($" [x] Received {message }" );
109111
110112 int dots = message .Split ('.' ).Length - 1 ;
@@ -219,9 +221,15 @@ examples we explicitly turned them off by setting the autoAck
219221remove this flag and manually send a proper acknowledgment from the
220222worker, once we're done with a task.
221223
222- After the existing _ WriteLine_ , add a call to _ BasicAck_ and update _ BasicConsume_ with _ autoAck:false_ :
223- ``` csharp reference
224- https : // github.com/rabbitmq/rabbitmq-tutorials/blob/main/dotnet/Worker/Worker.cs#L26-L32
224+ After the existing _ WriteLine_ , add a call to _ BasicAckAsync_ and update _ BasicConsumeAsync_ with _ autoAck:false_ :
225+ ``` csharp
226+ Console .WriteLine (" [x] Done" );
227+
228+ // here channel could also be accessed as ((AsyncEventingBasicConsumer)sender).Channel
229+ await channel .BasicAckAsync (deliveryTag : ea .DeliveryTag , multiple : false );
230+ };
231+
232+ await channel .BasicConsumeAsync (" hello" , autoAck : false , consumer : consumer );
225233```
226234
227235Using this code, you can ensure that even if you terminate a worker node using
0 commit comments