How to cancel the consumer method in MassTransit

Viewed 113

How can I cancel the execution of a Consume method of an IConsumer<>? I tried to create a cancellation token and use another thread to trigger the cancellation, and I can get a ConsumerCancelledException, but I could not handle the Fault<> message. E.g.

  • I have a MyDataConsumer: IConsumer<MyData> and MyDataFaultConsumer: IConsumer<Fault<MyData>>: IConsumer<Fault<MyData>>
  • The IConsumer<MyData> throws an ConsumerCancelledException
  • The failed message went into the MyData_error queue, but it did not go to the MyDataFault queue

However, if I directly throw an exception in my MyDataConsumer, my fault consumer can get the data. It seems the ConsumerCancelledException is handled differently than other exceptions.

0 Answers
Related