daily pastebin goal
40%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @org.springframework.context.annotation.Configuration
  2. @ComponentScan("jms")
  3. @EnableTransactionManagement
  4. public class Configuration {
  5.  
  6.     @Bean
  7.     public JmsTemplate jmsTemplate() {
  8.  
  9.         JmsTemplate jmsTemplate = new JmsTemplate();
  10.         jmsTemplate.setConnectionFactory(connectionFactory());
  11.         return jmsTemplate;
  12.     }
  13.  
  14.     @Bean
  15.  
  16.     public ConnectionFactory connectionFactory() {
  17.         ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory();
  18.         activeMQConnectionFactory.setBrokerURL( "tcp://localhost:61616");
  19.         return activeMQConnectionFactory;
  20.     }
  21.  
  22.     @Bean
  23.     public JmsTransactionManager transactionManager() {
  24.         JmsTransactionManager p = new JmsTransactionManager(connectionFactory());
  25.         return p;
  26.     }
  27.  
  28. }
  29. I am using jmsTemplate to retrieve a message.
  30.  @Transactional
  31.     void func() {
  32.        while (true) {
  33.            Message message = jmsTemplate.receive("jmsQueue.queue");
  34.            System.out.println(message.toString());
  35.  
  36.            throw new RuntimeException();
  37.        }
  38. }
RAW Paste Data
Top