Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @org.springframework.context.annotation.Configuration
- @ComponentScan("jms")
- @EnableTransactionManagement
- public class Configuration {
- @Bean
- public JmsTemplate jmsTemplate() {
- JmsTemplate jmsTemplate = new JmsTemplate();
- jmsTemplate.setConnectionFactory(connectionFactory());
- return jmsTemplate;
- }
- @Bean
- public ConnectionFactory connectionFactory() {
- ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory();
- activeMQConnectionFactory.setBrokerURL( "tcp://localhost:61616");
- return activeMQConnectionFactory;
- }
- @Bean
- public JmsTransactionManager transactionManager() {
- JmsTransactionManager p = new JmsTransactionManager(connectionFactory());
- return p;
- }
- }
- I am using jmsTemplate to retrieve a message.
- @Transactional
- void func() {
- while (true) {
- Message message = jmsTemplate.receive("jmsQueue.queue");
- System.out.println(message.toString());
- throw new RuntimeException();
- }
- }
Add Comment
Please, Sign In to add comment