我有一个非常简单的同步通信示例:
gateway -> router -> channel1
-> channel2
-> channelx
这是我的定义:
<si:channel id="sendToChannel"/>
<si:gateway id="sender"
service-interface="com.messaging.MessageGateway"
default-request-channel="sendToChannel"/>
<si:router id="messageRouter"
input-channel="sendToChannel" >
<bean class="com.messaging.MessageRouter"/>
</si:router>
路由器定义如下:
public class MessageRouter {
/** Route messages on the basis of message DESTINATION. */
public String routeMessage(Message<?> message) {
if (message.getDestination().equals("channel1")) {
return "channel1";
...
为什么我会得到这个异常?这是否意味着 geteway 不能成为 DirectChannel sendToChannel 的调度程序?
Caused by: org.springframework.integration.MessageDeliveryException: Dispatcher has no subscribers for channel sendToChannel.
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:82) ~[spring-integration-core-2.2.5.RELEASE.jar:na]
at
... 77 common frames omitted
更新:添加了更多信息
我发送的消息包含带有源/目标/消息类型信息的标头以及可以是映射或空字符串的有效负载。
我的网关界面如下所示:
public interface MessageGateway {
public static final String EMPTY = "'EMPTY_PARAMS'";
@Gateway
public void sendMessage(
@Headers Map<String, Object> headers,
@Payload Map<MessageParameter,String> hm);
/** Send a message with empty payload. */
@Gateway
@Payload(EMPTY)
public void sendMessage(@Headers Map<String, Object> headers);
@Gateway
public void sendRawMessage(Message<?> message);