package com.twcable.smp.spring.integration; import org.apache.activemq.ActiveMQConnectionFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.integration.annotation.IntegrationComponentScan; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.jms.Jms; import org.springframework.integration.stream.CharacterStreamWritingMessageHandler; import javax.jms.ConnectionFactory; @Configuration @EnableIntegration @ComponentScan @IntegrationComponentScan public class IntegrationConfiguration { @Bean ConnectionFactory connectionFactory() { return new ActiveMQConnectionFactory("tcp://localhost:61616"); } @Bean public IntegrationFlow jmsInboundFlow() { return IntegrationFlows.from(Jms.messageDrivenChannelAdapter(connectionFactory()) .destination("TopicName") .configureListenerContainer( c -> {c.pubSubDomain(true); })) .handle(CharacterStreamWritingMessageHandler.stdout()) .get(); } }
Wednesday, March 9, 2016
Subscribing to a JMS Topic with Spring Integration Java DSL
I couldn't find this on google or stack overflow so here is my working solution for connecting to an activemq JMS topic on localhost:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment