annotate spring-jms-playground/src/main/java/de/comline/jms/receiver/QueueReceiver.java @ 18:8504317b9a09

Erweiterung um Sleuth, manuelle Konfiguration von Spring
author Dirk Olmes <dirk.olmes@codedo.de>
date Thu, 17 Sep 2020 09:03:11 +0200
parents a9675808f1dd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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.receiver;
ad77abd85976 playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
2
16
4217059d40e8 Test zum Empfang einer ganzen JMS Message, nicht nur der Payload
Dirk Olmes <dirk.olmes@codedo.de>
parents: 15
diff changeset
3 import javax.jms.TextMessage;
4217059d40e8 Test zum Empfang einer ganzen JMS Message, nicht nur der Payload
Dirk Olmes <dirk.olmes@codedo.de>
parents: 15
diff changeset
4
15
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.jms.annotation.JmsListener;
ad77abd85976 playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
8 import org.springframework.stereotype.Component;
ad77abd85976 playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
9
16
4217059d40e8 Test zum Empfang einer ganzen JMS Message, nicht nur der Payload
Dirk Olmes <dirk.olmes@codedo.de>
parents: 15
diff changeset
10 import de.comline.jms.application.Application;
4217059d40e8 Test zum Empfang einer ganzen JMS Message, nicht nur der Payload
Dirk Olmes <dirk.olmes@codedo.de>
parents: 15
diff changeset
11
15
ad77abd85976 playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
12 @Component
ad77abd85976 playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
13 public class QueueReceiver {
ad77abd85976 playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
14 private static final Logger LOG = LoggerFactory.getLogger(QueueReceiver.class);
ad77abd85976 playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
15
16
4217059d40e8 Test zum Empfang einer ganzen JMS Message, nicht nur der Payload
Dirk Olmes <dirk.olmes@codedo.de>
parents: 15
diff changeset
16 @JmsListener(destination = "input-queue", containerFactory = Application.AMQ_FACTORY_BEAN)
15
ad77abd85976 playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
17 public void receive(String message) {
ad77abd85976 playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
18 LOG.info("received {}", message);
ad77abd85976 playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
19 }
16
4217059d40e8 Test zum Empfang einer ganzen JMS Message, nicht nur der Payload
Dirk Olmes <dirk.olmes@codedo.de>
parents: 15
diff changeset
20
4217059d40e8 Test zum Empfang einer ganzen JMS Message, nicht nur der Payload
Dirk Olmes <dirk.olmes@codedo.de>
parents: 15
diff changeset
21 @JmsListener(destination = "validated", containerFactory = Application.AMQ_FACTORY_BEAN)
17
a9675808f1dd Triggern der exception je nach Payload
Dirk Olmes <dirk.olmes@codedo.de>
parents: 16
diff changeset
22 public void receive(TextMessage message) throws Exception {
16
4217059d40e8 Test zum Empfang einer ganzen JMS Message, nicht nur der Payload
Dirk Olmes <dirk.olmes@codedo.de>
parents: 15
diff changeset
23 LOG.info("received message {}", message);
17
a9675808f1dd Triggern der exception je nach Payload
Dirk Olmes <dirk.olmes@codedo.de>
parents: 16
diff changeset
24
a9675808f1dd Triggern der exception je nach Payload
Dirk Olmes <dirk.olmes@codedo.de>
parents: 16
diff changeset
25 String text = message.getText();
a9675808f1dd Triggern der exception je nach Payload
Dirk Olmes <dirk.olmes@codedo.de>
parents: 16
diff changeset
26 if (text.contains("kaputt")) {
a9675808f1dd Triggern der exception je nach Payload
Dirk Olmes <dirk.olmes@codedo.de>
parents: 16
diff changeset
27 throw new IllegalStateException("Die Nachricht ist kaputt");
a9675808f1dd Triggern der exception je nach Payload
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 }
15
ad77abd85976 playground for spring boot JMS handling
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
30 }