Mercurial > hg > SpringPlayground
view spring-jms-playground/src/main/java/de/comline/jms/application/Application.java @ 16:4217059d40e8
Test zum Empfang einer ganzen JMS Message, nicht nur der Payload
author | Dirk Olmes <dirk.olmes@codedo.de> |
---|---|
date | Thu, 10 Sep 2020 09:32:21 +0200 |
parents | ad77abd85976 |
children | 8504317b9a09 |
line wrap: on
line source
package de.comline.jms.application; import javax.jms.ConnectionFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.jms.DefaultJmsListenerContainerFactoryConfigurer; import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration; import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.jms.config.DefaultJmsListenerContainerFactory; import org.springframework.jms.config.JmsListenerContainerFactory; import de.comline.jms.application.Application.AppConfig; import de.comline.jms.receiver.QueueReceiver; @Import(AppConfig.class) public class Application { private static final Logger LOG = LoggerFactory.getLogger(Application.class); public static final String AMQ_FACTORY_BEAN = "amqFactory"; public static void main(String[] args) { SpringApplication.run(Application.class, args); } @Configuration @Import({ ActiveMQAutoConfiguration.class, JmsAutoConfiguration.class, QueueReceiver.class }) public static class AppConfig { @Bean(name = AMQ_FACTORY_BEAN) public JmsListenerContainerFactory<?> configureJmsListenerFactory(ConnectionFactory connectionFactory, DefaultJmsListenerContainerFactoryConfigurer configurer) { DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); factory.setErrorHandler(exception -> { LOG.error("An error has occurred in JMS", exception); }); configurer.configure(factory, connectionFactory); return factory; } } }