|
16 | 16 |
|
17 | 17 | package com.example; |
18 | 18 |
|
19 | | -import com.fasterxml.jackson.core.JsonProcessingException; |
20 | | -import com.fasterxml.jackson.databind.ObjectMapper; |
| 19 | +import tools.jackson.databind.ObjectMapper; |
21 | 20 |
|
22 | 21 | import org.springframework.amqp.core.Binding; |
23 | 22 | import org.springframework.amqp.core.BindingBuilder; |
@@ -50,19 +49,13 @@ SimpleMessageListenerContainer messageListenerContainer(ConnectionFactory connec |
50 | 49 |
|
51 | 50 | @Bean |
52 | 51 | MessageListener exampleListener(final RabbitTemplate rabbitTemplate) { |
53 | | - return new MessageListener() { |
54 | | - public void onMessage(Message message) { |
55 | | - System.out.println("received: " + message); |
56 | | - try { |
57 | | - String payload = new ObjectMapper() |
58 | | - .writeValueAsString(new MyPojo("992e46d8-ab05-4a26-a740-6ef7b0daeab3", "CREATED")); |
59 | | - Message outputMessage = MessageBuilder.withBody(payload.getBytes()).build(); |
60 | | - rabbitTemplate.send(issue178OutputExchange().getName(), "routingkey", outputMessage); |
61 | | - } |
62 | | - catch (JsonProcessingException e) { |
63 | | - throw new RuntimeException(e); |
64 | | - } |
65 | | - } |
| 52 | + return message -> { |
| 53 | + System.out.println("received: " + message); |
| 54 | + String payload = new ObjectMapper() |
| 55 | + .writeValueAsString(new MyPojo("992e46d8-ab05-4a26-a740-6ef7b0daeab3", "CREATED")); |
| 56 | + Message outputMessage = MessageBuilder.withBody(payload.getBytes()).build(); |
| 57 | + rabbitTemplate.send(issue178OutputExchange().getName(), "routingkey", outputMessage); |
| 58 | + |
66 | 59 | }; |
67 | 60 | } |
68 | 61 |
|
|
0 commit comments