Skip to content

Commit 74caf72

Browse files
committed
Init doc for multi request
1 parent f822df9 commit 74caf72

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

documentation/src/main/docs/kafka/request-reply.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,21 @@ Like the core Emitter's `send` methods, `request` method also can receive a `Mes
6565
The ingested reply type of the `KafkaRequestReply` is discovered at runtime,
6666
in order to configure a `MessageConveter` to be applied on the incoming message before returning the `Uni` result.
6767

68+
## Requesting multiple replies
69+
70+
You can use the `requestMulti` method to expect any number of replies represented by the `Multi` return type.
71+
72+
For example this can be used to aggregate multiple replies to a single request.
73+
74+
``` java
75+
{{ insert('kafka/outbound/KafkaRequestReplyMultiEmitter.java') }}
76+
```
77+
Like the other `request` you can also request `Message` types.
78+
79+
!!! note
80+
The channel attribute `reply.timeout` will be applied between each message, if reached the returned `Multi` will
81+
fail.
82+
6883
## Scaling Request/Reply
6984

7085
If multiple requestor instances are configured on the same outgoing topic, and the same reply topic,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.acme;
2+
3+
import jakarta.enterprise.context.ApplicationScoped;
4+
import jakarta.inject.Inject;
5+
6+
import org.eclipse.microprofile.reactive.messaging.Channel;
7+
8+
import io.smallrye.mutiny.Multi;
9+
import io.smallrye.reactive.messaging.kafka.reply.KafkaRequestReply;
10+
11+
@ApplicationScoped
12+
public class KafkaRequestReplyMultiEmitter {
13+
14+
@Inject
15+
@Channel("my-request")
16+
KafkaRequestReply<String, Integer> quoteRequest;
17+
18+
public Multi<Integer> requestQuote(String request) {
19+
return quoteRequest.requestMulti(request).select().first(5);
20+
}
21+
}

0 commit comments

Comments
 (0)