spring-integrationeai

What is the difference between a content enricher vs Service Activator with a reply channel?


http://www.enterpriseintegrationpatterns.com/patterns/messaging/DataEnricher.html

http://www.enterpriseintegrationpatterns.com/patterns/messaging/MessagingAdapter.html

If there is a reponse channel, service activator seems completely identical to enricher.


Solution

  • See the Spring Integration documentation.

    With a Service Activator the input message is replaced by the output message.

    With the enricher; the input message is parked; we send a message (which could be different to the input message) to some downstream flow which returns a result.

    We then "enrich" the input message (by adding information from the reply) to produce the output message.

    For example; let's say you have an Order object with a customer ID and you want to enhance it by adding the customer name; you can use an enricher to send a lookup request for the customer; then set the customer name property on the order.

    You can, of course, do the same thing within your service but with the enricher you don't have to write any code - it's your choice.