@Gateway(payloadExpression="..") vs @Payload("...")

Viewed 115

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?

1 Answers
Related