在 java 1.7 中将 JMS 出站通道适配器转换为等效的 Spring Integration DSL
Posted
技术标签:
【中文标题】在 java 1.7 中将 JMS 出站通道适配器转换为等效的 Spring Integration DSL【英文标题】:Convert JMS out bound channel adapter to equavalent Spring Integration DSL in java 1.7 【发布时间】:2015-11-26 15:51:09 【问题描述】:如何在 java 1.7 中将 <int-jms:outbound-channel-adapter channel="topicChannel" destination="requestQueue"/>
转换为等效的 Spring Integration DSL
下面是 ActiveMQ 配置:
<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616"/>
</bean>
</property>
<property name="sessionCacheSize" value="10"/>
</bean>
<bean id="requestQueue" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="queue.demo"/>
</bean>
【问题讨论】:
@Bean
public ActiveMQQueue requestQueue()
return new ActiveMQQueue("queue.demo");
等等
【讨论】:
Gary 感谢您的回复....你能告诉我您可以像这样配置发件人:
@Configuration
@ComponentScan(basePackages = "com.sample.dispatcher" )
public class DispatcherConfig
public static final String JOB_TOPIC = "jobTopic";
@Bean
@ServiceActivator(inputChannel = JOB_TOPIC)
public MessageHandler outboundJmsAdapter(JmsTemplate template)
JmsSendingMessageHandler handler = new JmsSendingMessageHandler(template);
handler.setDestinationName(JOB_TOPIC);
return handler;
@Bean(name = JOB_TOPIC)
public MessageChannel jobTopic()
return new PublishSubscribeChannel();
和这样的听众
@Configuration
@ComponentScan(basePackages = "com.sample.processor" )
@IntegrationComponentScan(basePackages = "com.sample.processor" )
public class ProcessorConfig
public static final String ON_POST_JOB = "onPostJob";
public static final String JOB_TOPIC = "jobTopic";
@Bean
public Queue jobTopic()
return new ActiveMQQueue(JOB_TOPIC);
@Bean
public JmsMessageDrivenEndpoint inboundJmsAdapter(ConnectionFactory connectionFactory)
return new JmsMessageEndpointBuilder()
.setConnectionFactory(connectionFactory)
.setDestination(JOB_TOPIC)
.setInputChannel(onPostJob())
.build();
@Bean(name = ON_POST_JOB)
public MessageChannel onPostJob()
return new PublishSubscribeChannel();
我有一个示例项目,它使用 jms 和 Spring Integration 作为在单独的 vm/process/ 上运行的两个应用程序之间的通信形式:
https://github.com/vineey/sample-jobqueue
【讨论】:
以上是关于在 java 1.7 中将 JMS 出站通道适配器转换为等效的 Spring Integration DSL的主要内容,如果未能解决你的问题,请参考以下文章
是否有兼容 Java 1.7 的 Artemis JMS 客户端?