문제

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