消息模板接收让Dispatcher没有订阅频道(Message Template receive gives Dispatcher has no subscribers for channel)
这是我的弹簧整合入站和出站,从终点获取列表。
<http:inbound-gateway id="webListGateway" request-channel="fromWeb_List" reply-channel="toWeb_List" path="/api/profile/V1/get" supported-methods="GET"> <http:header name="container" expression="#pathVariables.container"/> <http:header name="groupName" expression="#pathVariables.groupName"/> <http:header name="userId" expression="#pathVariables.userId"/> </http:inbound-gateway> <int:header-enricher input-channel="fromWeb_List" output-channel="toCloud_List"> <int:header name="apikey" value=“1234”/> </int:header-enricher> <http:outbound-gateway id="profileListGateway" request-channel="toCloud_List" reply-channel="sync_preferences" url=“localhost:8081/containers/{container}/groups/{groupName}/values/hierarchy/{userId}" http-method="GET" expected-response-type="java.lang.String" charset="UTF-8" extract-request-payload="false" header-mapper="headerMapper" encode-uri="true" > <http:uri-variable name="container" expression="headers.container"/> <http:uri-variable name="groupName" expression="headers.groupName"/> <http:uri-variable name="userId" expression="headers.userId"/> </http:outbound-gateway>
这是我的收件人列表路由器,它将列表发送回请求者,并将列表保存在另一个终点。
<int:recipient-list-router id="syncRouter" input-channel="sync_preferences"> <int:recipient channel="toWeb_List"/> <int:recipient channel="toCloud_Save"/> </int:recipient-list-router>
我也试图从java代码中调用出站网关,并试图通过在MessageTemplate上使用receive方法来获取来自Web_List通道的响应,这给我错误
MessagingTemplate template = new MessagingTemplate(); Message<String> message1 = MessageBuilder.withPayload("") .setHeader("container", “fwd”) .setHeader("groupName", “foo”) .setHeader("userId", “user”) .build(); template.send((MessageChannel) CONTEXT.getBean("fromWeb_List"),message1); PreList pre = (PreList) template.receive((MessageChannel)CONTEXT.getBean("toWeb_List"));
错误
Dispatcher has no subscribers for channel 'application:springboot.toWeb_List'
任何想法我在这里做错了。
This is my spring-integration inbound and out bound which gets a list from a end point.
<http:inbound-gateway id="webListGateway" request-channel="fromWeb_List" reply-channel="toWeb_List" path="/api/profile/V1/get" supported-methods="GET"> <http:header name="container" expression="#pathVariables.container"/> <http:header name="groupName" expression="#pathVariables.groupName"/> <http:header name="userId" expression="#pathVariables.userId"/> </http:inbound-gateway> <int:header-enricher input-channel="fromWeb_List" output-channel="toCloud_List"> <int:header name="apikey" value=“1234”/> </int:header-enricher> <http:outbound-gateway id="profileListGateway" request-channel="toCloud_List" reply-channel="sync_preferences" url=“localhost:8081/containers/{container}/groups/{groupName}/values/hierarchy/{userId}" http-method="GET" expected-response-type="java.lang.String" charset="UTF-8" extract-request-payload="false" header-mapper="headerMapper" encode-uri="true" > <http:uri-variable name="container" expression="headers.container"/> <http:uri-variable name="groupName" expression="headers.groupName"/> <http:uri-variable name="userId" expression="headers.userId"/> </http:outbound-gateway>
This is my recipient-list-router which send backs the list to requestor and also saves the list in another end point.
<int:recipient-list-router id="syncRouter" input-channel="sync_preferences"> <int:recipient channel="toWeb_List"/> <int:recipient channel="toCloud_Save"/> </int:recipient-list-router>
I am also trying to call the outbound gateway from java code and trying to get the response from toWeb_List channel by using receive method on MessageTemplate, which is giving me error
MessagingTemplate template = new MessagingTemplate(); Message<String> message1 = MessageBuilder.withPayload("") .setHeader("container", “fwd”) .setHeader("groupName", “foo”) .setHeader("userId", “user”) .build(); template.send((MessageChannel) CONTEXT.getBean("fromWeb_List"),message1); PreList pre = (PreList) template.receive((MessageChannel)CONTEXT.getBean("toWeb_List"));
error
Dispatcher has no subscribers for channel 'application:springboot.toWeb_List'
Any Idea what I am doing wrong here.
原文:https://stackoverflow.com/questions/49410896
最满意答案
您无法使用
MessagingGateway.receive()
DirectChannel
:protected final Message<?> doReceive(MessageChannel channel, long timeout) { Assert.notNull(channel, "MessageChannel is required"); Assert.state(channel instanceof PollableChannel, "A PollableChannel is required to receive messages");
正如Gary指出的,另一个
reply-channel="toWeb_List"
问题必须在入站网关中注册为correlator
才能接收消息。 这是在第一次请求时按要求完成的。 这就是为什么你得到这个Dispatcher has no subscribers
。真的,请尝试解释你想要做什么。
UPDATE
如果您打算从HTTP Inbound和其他类似的请求回复地点重复使用
<int:recipient-list-router>
,则应考虑放弃reply-channel
并仅依赖头中的replyChannel
。我的意思是可以有这样的
toWeb_List
通道bean定义,但不应该从reply-channel
使用它。 在这种情况下,你的配置应该是这样的:<int:recipient-list-router id="syncRouter" input-channel="sync_preferences"> <int:recipient channel="toWeb_List"/> <int:recipient channel="toCloud_Save"/> </int:recipient-list-router> <int:bridge input-channel="toWeb_List"/>
如果存在的话,
bridge
是将信息从输入通道转移到输出通道的组件。 否则,它将查询MessageHeaders
以获取replyChannel
值。 当您直接从Java调用时,这些内容将通过诸如<http:inbound-gateway>
或plain<int:gateway>
入站请求 - 回复组件完全填充。查看参考手册中的更多信息。
You can't use
DirectChannel
for theMessagingGateway.receive()
:protected final Message<?> doReceive(MessageChannel channel, long timeout) { Assert.notNull(channel, "MessageChannel is required"); Assert.state(channel instanceof PollableChannel, "A PollableChannel is required to receive messages");
Another issue that
reply-channel="toWeb_List"
has to be registered ascorrelator
in the Inbound Gateway to be able to receive messages, as Gary pointed. And that is done on demand, on the first request. That's why you get thatDispatcher has no subscribers
.And really, please, try to explain what you would like to do.
UPDATE
If you are going to reuse that
<int:recipient-list-router>
from the HTTP Inbound and from some other similar request-reply place, you should consider to drop off usage of thereply-channel
and just rely on thereplyChannel
in headers.I mean there can be that
toWeb_List
channel bean definition, but should not use it from thereply-channel
. In this case your config should be like this:<int:recipient-list-router id="syncRouter" input-channel="sync_preferences"> <int:recipient channel="toWeb_List"/> <int:recipient channel="toCloud_Save"/> </int:recipient-list-router> <int:bridge input-channel="toWeb_List"/>
The
bridge
is such a components to shift message from input channel to the output one, if present. Otherwise it consultsMessageHeaders
for thereplyChannel
value. And this is is populated exactly via those Inbound request-reply components such as<http:inbound-gateway>
or plain<int:gateway>
when you call directly from Java.See more information in the Reference Manual.
相关问答
更多-
请参阅AMQP参考 ,了解durable和persistent均值的解释。 基本上, 队列要么durable要么non-durable 。 前者经纪人重新生存,后者不。 消息以transient或persistent 。 这个想法是, persistent队列上的durable persistent消息也应该能够在代理重启之后幸存下来。 所以,为了得到你想要的,你需要1)声明队列是durable ,2)将消息发布为persistent 。 另外,您可能还希望在频道上启用发布商确认 ; 这样,你就会知道经纪人 ...
-
在实例化bean之后但在连接其余上下文之前调用init / @PostConstruct方法(在这种情况下,在RMI适配器订阅了通道之前)。 您需要等到上下文完全刷新。 一种方法是实施 ApplicationListener
并将您的代码放入 public void onApplicationEvent(ContextRefreshedEvent event) 在上下文完全连线后将调用该方法。 The init/@PostConstruct method i ... -
使用localSession似乎是答案。 我实现了这个解决方案: ClientSessionChannel channel = localSession.getChannel(getClientChannel()); channel.publish(map); 客户现在正在接收所有消息。 Using the localSession seems to be the answer. I implemented this to fix: ClientSessionChannel channel = local ...
-
您的适配器正在将其数据发送到eventUpdateChannel ,后者不再订阅任何内容。 以前,
订阅了它。 根据您的评论,您需要 消息模板接收让Dispatcher没有订阅频道(Message Template receive gives Dispatcher has no subscribers for channel)[2022-05-23]
您无法使用MessagingGateway.receive() DirectChannel : protected final Message> doReceive(MessageChannel channel, long timeout) { Assert.notNull(channel, "MessageChannel is required"); Assert.state(channel instanceof PollableChannel, "A PollableChannel ...获取我拥有的频道的订阅者列表 如果您想查看YouTube频道的订阅者,则需要使用包含以下字段的资源subscription.list : part: subscriberSnippet mySubscribers: true 并使用OAuth2.0进行身份验证。 然后查看用户的电子邮件 电子邮件是私人信息,只有在频道所有者授予您许可的情况下,您才能获得该信息。 get a list of subscribers to a channel i own If you want check the subscr ...Youtube Data API检索过去日期的频道订阅者数量(Youtube Data API retrieve channel subscribers count for past dates)[2021-04-14]
没有内置的方法来对您的订阅者进行历史性的审视。 您可以做的是在给定日期检索您的订阅者列表,并在某处自己保留。 然后在下周再做一次并进行比较。 API返回JSON响应,查找如下所示: https://www.googleapis.com/youtube/v3/subscriptions?part=snippet&mySubscribers=true&key= {API_KEY_GOES_HERE} 您可以在此处阅读有关文档中的语法和参数的更多信息: 链接 There is no built in way to ...PubNub延迟接收来自订阅频道的消息(Android)(PubNub delay to receive message from subscribed channel (Android))[2021-12-07]
似乎你使用过时的SDK版本。 尝试使用最新的4.3.0 我只是这样实现它 PNConfiguration pnConfiguration = new PNConfiguration(); pnConfiguration.setSubscribeKey(youKey); pnConfiguration.setReconnectionPolicy(PNReconnectionPolicy.LINEAR); pubnub = new PubNub(pnConfi ...使用Spring DSL进行Spring集成“发布订阅频道”(Spring Integration “Publish Subscribe Channel” with Spring DSL)[2021-10-03]
.transform(new ObjectToStringTransformer())试图在某个地方发送结果,但它不知道在哪里 - 入站适配器不期望回复,变换器无处可发送数据。 也许你的意思是这样的...... @Bean public IntegrationFlow receiveHttpPost() { return IntegrationFlows.from(Http.inboundChannelAdapter("/receive") .mappedRequestHeaders ...Dispatcher没有订阅者(Dispatcher has no subscribers)[2021-11-08]
实现SmartLifeCycle并返回Integer.MAX_VALUE阶段。 然后,你的bean将是最后一个被初始化的bean(CEFB有一个阶段= 0)。 Implement SmartLifeCycle and return a phase of Integer.MAX_VALUE. Then, your bean will one of the last to be initialized (CEFB has a phase = 0).相关文章
更多- dede:channel调用栏目后添加字段
- java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter的解决方案
- 《数据结构与STL》(Data Structures and the Standard Template Library)扫描版[PDF]
- 《Joomla 2.5 模板教程:宁皓网》(Create a Joomla 2.5 Template)前两章 + 模板资源[光盘镜像]
- 新浪微博failed to receive access token
- JMS&ActiveMQ实战- 消息的接收与监听
- 频道DAO层-java cms开发一
- 模板类怎么在另一个文件中使用?
- struts2配置的一个小疑惑
- 频道实体类-java cms开发一