Spring integration - channel adapter vs. gateway (AMQP)

I'm confused about the difference of Channel Adapters and Gateways in spring integration. As stated in https://stackoverflow.com/a/29992267/467944 by @gary-russell channel adapters are un-diirectional while gateways are bi-directional. If this is the case, why there is a amqp inbound gateway as well as an amqp outbound gateway?

What I'm trying to accomplish in the end is the following:

  1. Http request received within a controller
  2. place message on amqp queue
  3. consumer consumes messages and put result to result queue
  4. result arrives at controller

so I'd guess I need a gateway with an interface which is called from the controller and puts the payload to the amqp queue (configured as its request channel) while it listens for its answer on the its reply-channel. However with that configuration I always end up with a

MessageDeliveryException: Dispatcher has no subscribers for channel 'application.fromRabbit'

where fromRabibbit is my reply-queue.

1 answer

  • answered 2018-05-16 12:52 Gary Russell

    You should always show configuration when asking questions like this.

    Dispatcher has no subscribers...

    This is a configuration error where you have not wired up your integration flow correctly.

    There are two types of gateways in Spring Integration -

    Gateways to interface with external systems

    These provide request/reply semantics with external systems.

    Inbound gateways are for server-side request/reply where the server receives a request, performs some processing and returns a reply.

    Outbound gateways are the client-side equivalent where the client sends a request and waits for a reply. With AMQP, we have an async version where the reply comes back on a different thread.

    Messaging Gateways

    These interface-based gateways provide a gateway (usually request/reply but a method with a void result is one-way) from Java code (rather than some external system).

    This enables legacy java code to use an integration-based flow.

    So you might have...

    controller -> gateway -> transformer(optional) -> amqp-outbound-gateway

    ...this is a common pattern and works well.

    The server side might be

    amqp-inbound-gateway -> service-activator

    Show your code/config and someone can help debug your configuration problem.