# HG changeset patch # User Dirk Olmes # Date 1600326191 -7200 # Node ID 8504317b9a09acead2a674a3a7d642df075a038e # Parent a9675808f1ddd2f4c88a5f281998a82b0551c85d Erweiterung um Sleuth, manuelle Konfiguration von Spring diff -r a9675808f1dd -r 8504317b9a09 spring-jms-playground/pom.xml --- a/spring-jms-playground/pom.xml Thu Sep 10 11:18:13 2020 +0200 +++ b/spring-jms-playground/pom.xml Thu Sep 17 09:03:11 2020 +0200 @@ -2,12 +2,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.1.16.RELEASE - - de.comline spring-jms-playground 0.0.1-SNAPSHOT @@ -37,11 +31,34 @@ + + + + org.springframework.boot + spring-boot-starter-parent + 2.1.16.RELEASE + pom + import + + + org.springframework.cloud + spring-cloud-dependencies + Greenwich.SR6 + pom + import + + + + org.springframework.boot spring-boot-starter-activemq + + org.springframework.cloud + spring-cloud-starter-sleuth + org.junit.jupiter diff -r a9675808f1dd -r 8504317b9a09 spring-jms-playground/src/main/java/de/comline/jms/application/Application.java --- a/spring-jms-playground/src/main/java/de/comline/jms/application/Application.java Thu Sep 10 11:18:13 2020 +0200 +++ b/spring-jms-playground/src/main/java/de/comline/jms/application/Application.java Thu Sep 17 09:03:11 2020 +0200 @@ -8,6 +8,11 @@ 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.cloud.sleuth.autoconfig.TraceAutoConfiguration; +import org.springframework.cloud.sleuth.instrument.messaging.ExposedSleuthJmsConfiguration; +import org.springframework.cloud.sleuth.instrument.messaging.TraceMessagingAutoConfiguration; +import org.springframework.cloud.sleuth.instrument.messaging.TraceSpringIntegrationAutoConfiguration; +import org.springframework.cloud.sleuth.log.SleuthLogAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @@ -20,15 +25,21 @@ @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); } + // @formatter:off +// @EnableAutoConfiguration +// @Import(QueueReceiver.class) @Configuration - @Import({ ActiveMQAutoConfiguration.class, JmsAutoConfiguration.class, QueueReceiver.class }) + @Import({ SleuthLogAutoConfiguration.class, TraceAutoConfiguration.class, TraceMessagingAutoConfiguration.class, ExposedSleuthJmsConfiguration.class, TraceSpringIntegrationAutoConfiguration.class, + ActiveMQAutoConfiguration.class, JmsAutoConfiguration.class, + QueueReceiver.class }) + // @formatter:on public static class AppConfig { @Bean(name = AMQ_FACTORY_BEAN) public JmsListenerContainerFactory configureJmsListenerFactory(ConnectionFactory connectionFactory, DefaultJmsListenerContainerFactoryConfigurer configurer) { diff -r a9675808f1dd -r 8504317b9a09 spring-jms-playground/src/main/java/org/springframework/cloud/sleuth/instrument/messaging/ExposedSleuthJmsConfiguration.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spring-jms-playground/src/main/java/org/springframework/cloud/sleuth/instrument/messaging/ExposedSleuthJmsConfiguration.java Thu Sep 17 09:03:11 2020 +0200 @@ -0,0 +1,13 @@ +package org.springframework.cloud.sleuth.instrument.messaging; + +import org.springframework.cloud.sleuth.instrument.messaging.TraceMessagingAutoConfiguration.SleuthJmsConfiguration; +import org.springframework.context.annotation.Import; + +/** + * This subclass is requierd to expose {@link SleuthJmsConfiguration} for + * {@link Import}ing in a static configuration. It should not be required as + * {@link SleuthJmsConfiguration} should be public. + */ +public class ExposedSleuthJmsConfiguration extends TraceMessagingAutoConfiguration.SleuthJmsConfiguration { + // just a hack for exposing the config to our app +} diff -r a9675808f1dd -r 8504317b9a09 spring-jms-playground/src/main/resources/application.properties --- a/spring-jms-playground/src/main/resources/application.properties Thu Sep 10 11:18:13 2020 +0200 +++ b/spring-jms-playground/src/main/resources/application.properties Thu Sep 17 09:03:11 2020 +0200 @@ -1,3 +1,10 @@ +logging.pattern.console = %d{HH:mm:ss.SSS} %-5p [%10.10t] [${spring.zipkin.service.name:${spring.application.name:-}},%X{X-B3-TraceId:-},%X{X-B3-SpanId:-},%X{X-Span-Export:-}] %c{1} : %m%n + #spring.activemq.user=admin #spring.activemq.password=admin spring.activemq.broker-url=tcp://localhost:61616 + +spring.application.name = jmstest + +spring.sleuth.messaging.enabled = true +spring.sleuth.messaging.jms.enabled = true diff -r a9675808f1dd -r 8504317b9a09 spring-jms-playground/src/main/resources/logback-spring.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spring-jms-playground/src/main/resources/logback-spring.xml Thu Sep 17 09:03:11 2020 +0200 @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file