Mercurial > hg > SpringPlayground
annotate spring-jms-playground/src/main/java/de/comline/jms/application/Application.java @ 19:fe6a57f7a2cf
Spring Cloud Config server
author | Dirk Olmes <dirk.olmes@codedo.de> |
---|---|
date | Thu, 17 Sep 2020 17:24:48 +0200 |
parents | 8504317b9a09 |
children |
rev | line source |
---|---|
15
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
1 package de.comline.jms.application; |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
2 |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
3 import javax.jms.ConnectionFactory; |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
4 |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
5 import org.slf4j.Logger; |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
6 import org.slf4j.LoggerFactory; |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
7 import org.springframework.boot.SpringApplication; |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
8 import org.springframework.boot.autoconfigure.jms.DefaultJmsListenerContainerFactoryConfigurer; |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
9 import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration; |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
10 import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration; |
18
8504317b9a09
Erweiterung um Sleuth, manuelle Konfiguration von Spring
Dirk Olmes <dirk.olmes@codedo.de>
parents:
16
diff
changeset
|
11 import org.springframework.cloud.sleuth.autoconfig.TraceAutoConfiguration; |
8504317b9a09
Erweiterung um Sleuth, manuelle Konfiguration von Spring
Dirk Olmes <dirk.olmes@codedo.de>
parents:
16
diff
changeset
|
12 import org.springframework.cloud.sleuth.instrument.messaging.ExposedSleuthJmsConfiguration; |
8504317b9a09
Erweiterung um Sleuth, manuelle Konfiguration von Spring
Dirk Olmes <dirk.olmes@codedo.de>
parents:
16
diff
changeset
|
13 import org.springframework.cloud.sleuth.instrument.messaging.TraceMessagingAutoConfiguration; |
8504317b9a09
Erweiterung um Sleuth, manuelle Konfiguration von Spring
Dirk Olmes <dirk.olmes@codedo.de>
parents:
16
diff
changeset
|
14 import org.springframework.cloud.sleuth.instrument.messaging.TraceSpringIntegrationAutoConfiguration; |
8504317b9a09
Erweiterung um Sleuth, manuelle Konfiguration von Spring
Dirk Olmes <dirk.olmes@codedo.de>
parents:
16
diff
changeset
|
15 import org.springframework.cloud.sleuth.log.SleuthLogAutoConfiguration; |
15
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
16 import org.springframework.context.annotation.Bean; |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
17 import org.springframework.context.annotation.Configuration; |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
18 import org.springframework.context.annotation.Import; |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
19 import org.springframework.jms.config.DefaultJmsListenerContainerFactory; |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
20 import org.springframework.jms.config.JmsListenerContainerFactory; |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
21 |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
22 import de.comline.jms.application.Application.AppConfig; |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
23 import de.comline.jms.receiver.QueueReceiver; |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
24 |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
25 @Import(AppConfig.class) |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
26 public class Application { |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
27 private static final Logger LOG = LoggerFactory.getLogger(Application.class); |
18
8504317b9a09
Erweiterung um Sleuth, manuelle Konfiguration von Spring
Dirk Olmes <dirk.olmes@codedo.de>
parents:
16
diff
changeset
|
28 |
16
4217059d40e8
Test zum Empfang einer ganzen JMS Message, nicht nur der Payload
Dirk Olmes <dirk.olmes@codedo.de>
parents:
15
diff
changeset
|
29 public static final String AMQ_FACTORY_BEAN = "amqFactory"; |
15
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
30 |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
31 public static void main(String[] args) { |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
32 SpringApplication.run(Application.class, args); |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
33 } |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
34 |
18
8504317b9a09
Erweiterung um Sleuth, manuelle Konfiguration von Spring
Dirk Olmes <dirk.olmes@codedo.de>
parents:
16
diff
changeset
|
35 // @formatter:off |
8504317b9a09
Erweiterung um Sleuth, manuelle Konfiguration von Spring
Dirk Olmes <dirk.olmes@codedo.de>
parents:
16
diff
changeset
|
36 // @EnableAutoConfiguration |
8504317b9a09
Erweiterung um Sleuth, manuelle Konfiguration von Spring
Dirk Olmes <dirk.olmes@codedo.de>
parents:
16
diff
changeset
|
37 // @Import(QueueReceiver.class) |
15
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
38 @Configuration |
18
8504317b9a09
Erweiterung um Sleuth, manuelle Konfiguration von Spring
Dirk Olmes <dirk.olmes@codedo.de>
parents:
16
diff
changeset
|
39 @Import({ SleuthLogAutoConfiguration.class, TraceAutoConfiguration.class, TraceMessagingAutoConfiguration.class, ExposedSleuthJmsConfiguration.class, TraceSpringIntegrationAutoConfiguration.class, |
8504317b9a09
Erweiterung um Sleuth, manuelle Konfiguration von Spring
Dirk Olmes <dirk.olmes@codedo.de>
parents:
16
diff
changeset
|
40 ActiveMQAutoConfiguration.class, JmsAutoConfiguration.class, |
8504317b9a09
Erweiterung um Sleuth, manuelle Konfiguration von Spring
Dirk Olmes <dirk.olmes@codedo.de>
parents:
16
diff
changeset
|
41 QueueReceiver.class }) |
8504317b9a09
Erweiterung um Sleuth, manuelle Konfiguration von Spring
Dirk Olmes <dirk.olmes@codedo.de>
parents:
16
diff
changeset
|
42 // @formatter:on |
15
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
43 public static class AppConfig { |
16
4217059d40e8
Test zum Empfang einer ganzen JMS Message, nicht nur der Payload
Dirk Olmes <dirk.olmes@codedo.de>
parents:
15
diff
changeset
|
44 @Bean(name = AMQ_FACTORY_BEAN) |
15
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
45 public JmsListenerContainerFactory<?> configureJmsListenerFactory(ConnectionFactory connectionFactory, DefaultJmsListenerContainerFactoryConfigurer configurer) { |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
46 DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
47 |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
48 factory.setErrorHandler(exception -> { |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
49 LOG.error("An error has occurred in JMS", exception); |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
50 }); |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
51 |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
52 configurer.configure(factory, connectionFactory); |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
53 return factory; |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
54 } |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
55 } |
ad77abd85976
playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
56 } |