[英]What is the id of the listener container when using Spring's JMS namespace?
According to the Spring Documentation for the JMS Namespace tags (ie <jms:listener-container>
), there is no id
attribute for a <jms:listener-container>
element. 根据Spring文档中有关JMS命名空间标签(即<jms:listener-container>
)的说明, <jms:listener-container>
元素没有id
属性。
How do I reference the listener container bean from other bean definitions if there is no id
for it? 如果没有id
,如何从其他bean定义中引用侦听器容器bean?
For example, say I have the following Listener container defined: 例如,说我定义了以下侦听器容器:
<jms:listener-container acknowledge="auto"
connection-factory="queueConnectionFactoryBean"
container-type="default"
destination-resolver="jndiDestinationResolver"
destination-type="queue"
message-converter="myConverter">
<jms:listener ref="myListenerPOJO" id="myQueueListener"
method="processThePOJO" destination="${myQueueListener.queue.jndiName}" />
</jms:listener-container>
And I want to define an inbound gateway that uses the above container. 我想定义一个使用上述容器的入站网关。 What would I use as the container
property for the inbound gateway definition? 我将什么用作入站网关定义的container
属性?
Example: 例:
<int-jms:inbound-gateway
request-channel="inboundChannel"
id="messageChannelAdapter"
container="**What Goes Here?**"
reply-channel="outboundChannel" />
Or am I misunderstanding the relationship between listener container and gateway? 还是我误解了侦听器容器和网关之间的关系?
The listener-container
element isn't meant for configuring a standalone JMS listener container. listener-container
元素并不用于配置独立的JMS侦听器容器。 It is meant to act as a blueprint for all enclosed listener
tags. 它旨在充当所有封闭的listener
标签的蓝图。 What, at runtime, actually happens is that a JMS Listener Container is constructed for each enclosed listener
. 在运行时实际上发生的是,为每个封闭的listener
器构造了一个JMS侦听器容器。 So there is not a single container but multiple. 因此,没有一个容器,而是多个容器。
As @artembilan mentioned the id of the container is set to the id of the listener. 正如@artembilan所提到的,容器的ID设置为侦听器的ID。 However when you would reuse the listener for spring integration it would render the listener useless. 但是,当您将侦听器重新用于Spring集成时,它将使侦听器无用。 A listener-container can only have a single MessageListener attached, not multiple. 一个侦听器-容器只能附加一个MessageListener,而不能多个。
If you want to use a listener container for a Spring Integration gateway you will have to construct one yourself using one of the *MessageListenerContainer
classes. 如果要对Spring Integration网关使用侦听器容器,则必须使用*MessageListenerContainer
类之一构造一个自己的容器。
As Marten said, listener-container
pupolates the MessageListenerContainer
beans for each listener
sub-element. 正如Marten所说, listener-container
为每个listener
子元素添加MessageListenerContainer
Bean。 And what is magic the target MessageListenerContainer
gets the id
from the listener's id
. 目标MessageListenerContainer
从侦听器的id
获取id
是什么呢?
So, in your case the <int-jms:inbound-gateway>
's container
should apply the value myQueueListener . 因此,在您的情况下, <int-jms:inbound-gateway>
的container
应应用值myQueueListener 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.