[英]Spring Integration message-driven-channel-adapter tag not honoring bean name?
I'm using Spring Integration 4.0.3.RELEASE and Spring Framework 4.0.2.RELEASE. 我正在使用Spring Integration 4.0.3.RELEASE和Spring Framework 4.0.2.RELEASE。
I have the following Spring Integration code in my context file: 我的上下文文件中有以下Spring Integration代码:
<int-jms:message-driven-channel-adapter id="exchangeQueueChannelAdapter"
auto-startup="true"
destination="exchangeQueueJmsDestination"
channel="exchangeSpringQueueChannel"
receive-timeout="1000"
connection-factory="WMQCachedConnectionFactory"
acknowledge="transacted"
transaction-manager="WMQTxManager"
error-channel="errorChannel"/>
Notice that I've given the bean being created a name [exchangeQueueChannelAdapter]. 注意,我给正在创建的bean命名为[exchangeQueueChannelAdapter]。 When exceptions occur within the underlying DefaultMessageListenerContainer
however it doesn't appear like the Spring Integration tags are passing the beanName to the DefaultMessageListenerContainer
class. 当底层DefaultMessageListenerContainer
发生异常时,它不会像Spring Integration标记将beanName传递给DefaultMessageListenerContainer
类那样。 This results in an exception looking like this (notice the thread name): 这将导致如下所示的异常(注意线程名称):
[org.springframework.jms.listener.DefaultMessageListenerContainer#0-1] WARN (org.springframework.jms.listener.DefaultMessageListenerContainer) - Setup of JMS message listener invoker failed for destination 'queue://CDCS.F370ZZZ.TRADOUT.FIXML' - trying to recover. Cause: Could not create JMS transaction; nested exception is javax.jms.JMSException: Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused: connect
[DefaultMessageListenerContainer-1] ERROR (org.springframework.jms.listener.DefaultMessageListenerContainer) - Could not refresh JMS Connection for destination 'citi.cibtech.na.ExPro_149155.DERIVS_ETD_TRD.TMG_CONTROLBUS.T1' - retrying in 5000 ms. Cause: Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused: connect
Looking at the DefaultMessageListenerContainer
code, it appears that it would prepend the beanName to the front of the threadname if it were passed into the class when it's initialized. 查看DefaultMessageListenerContainer
代码,似乎在初始化时将beanName传递到类中时,它将beanName放在线程名的前面。
protected TaskExecutor createDefaultTaskExecutor() {
String beanName = getBeanName();
String threadNamePrefix = (beanName != null ? beanName + "-" : DEFAULT_THREAD_NAME_PREFIX);
return new SimpleAsyncTaskExecutor(threadNamePrefix);
}
Ideally I'd like a way to be able to get the thread to have my bean name somewhere in the name of the thead (ie "exchangeQueueChannelAdapter#0-1"). 理想情况下,我希望有一种方法能够使线程在thead名称中的某个位置具有我的bean名称(即“ exchangeQueueChannelAdapter#0-1”)。 Is there a way to do that without having to create a DefaultMessageListenerContainer
on my own? 有没有一种方法可以不必自己创建DefaultMessageListenerContainer
? Perhaps I'm missing something? 也许我缺少什么?
You can create an external TaskExecutor
with a custom name and the threads will be named that way... 您可以使用自定义名称创建外部TaskExecutor
,然后将以这种方式命名线程...
<task:executor id="foo" />
Threads will be named "foo-n" 线程将被命名为“ foo-n”
Provide it to the adapter using the task-executor
attribute. 使用task-executor
属性将其提供给适配器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.