Skip to content

Instantly share code, notes, and snippets.

@ruwanka
Last active June 28, 2020 06:42
Show Gist options
  • Save ruwanka/ea0d8a854b95671aa6016e4b1865f8f9 to your computer and use it in GitHub Desktop.
Save ruwanka/ea0d8a854b95671aa6016e4b1865f8f9 to your computer and use it in GitHub Desktop.
spring boot jms application
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