Search code examples
spring-integrationspring-el

Setting input/ouput channel of @Gateway and @ServiceActivator dynamically using Spring EL or property placeholders


The annotation @MessagingGateway allows defaultRequestChannel to be set using the property placeholder ${}:

@MessagingGateway(defaultRequestChannel = "${gateway.request.channel}")
public interface MessageGateway {

    @Gateway(requestTimeout = 2000)
    void sendListing(List<Path> entries);
}

But I cannot to similar on the @Gateway annotation:

@MessagingGateway
public interface MessageGateway {

    @Gateway(requestTimeout = 2000, requestChannel = "${gateway.request.channel}") // invalid
    void sendListing(List<Path> entries);
}

Similarly I cannot dynamically set inputChannel/outputChannel of ServiceActivator using the properties placeholder or SpEl.

Do I need to resort to configuring a ServiceActivator manually using ServiceActivatingHandler?


Solution

  • The property placeholder was never worked on those annotations. Original such a feature was only a part of XML configuration. Although that is indeed possible very easy with Java & DSL configuration, the annotation evolution has left behind. The @MessagingGateway was introduced a bit late and such a resolveEmbeddedValue was requested of its attributes.

    I wonder what really difference for the application logic that would make if those channel names would be dynamically resolved from properties.