问题
In spring integration, I am trying to create a Direct Message channel with a custom scope as follows
...
<int:channel id="myChannel" scope="validCustomScope" />
<int:service-activator ref="validSericeReference_WithSameValidCustomScope" method="handleMessage" input-channel="myChannel"/>
...
However, I am running into an exception ..
org.springframework.integration.MessageDeliveryException: Dispatcher has no subscribers for channel
Note: this custom scope works for other beans. This issue is similar to what is discussed here, but to no resolution. If someone can help resolve this issue, it will be a huge help.
回答1:
The service activator will only get subscribed to one of the instances. The others will throw Dispatcher has no subscribers
.
Your custom scope would need to figure out how to propagate the subscription (service activator's MessageHandler
) for every instance when the service activator is start()
ed, and then propagate it to any new instances created after
the endpoint was started.
Non-trivial probably.
That said. the benefit of a scoped channel sending messages to a non-scoped service is not clear to me.
Perhaps if you explain what you are trying to do with the custom scope there might be a general solution, but my guess it will need some tricky code in the custom scope.
回答2:
That is a good explanation to why "Dispatcher has no subscribers" exception is encountered. We are going to employ Spring Integration in a multi-tenant environment so each tenant uses his/her own channels and service activators. We have applied the same scope to the service activator bean definition. Any suggestions to this?
<bean id="validSericeReference" class="ValidSericeClass" scope="validCustomScope"/>
来源:https://stackoverflow.com/questions/22416223/custom-spring-scope-not-working-for-message-channel