Вопрос

As far as I can understand from MassTransit's documentation and API, this is the only way to register a method message handler:

IServiceBus.SubscribeHandler<T>(Action<T> handler)

However, I'd like to register handlers using reflection based on attributes, so Ideally I need something like this:

IServiceBus.SubscribeHandler(Type messageType, Action<object> handler)

Does anything like that exist, or is there a way to achieve it?

Это было полезно?

Решение

MassTransit requires the type information "statically" in the call. There's no way around that.

You can however make calls to the SubscribeHandler<T> via reflection and pass in the generic's type information. A extension method to do this would work great, and could likely have the exact same signature you're looking for above.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top