Last active
June 28, 2020 06:42
-
-
Save ruwanka/ea0d8a854b95671aa6016e4b1865f8f9 to your computer and use it in GitHub Desktop.
spring boot jms application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.aptkode; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.boot.autoconfigure.jms.DefaultJmsListenerContainerFactoryConfigurer; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.jms.annotation.EnableJms; | |
import org.springframework.jms.annotation.JmsListener; | |
import org.springframework.jms.config.DefaultJmsListenerContainerFactory; | |
import org.springframework.jms.config.JmsListenerContainerFactory; | |
import javax.jms.ConnectionFactory; | |
@SpringBootApplication | |
@EnableJms | |
public class SpringBootActivemqDemoApplication { | |
private static final Logger logger = LoggerFactory.getLogger(SpringBootActivemqDemoApplication.class); | |
public static void main(String[] args) { | |
SpringApplication.run(SpringBootActivemqDemoApplication.class, args); | |
} | |
@Bean | |
public JmsListenerContainerFactory<?> jmsTopicContainerFactory( | |
ConnectionFactory connectionFactory, | |
DefaultJmsListenerContainerFactoryConfigurer configurer ) | |
{ | |
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); | |
configurer.configure( factory, connectionFactory ); | |
factory.setPubSubDomain( true ); | |
return factory; | |
} | |
@JmsListener( destination = "aptkode", | |
containerFactory = "jmsTopicContainerFactory" ) | |
public void receiveMessage( String message ) | |
{ | |
logger.info("jms message: {}", message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment