Mercurial > hg > SpringPlayground
changeset 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 | a9675808f1dd |
files | spring-jms-playground/src/main/java/de/comline/jms/application/Application.java spring-jms-playground/src/main/java/de/comline/jms/receiver/QueueReceiver.java |
diffstat | 2 files changed, 13 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/spring-jms-playground/src/main/java/de/comline/jms/application/Application.java Thu Sep 10 08:44:20 2020 +0200 +++ b/spring-jms-playground/src/main/java/de/comline/jms/application/Application.java Thu Sep 10 09:32:21 2020 +0200 @@ -20,6 +20,8 @@ @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); @@ -28,7 +30,7 @@ @Configuration @Import({ ActiveMQAutoConfiguration.class, JmsAutoConfiguration.class, QueueReceiver.class }) public static class AppConfig { - @Bean(name = "amqFactory") + @Bean(name = AMQ_FACTORY_BEAN) public JmsListenerContainerFactory<?> configureJmsListenerFactory(ConnectionFactory connectionFactory, DefaultJmsListenerContainerFactoryConfigurer configurer) { DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
--- a/spring-jms-playground/src/main/java/de/comline/jms/receiver/QueueReceiver.java Thu Sep 10 08:44:20 2020 +0200 +++ b/spring-jms-playground/src/main/java/de/comline/jms/receiver/QueueReceiver.java Thu Sep 10 09:32:21 2020 +0200 @@ -1,16 +1,25 @@ package de.comline.jms.receiver; +import javax.jms.TextMessage; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.jms.annotation.JmsListener; import org.springframework.stereotype.Component; +import de.comline.jms.application.Application; + @Component public class QueueReceiver { private static final Logger LOG = LoggerFactory.getLogger(QueueReceiver.class); - @JmsListener(destination = "input-queue", containerFactory = "amqFactory") + @JmsListener(destination = "input-queue", containerFactory = Application.AMQ_FACTORY_BEAN) public void receive(String message) { LOG.info("received {}", message); } + + @JmsListener(destination = "validated", containerFactory = Application.AMQ_FACTORY_BEAN) + public void receive(TextMessage message) { + LOG.info("received message {}", message); + } }