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
Fixes#3615
The `log()` operator for Java DSL in the end of flow causes a confusion
for its different behavior and, therefore, inconsistency with expectations
* Populate a `bridge()` in the end of flow instead of `nullChannel` when
the current component is `WireTapSpec` (relevant to `wireTap()` and `log()`)
* Deprecate a `logAndReply()` operator since its behavior is now included into the `log()` in the end if flow
* Fix tests to use just `log()` in the end from now on
* Fix `dsl.adoc` for the new `log()` behaviour in the end of flow
Copy file name to clipboardExpand all lines: spring-integration-core/src/main/java/org/springframework/integration/dsl/BaseIntegrationFlowDefinition.java
+27-40
Original file line number
Diff line number
Diff line change
@@ -2182,9 +2182,6 @@ public B gateway(IntegrationFlow flow, Consumer<GatewayEndpointSpec> endpointCon
2182
2182
* logging level and {@code org.springframework.integration.handler.LoggingHandler}
2183
2183
* as a default logging category.
2184
2184
* <p> The full request {@link Message} will be logged.
2185
-
* <p> When this operator is used in the end of flow, it is treated
2186
-
* as one-way handler without any replies to continue.
2187
-
* The {@link #logAndReply()} should be used for request-reply configuration.
2188
2185
* @return the current {@link BaseIntegrationFlowDefinition}.
2189
2186
* @see #wireTap(WireTapSpec)
2190
2187
*/
@@ -2198,9 +2195,6 @@ public B log() {
2198
2195
* logging level and {@code org.springframework.integration.handler.LoggingHandler}
2199
2196
* as a default logging category.
2200
2197
* <p> The full request {@link Message} will be logged.
2201
-
* <p> When this operator is used in the end of flow, it is treated
2202
-
* as one-way handler without any replies to continue.
2203
-
* The {@link #logAndReply()} should be used for request-reply configuration.
2204
2198
* @param level the {@link LoggingHandler.Level}.
2205
2199
* @return the current {@link BaseIntegrationFlowDefinition}.
2206
2200
* @see #wireTap(WireTapSpec)
@@ -2214,9 +2208,6 @@ public B log(LoggingHandler.Level level) {
2214
2208
* with the {@link LoggingHandler} subscriber for the provided logging category
2215
2209
* and {@code INFO} logging level.
2216
2210
* <p> The full request {@link Message} will be logged.
2217
-
* <p> When this operator is used in the end of flow, it is treated
2218
-
* as one-way handler without any replies to continue.
2219
-
* The {@link #logAndReply()} should be used for request-reply configuration.
2220
2211
* @param category the logging category to use.
2221
2212
* @return the current {@link BaseIntegrationFlowDefinition}.
2222
2213
* @see #wireTap(WireTapSpec)
@@ -2230,9 +2221,6 @@ public B log(String category) {
2230
2221
* with the {@link LoggingHandler} subscriber for the provided
2231
2222
* {@link LoggingHandler.Level} logging level and logging category.
2232
2223
* <p> The full request {@link Message} will be logged.
2233
-
* <p> When this operator is used in the end of flow, it is treated
2234
-
* as one-way handler without any replies to continue.
2235
-
* The {@link #logAndReply()} should be used for request-reply configuration.
2236
2224
* @param level the {@link LoggingHandler.Level}.
2237
2225
* @param category the logging category to use.
2238
2226
* @return the current {@link BaseIntegrationFlowDefinition}.
@@ -2247,9 +2235,6 @@ public B log(LoggingHandler.Level level, String category) {
2247
2235
* with the {@link LoggingHandler} subscriber for the provided
Copy file name to clipboardExpand all lines: spring-integration-core/src/test/java/org/springframework/integration/dsl/extensions/IntegrationFlowExtensionTests.java
+3-2
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2020 the original author or authors.
2
+
* Copyright 2020-2022 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -82,7 +82,8 @@ public IntegrationFlow customFlowDefinition() {
Copy file name to clipboardExpand all lines: spring-integration-core/src/test/java/org/springframework/integration/dsl/flowservices/FlowServiceTests.java
+4-3
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2016-2020 the original author or authors.
2
+
* Copyright 2016-2022 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -127,7 +127,7 @@ public static class ContextConfiguration {
127
127
@Bean
128
128
publicIntegrationFlowtestGateway() {
129
129
returnf -> f.gateway("processChannel", g -> g.replyChannel("replyChannel"))
130
-
.logAndReply();
130
+
.log();
131
131
}
132
132
133
133
@Bean
@@ -152,7 +152,8 @@ public void configure(IntegrationFlowDefinition<?> f) {
Copy file name to clipboardExpand all lines: spring-integration-core/src/test/java/org/springframework/integration/dsl/transformers/TransformerTests.java
+4-3
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2017-2021 the original author or authors.
2
+
* Copyright 2017-2022 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -297,7 +297,8 @@ public IntegrationFlow enricherFlow() {
297
297
.propertyFunction("date", m -> newDate())
298
298
.headerExpression("foo", "payload['name']")
299
299
)
300
-
.logAndReply();
300
+
.log()
301
+
.get();
301
302
}
302
303
303
304
@Bean
@@ -463,7 +464,7 @@ public IntegrationFlow transformFlowWithError() {
Copy file name to clipboardExpand all lines: src/reference/asciidoc/dsl.adoc
+3-3
Original file line number
Diff line number
Diff line change
@@ -656,9 +656,9 @@ The following example shows how to use `LoggingHandler`:
656
656
657
657
In the preceding example, an `id` header is logged at the `ERROR` level onto `test.category` only for messages that passed the filter and before routing.
658
658
659
-
When this operator is used at the end of a flow, it is a one-way handler and the flow ends.
660
-
To make it as a reply-producing flow, you can either use a simple `bridge()` after the `log()` or, starting with version 5.1, you can use a `logAndReply()` operator instead.
661
-
`logAndReply` can only be used at the end of a flow.
659
+
Starting with version 6.0, the behavior of this operator in the end of flowis aligned with its usage in the middle.
660
+
In other words the behavior of the flow remains the same even if the `log()` operator is removed.
661
+
So, if a reply is not expected to be produced in the end of the flow, the `nullChannel()` is recommended to be used after the last `log()`.
0 commit comments