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
Substantially, when I set up a gateway method with void return type, I expect that any reply message that is produced by the downstream chain is simply ignored, and that I can rather opt-in for an exception if an unexpected (?) reply message is produced.
Current Behavior
If I understand it well, right now a gateway method with void return type only works (with no exception) if the downstream chain ends with an outbound adapter or if I explicitly set a NullChannelreplyChannel somewhere in the chain (perhaps with an annotation on the gateway method). Otherwise an exception is produced:
org.springframework.messaging.core.DestinationResolutionException: no output-channel or replyChannel header available
In my case I have a gateway interface with many methods and a downstream HTTP outbound gateway that invokes actions on a remote service through REST. The REST API provides some actions with a response, some others with no meaningful response (apart from a status code which is used to correctly wire errors).
On my gateway interface I would expect that a method with a void return type is enough to tell Spring Integration that I don't care about any (unmeaningful) response produced by the HTTP outbound gateway, but this is not the case and an exception is produced. I have to annotate my interface method by specifying a MessageHeaders.REPLY_CHANNEL header with nullChannel name or @nullChannel expression, or rather set this header somewhere else in my downstream chain. But this sounds redundant to me.
By debugging I see that org.springframework.integration.gateway.GatewayProxyFactoryBean.invokeGatewayMethod(MethodInvocation, boolean) does a "sendAndReceive" when the gateway method is expected to return something, otherwise a simple "send". The former call causes an appropriate replyChannel header to be set on the produced message (sorry, I'm not sure on how this is done, probably by org.springframework.integration.gateway.MessagingGatewaySupport.registerReplyMessageCorrelator()?), while the latter doesn't cause any replyChannel header to be set and hence the exception occurs if a reply message arrives from the downstream chain.
The text was updated successfully, but these errors were encountered:
Fixesspring-projects#3280
To properly support a one-way gateway (`void` return type), it is
better to ignore any possible replies from downstream instead of
unexpected `no output-channel or replyChannel header available`
error
* Populate a `nullChannel` into a `replyChannel` header
for `void` gateway methods when `replyChannel` is not set explicitly
* Remove redundant `GatewayProxyFactoryBean.PARSER` in favor of
similar `EXPRESSION_PARSER` in the super class
* Test and document the feature
* GH-3280: NullChannel as reply for void gateways
Fixes#3280
To properly support a one-way gateway (`void` return type), it is
better to ignore any possible replies from downstream instead of
unexpected `no output-channel or replyChannel header available`
error
* Populate a `nullChannel` into a `replyChannel` header
for `void` gateway methods when `replyChannel` is not set explicitly
* Remove redundant `GatewayProxyFactoryBean.PARSER` in favor of
similar `EXPRESSION_PARSER` in the super class
* Test and document the feature
* * Fix language in the `whats-new.adoc`
Co-authored-by: Gary Russell <grussell@vmware.com>
* * Fix language in gateway.adoc
Co-authored-by: Gary Russell <grussell@vmware.com>
Co-authored-by: Gary Russell <grussell@vmware.com>
Expected Behavior
The full discussion is at: https://stackoverflow.com/questions/61756786/spring-integration-gateway-with-void-method-return-type-why-doesnt-it-set-a-nu
Substantially, when I set up a gateway method with void return type, I expect that any reply message that is produced by the downstream chain is simply ignored, and that I can rather opt-in for an exception if an unexpected (?) reply message is produced.
Current Behavior
If I understand it well, right now a gateway method with void return type only works (with no exception) if the downstream chain ends with an outbound adapter or if I explicitly set a
NullChannel
replyChannel
somewhere in the chain (perhaps with an annotation on the gateway method). Otherwise an exception is produced:In my case I have a gateway interface with many methods and a downstream HTTP outbound gateway that invokes actions on a remote service through REST. The REST API provides some actions with a response, some others with no meaningful response (apart from a status code which is used to correctly wire errors).
On my gateway interface I would expect that a method with a void return type is enough to tell Spring Integration that I don't care about any (unmeaningful) response produced by the HTTP outbound gateway, but this is not the case and an exception is produced. I have to annotate my interface method by specifying a
MessageHeaders.REPLY_CHANNEL
header withnullChannel
name or@nullChannel
expression, or rather set this header somewhere else in my downstream chain. But this sounds redundant to me.By debugging I see that
org.springframework.integration.gateway.GatewayProxyFactoryBean.invokeGatewayMethod(MethodInvocation, boolean)
does a "sendAndReceive" when the gateway method is expected to return something, otherwise a simple "send". The former call causes an appropriatereplyChannel
header to be set on the produced message (sorry, I'm not sure on how this is done, probably byorg.springframework.integration.gateway.MessagingGatewaySupport.registerReplyMessageCorrelator()
?), while the latter doesn't cause anyreplyChannel
header to be set and hence the exception occurs if a reply message arrives from the downstream chain.The text was updated successfully, but these errors were encountered: