Skip to content

Commit 78d7591

Browse files
authored
chore(amqp): Align example producer (#429)
1 parent 98046d0 commit 78d7591

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

springwolf-examples/springwolf-amqp-example/src/main/java/io/github/stavshamir/springwolf/example/amqp/consumers/ExampleConsumer.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto;
55
import io.github.stavshamir.springwolf.example.amqp.dtos.ExamplePayloadDto;
6-
import io.github.stavshamir.springwolf.example.amqp.producers.ExampleProducer;
6+
import io.github.stavshamir.springwolf.example.amqp.producers.AnotherProducer;
77
import lombok.RequiredArgsConstructor;
88
import lombok.extern.slf4j.Slf4j;
99
import org.springframework.amqp.core.ExchangeTypes;
@@ -18,12 +18,17 @@
1818
@RequiredArgsConstructor
1919
public class ExampleConsumer {
2020

21-
private final ExampleProducer exampleProducer;
21+
private final AnotherProducer anotherProducer;
2222

2323
@RabbitListener(queues = "example-queue")
2424
public void receiveExamplePayload(ExamplePayloadDto payload) {
2525
log.info("Received new message in example-queue: {}", payload.toString());
26-
exampleProducer.sendMessage(payload);
26+
27+
AnotherPayloadDto example = new AnotherPayloadDto();
28+
example.setExample(payload);
29+
example.setFoo("foo");
30+
31+
anotherProducer.sendMessage(example);
2732
}
2833

2934
@RabbitListener(queues = "another-queue")
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.AsyncOperation;
66
import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.AsyncPublisher;
77
import io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto;
8-
import io.github.stavshamir.springwolf.example.amqp.dtos.ExamplePayloadDto;
98
import lombok.RequiredArgsConstructor;
109
import org.springframework.amqp.rabbit.core.RabbitTemplate;
1110
import org.springframework.stereotype.Component;
1211

1312
@Component
1413
@RequiredArgsConstructor
15-
public class ExampleProducer {
14+
public class AnotherProducer {
1615
private final RabbitTemplate rabbitTemplate;
1716

1817
@AsyncPublisher(
@@ -21,9 +20,8 @@ public class ExampleProducer {
2120
channelName = "example-producer-channel-publisher",
2221
description = "Custom, optional description defined in the AsyncPublisher annotation"))
2322
@AmqpAsyncOperationBinding()
24-
public void sendMessage(ExamplePayloadDto msg) {
23+
public void sendMessage(AnotherPayloadDto msg) {
2524
// send
26-
AnotherPayloadDto dto = new AnotherPayloadDto("fooValue", msg);
27-
rabbitTemplate.convertAndSend("example-topic-exchange", "example-topic-routing-key", dto);
25+
rabbitTemplate.convertAndSend("example-topic-exchange", "example-topic-routing-key", msg);
2826
}
2927
}

springwolf-examples/springwolf-amqp-example/src/test/resources/asyncapi.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,11 @@
174174
},
175175
"message": {
176176
"schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0",
177-
"name": "io.github.stavshamir.springwolf.example.amqp.dtos.ExamplePayloadDto",
178-
"title": "ExamplePayloadDto",
179-
"description": "Example payload model",
177+
"name": "io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto",
178+
"title": "AnotherPayloadDto",
179+
"description": "Another payload model",
180180
"payload": {
181-
"$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.amqp.dtos.ExamplePayloadDto"
181+
"$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto"
182182
},
183183
"headers": {
184184
"$ref": "#/components/schemas/HeadersNotDocumented"

springwolf-examples/springwolf-amqp-example/src/test/resources/asyncapi_withdocketfromenvironment.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@
9292
},
9393
"message": {
9494
"schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0",
95-
"name": "io.github.stavshamir.springwolf.example.amqp.dtos.ExamplePayloadDto",
96-
"title": "ExamplePayloadDto",
97-
"description": "Example payload model",
95+
"name": "io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto",
96+
"title": "AnotherPayloadDto",
97+
"description": "Another payload model",
9898
"payload": {
99-
"$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.amqp.dtos.ExamplePayloadDto"
99+
"$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto"
100100
},
101101
"headers": {
102102
"$ref": "#/components/schemas/HeadersNotDocumented"

0 commit comments

Comments
 (0)