65
65
import org .springframework .integration .handler .LoggingHandler ;
66
66
import org .springframework .integration .handler .MessageProcessor ;
67
67
import org .springframework .integration .handler .MessageTriggerAction ;
68
+ import org .springframework .integration .handler .ReactiveMessageHandlerAdapter ;
68
69
import org .springframework .integration .handler .ServiceActivatingHandler ;
69
70
import org .springframework .integration .router .AbstractMessageRouter ;
70
71
import org .springframework .integration .router .ErrorMessageExceptionTypeRouter ;
91
92
import org .springframework .messaging .Message ;
92
93
import org .springframework .messaging .MessageChannel ;
93
94
import org .springframework .messaging .MessageHandler ;
95
+ import org .springframework .messaging .ReactiveMessageHandler ;
94
96
import org .springframework .messaging .support .ChannelInterceptor ;
95
97
import org .springframework .messaging .support .InterceptableChannel ;
96
98
import org .springframework .util .Assert ;
@@ -891,7 +893,8 @@ public <P> B filter(@Nullable Class<P> expectedType, GenericSelector<P> genericS
891
893
892
894
/**
893
895
* Populate a {@link ServiceActivatingHandler} for the selected protocol specific
894
- * {@link MessageHandler} implementation from {@code Namespace Factory}:
896
+ * {@link MessageHandler} implementation
897
+ * from the respective namespace factory (e.g. {@code Http, Kafka, Files}):
895
898
* <pre class="code">
896
899
* {@code
897
900
* .handle(Amqp.outboundAdapter(this.amqpTemplate).routingKeyExpression("headers.routingKey"))
@@ -1097,7 +1100,8 @@ public B handle(MessageProcessorSpec<?> messageProcessorSpec,
1097
1100
1098
1101
/**
1099
1102
* Populate a {@link ServiceActivatingHandler} for the selected protocol specific
1100
- * {@link MessageHandler} implementation from {@code Namespace Factory}:
1103
+ * {@link MessageHandler} implementation
1104
+ * from the respective namespace factory (e.g. {@code Http, Kafka, Files}).
1101
1105
* In addition, accept options for the integration endpoint using {@link GenericEndpointSpec}.
1102
1106
* Typically, used with a Lambda expression:
1103
1107
* <pre class="code">
@@ -1221,7 +1225,7 @@ public B enrich(Consumer<EnricherSpec> enricherConfigurer) {
1221
1225
* Populate a {@link MessageTransformingHandler} for
1222
1226
* a {@link org.springframework.integration.transformer.HeaderEnricher}
1223
1227
* using header values from provided {@link MapBuilder}.
1224
- * Can be used together with {@code Namespace Factory} :
1228
+ * Can be used together with a namespace factory :
1225
1229
* <pre class="code">
1226
1230
* {@code
1227
1231
* .enrichHeaders(Mail.headers()
@@ -1242,7 +1246,7 @@ public B enrichHeaders(MapBuilder<?, String, Object> headers) {
1242
1246
* a {@link org.springframework.integration.transformer.HeaderEnricher}
1243
1247
* using header values from provided {@link MapBuilder}.
1244
1248
* In addition, accept options for the integration endpoint using {@link GenericEndpointSpec}.
1245
- * Can be used together with {@code Namespace Factory} :
1249
+ * Can be used together with a namespace factory :
1246
1250
* <pre class="code">
1247
1251
* {@code
1248
1252
* .enrichHeaders(Mail.headers()
@@ -2916,6 +2920,68 @@ public IntegrationFlow nullChannel() {
2916
2920
.get ();
2917
2921
}
2918
2922
2923
+ /**
2924
+ * Populate a terminal consumer endpoint for the selected protocol specific
2925
+ * {@link MessageHandler} implementation
2926
+ * from the respective namespace factory (e.g. {@code Http, Kafka, Files}).
2927
+ * In addition, accept options for the integration endpoint using {@link GenericEndpointSpec}.
2928
+ * @param messageHandlerSpec the {@link MessageHandlerSpec} to configure the protocol specific
2929
+ * {@link MessageHandler}.
2930
+ * @param <H> the {@link MessageHandler} type.
2931
+ * @return the current {@link BaseIntegrationFlowDefinition}.
2932
+ * @since 6.1
2933
+ */
2934
+ public <H extends ReactiveMessageHandler > IntegrationFlow handleReactive (
2935
+ ReactiveMessageHandlerSpec <?, H > messageHandlerSpec ) {
2936
+
2937
+ return handleReactive (messageHandlerSpec , null );
2938
+ }
2939
+
2940
+ /**
2941
+ * Populate a terminal consumer endpoint for the selected protocol specific
2942
+ * {@link MessageHandler} implementation
2943
+ * from the respective namespace factory (e.g. {@code Http, Kafka, Files}).
2944
+ * In addition, accept options for the integration endpoint using {@link GenericEndpointSpec}.
2945
+ * @param messageHandlerSpec the {@link MessageHandlerSpec} to configure the protocol specific
2946
+ * {@link MessageHandler}.
2947
+ * @param endpointConfigurer the {@link Consumer} to provide integration endpoint options.
2948
+ * @param <H> the {@link MessageHandler} type.
2949
+ * @return the current {@link BaseIntegrationFlowDefinition}.
2950
+ * @since 6.1
2951
+ */
2952
+ public <H extends ReactiveMessageHandler > IntegrationFlow handleReactive (
2953
+ ReactiveMessageHandlerSpec <?, H > messageHandlerSpec ,
2954
+ @ Nullable Consumer <GenericEndpointSpec <ReactiveMessageHandlerAdapter >> endpointConfigurer ) {
2955
+
2956
+ return
2957
+ addComponents (messageHandlerSpec .getComponentsToRegister ()).
2958
+ handleReactive (messageHandlerSpec .getObject ().getDelegate (), endpointConfigurer );
2959
+ }
2960
+
2961
+ /**
2962
+ * Add a {@link ReactiveMessageHandler} as a terminal {@link IntegrationFlow} operator.
2963
+ * @param reactiveMessageHandler the {@link ReactiveMessageHandler} to finish the flow.
2964
+ * @return The {@link IntegrationFlow} instance based on this definition.
2965
+ * @since 6.1
2966
+ */
2967
+ public IntegrationFlow handleReactive (ReactiveMessageHandler reactiveMessageHandler ) {
2968
+ return handleReactive (reactiveMessageHandler , null );
2969
+ }
2970
+
2971
+ /**
2972
+ * Add a {@link ReactiveMessageHandler} as a terminal {@link IntegrationFlow} operator.
2973
+ * @param reactiveMessageHandler the {@link ReactiveMessageHandler} to finish the flow.
2974
+ * @param endpointConfigurer the {@link Consumer} to configure a target endpoint for the handler.
2975
+ * @return The {@link IntegrationFlow} instance based on this definition.
2976
+ * @since 6.1
2977
+ */
2978
+ public IntegrationFlow handleReactive (ReactiveMessageHandler reactiveMessageHandler ,
2979
+ @ Nullable Consumer <GenericEndpointSpec <ReactiveMessageHandlerAdapter >> endpointConfigurer ) {
2980
+
2981
+ return handle (new ReactiveMessageHandlerAdapter (reactiveMessageHandler ), endpointConfigurer )
2982
+ .get ();
2983
+ }
2984
+
2919
2985
/**
2920
2986
* Finish this flow with delegation to other {@link IntegrationFlow} instance.
2921
2987
* @param other the {@link IntegrationFlow} to compose with.
0 commit comments