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/chain.adoc
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -130,6 +130,7 @@ You can access them from the `BeanFactory` by using the appropriate bean name, a
130
130
131
131
TIP: It is useful to provide an explicit `id` attribute on `<chain>` elements to simplify the identification of sub-components in logs and to provide access to them from the `BeanFactory` etc.
132
132
133
+
[[chain-gateway]]
133
134
==== Calling a Chain from within a Chain
134
135
135
136
Sometimes, you need to make a nested call to another chain from within a chain and then come back and continue execution within the original chain.
Copy file name to clipboardExpand all lines: src/reference/asciidoc/dsl.adoc
+38Lines changed: 38 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -599,6 +599,44 @@ public IntegrationFlow integerFlow() {
599
599
600
600
Also see <<java-dsl-class-cast>>.
601
601
602
+
[[java-dsl-gateway]]
603
+
=== Operator gateway()
604
+
605
+
The `gateway()` operator in an `IntegrationFlow` definition is a special service activator implementation, to call some other endpoint or integration flow via its input channel and wait for reply.
606
+
Technically it plays the same role as a nested `<gateway>` component in a `<chain>` definition (see <<./chain.adoc#chain-gateway,Calling a Chain from within a Chain>>) and allows a flow to be cleaner and more straightforward.
607
+
Logically, and from business perspective, it is a messaging gateway to allow the distribution and reuse of functionality between different parts of the target integration solution (see <<./gateway.adoc#gateway,Messaging Gateways>>).
608
+
This operator has several overloads for different goals:
609
+
610
+
- `gateway(String requestChannel)` to send a message to some endpoint's input channel by its name;
611
+
- `gateway(MessageChannel requestChannel)` to send a message to some endpoint's input channel by its direct injection;
612
+
- `gateway(IntegrationFlow flow)` to send a message to the input channel of the provided `IntegrationFlow`.
613
+
614
+
All of these have a variant with the second `Consumer<GatewayEndpointSpec>` argument to configure the target `GatewayMessageHandler` and respective `AbstractEndpoint`.
615
+
Also the `IntegrationFlow`-based methods allows calling existing `IntegrationFlow` bean or declare the flow as a sub-flow via an in-place lambda for an `IntegrationFlow` functional interface or have it extracted in a `private` method cleaner code style:
616
+
617
+
====
618
+
[source,java]
619
+
----
620
+
@Bean
621
+
IntegrationFlow someFlow() {
622
+
return IntegrationFlows
623
+
.from(...)
624
+
.gateway(subFlow())
625
+
.handle(...)
626
+
.get();
627
+
}
628
+
629
+
private static IntegrationFlow subFlow() {
630
+
return f -> f
631
+
.scatterGather(s -> s.recipientFlow(...),
632
+
g -> g.outputProcessor(MessageGroup::getOne))
633
+
}
634
+
----
635
+
====
636
+
637
+
IMPORTANT: If the downstream flow does not always return a reply, you should set the `requestTimeout` to 0 to prevent hanging the calling thread indefinitely.
638
+
In that case, the flow will end at that point and the thread released for further work.
0 commit comments