You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/reference/asciidoc/si-kafka.adoc
+120Lines changed: 120 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -277,6 +277,125 @@ In most cases, this will be an `ErrorMessageSendingRecoverer` which will send th
277
277
When building `ErrorMessage` (for use in the `error-channel` or `recovery-callback`), you can customize the error message using the `error-message-strategy` property.
278
278
By default, a `RawRecordHeaderErrorMessageStrategy` is used; providing access to the converted message as well as the raw `ConsumerRecord`.
279
279
280
+
281
+
[[si-outbound-gateway]]
282
+
==== Outbound Gateway
283
+
284
+
The outbound gateway is for request/reply operations; it is different to most Spring Integration gateways in that the sending thread does not block in the gateway, the reply is processed on the reply listener container thread.
285
+
Of course, if user code invokes the gateway behind a synchronous https://docs.spring.io/spring-integration/reference/html/messaging-endpoints-chapter.html#gateway[Messaging Gateway], the user thread will block there until the reply is received (or a timeout occurs).
286
+
287
+
IMPORTANT: the gateway will not accept requests until the reply container has been assigned its topics and partitions.
288
+
It is suggested that you add a `ConsumerRebalanceListener` to the template's reply container properties and wait for the `onPartitionsAssigned` call before sending messages to the gateway.
289
+
290
+
Here is an example of configuring a gateway, with Java Configuration:
return new KafkaProducerMessageHandler<>(kafkaTemplate);
299
+
}
300
+
----
301
+
302
+
Notice that the same class as the <<si-outbound, outbound channel adapter>> is used, the only difference being that the kafka template passed into the constructor is a `ReplyingKafkaTemplate` - see <<replying-template>> for more information.
303
+
304
+
The outbound topic, partition, key etc, are determined the same way as the outbound adapter.
305
+
The reply topic is determined as follows:
306
+
307
+
1. A message header `KafkaHeaders.REPLY_TOPIC`, if present (must have a `String` or `byte[]` value) - validated against the template's reply container subscribed topics.
308
+
2. If the template's `replyContainer` is subscribed to just one topic, it will be used.
309
+
310
+
You can also specify a `KafkaHeaders.REPLY_PARTITION` header to determine a specific partition to be used for replies.
311
+
Again, this is validated against the template's reply container subscriptions.
0 commit comments