content: package net.alanbinu.springboot;
  
  import javax.jms.ConnectionFactory;
  
  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.ConfigurableApplicationContext;
  import org.springframework.context.annotation.Bean;
  import org.springframework.jms.annotation.EnableJms;
  import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
  import org.springframework.jms.config.JmsListenerContainerFactory;
  import org.springframework.jms.core.JmsTemplate;
  import org.springframework.jms.support.converter.MappingJackson2MessageConverter;
  import org.springframework.jms.support.converter.MessageConverter;
  import org.springframework.jms.support.converter.MessageType;
  
  import net.javaalanbinu.springboot.jms.User;
  
  @SpringBootApplication
  @EnableJms
  public class Application {
      private static Logger logger = LoggerFactory.getLogger(Application.class);
  
      public static void main(String[] args) throws Exception {
          ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);
  
          JmsTemplate jmsTemplate = context.getBean(JmsTemplate.class);
  
          //Send an user
          System.out.println("Sending an user message.");
          jmsTemplate.convertAndSend("userQueue",
                  new User("rameshfadatare@gmail.com", 5d, true));
  
          logger.info("Waiting for user and confirmation ...");
          System.in.read();
          context.close();
      }
  
      @Bean // Serialize message content to json using TextMessage
      public MessageConverter jacksonJmsMessageConverter() {
          MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
          converter.setTargetType(MessageType.TEXT);
          converter.setTypeIdPropertyName("_type");
          return converter;
      }
  
      @Bean
      public JmsListenerContainerFactory<?> connectionFactory(ConnectionFactory connectionFactory,
                                                              DefaultJmsListenerContainerFactoryConfigurer configurer) {
          DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
          // This provides all boot's default to this factory, including the message converter
          configurer.configure(factory, connectionFactory);
          // You could still override some of Boot's default if necessary.
          return factory;
      }
  }
  