You can configure the sender like this:
@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();
}
}
and the listener like this
@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();
}
}
I have a sample project that uses jms and Spring Integration as form of communication between two applications running on separate vm/process/:
https://github.com/vineey/sample-jobqueue