![]() The problem is that I cannot register this generic consumer like: consumer.Consumer>() MassTransit supports an overload method that accepts a type (good! just what I want) but it also requires a second argument Func consumerFactory and I don't know how to implement it. Please see my repository for all the details. I need to find a way to register the EventDtoHandlerAdapter as a consumer for each TEventDto type I pass at runtime (as a collection of types for example). The problem I have is with the way MassTransit requires the consumers to be registered because my consumer is a generic one and its type should not be known by the MassTransit wrapper at compile time. The MassTransit wrapper project (called DiDrDe.MessageBus) implements the adapters with an EventDtoBusAdapter composed of an IEventDtoBus and a EventDtoHandlerAdapter as my only generic IConsumer composed of an IEventDtoHandler To achieve this I am implementing the adapter pattern so that my custom interfaces IEventDtoBus (to publish events) and IEventDtoHandler (to consume events) are all my Publisher and Consumers know. Notice how DiDrDe.MessageBus does not know anything about DiDrDe.Model because it's a generic project that should be valid for any message type. DiDrDe.ConsumerTwo => DiDrDe.MessageBus.DiDrDe.ConsumerTwo => DiDrDe.Contracts.DiDrDe.ConsumerOne => DiDrDe.MessageBus.DiDrDe.ConsumerOne => DiDrDe.Contracts.The dependencies should go in this direction: I want to have a project wrapping MassTransit functionality so that my Publisher and Consumers projects know nothing about MassTransit. This is the whole sample project git repo: I am successfully using MassTransit for a silly sample application where I publish an message (an event) from a Publisher console application and I receive it at two different consumers which are also console applications using RabbitMq.
0 Comments
Leave a Reply. |