简体   繁体   English

Spring Integration message-driven-channel-adapter标签不遵守bean名称吗?

[英]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.

相关问题 spring集成消息驱动通道适配器 - spring integration message-driven-channel-adapter Spring Integration Kafka消息驱动通道适配器接收消息 - Spring Integration Kafka message-driven-channel-adapter receive message 保护JMS消息驱动通道适配器 - Securing JMS message-driven-channel-adapter 消息驱动通道适配器或JMS网关的错误通道 - Error channel for message-driven-channel-adapter or JMS gateway RecordFilterStrategy with int-kafka:message-driven-channel-adapter - RecordFilterStrategy with int-kafka:message-driven-channel-adapter 使用 spring 集成消息驱动的通道适配器配置 AtomikosConnectionFactoryBean - Configuring AtomikosConnectionFactoryBean with spring integration message driven channel adapter Java DSL中具有“选择器”创建功能的“ int-jms:message-driven-channel-adapter” - 'int-jms:message-driven-channel-adapter' with 'selector' creation in Java DSL Spring Integration中如何将目标值从许多消息驱动的通道适配器传递到公共入站通道 - How to pass the destination value from many message driven channel adapter to common inbound channel in spring integration Spring集成JMS消息“驱动通道适配器”以使用Java配置连接到IBM MQ - Spring integration JMS message Driven Channel Adapter to connect to IBM MQ using java configuration 使用Spring Integration Java配置创建消息驱动的入站通道适配器以连接到Kafka - Creating a message driven inbound channel adapter to connect to Kafka using Spring integration java configuration
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM