如何在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>
答案 0 :(得分:0)
@Bean
public ActiveMQQueue requestQueue() {
return new ActiveMQQueue("queue.demo");
}
等
答案 1 :(得分:0)
您可以像这样配置发件人:
@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 /上运行的两个应用程序之间的通信形式: