EasyNetQ: Consumer Cancellation
Join the DZone community and get the full member experience.Join For Free
Consumer cancellation has been a requested feature of EasyNetQ for a while now. I wasn’t intending to implement it immediately, but a pull request by Daniel White today made me look at the whole issue of consumer cancellation from the point of view of a deleted queue. It led rapidly to a quite straightforward implementation of user cancellations. The wonders of open source software development, and the generosity of people like Daniel, never fails to impress me.
So what is consumer cancellation? It means that you can stop consuming from a queue without having dispose of the entire IBus instance and close the connection. All the IBus Subscribe methods, and the IAdvancedBus Consume methods now return an IDisposable. To stop consuming, just call Dispose like this:
var cancelSubscription = bus.Subscribe<MyMessage>("subscriptionId", MessageHandler); . . // sometime later stop consuming cancelSubscription.Dispose();
Published at DZone with permission of Mike Hadlow, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
How To Approach Java, Databases, and SQL [Video]
Effortlessly Streamlining Test-Driven Development and CI Testing for Kafka Developers
How To Use Pandas and Matplotlib To Perform EDA In Python
Exploratory Testing Tutorial: A Comprehensive Guide With Examples and Best Practices