Spring integration documentation explains that a payload expression must be specified when declaring a gateway from an interface method with no arguments, so that the framework knows what payload should be set on the generated message. However, if I do the following:
<int:gateway id="myGateway"
service-interface="com.example.MyGateway"
default-request-channel="requestChannel"
default-reply-channel="replyChannel" />
for the following interface:
package com.example;
public interface MyGateway {
@Gateway(payloadExpression = "''")
String doSomething();
}
this leads to an error: "receive is not supported, because no pollable reply channel has been configured".
This works instead:
public interface MyGateway {
@Payload("''")
String doSomething();
}
Indeed, the same above documentation specifies that the payload should be specified with either @Payload or with payload-expression attribute on method elements.
However, as a user, I find it quite surprising that setting a payload expression through the @Gateway annotation does not work here, especially because the same annotation works in other contexts.
Is this on purpose or an oversight?
It is not clear why the documentation is confusing, but feel free to suggest improvements.
The
@Gatewayannotation is intended for configuration when using annotation-based configurationhttps://docs.spring.io/spring-integration/docs/5.3.2.RELEASE/reference/html/messaging-endpoints.html#gateway-configuration-annotations
The docs clearly state to use
@Payloadorpayload-expressionwhen using XML configuration.