The difference between the processor and the consumer in MassTransit

What is the difference between handler and consumer in MassTransit? I saw examples that use one or the other, but conceptually, I don’t understand what is the difference between the two and why you would like to choose one or the other.

+6
source share
1 answer

A consumer is a type that you register, which has a specialized handler that handles the life cycle of your Consumer object.

A handler is just a general event handler.

You would use a handler if you need a small Action<> block to allow any action in your message. You must use the Consumer if you want to register a type that has a life cycle to allow any action in your message. Typically, you will need a Consumer because you want your container to allow dependencies for the type, rather than just having them within your handler. But handlers are great for small things or request-response scripts.

+6
source

All Articles