user1052610
user1052610

Reputation: 4719

Spring Integration: Stategies for avoiding lost messages

If a Spring Integration channel is defined with a task executor, a thread pool will be used to handle messages as they come in. If a service activator or transformer endpoint component receives messages from this internal channel, will a pool of endpoint components be instantiated, one for each thread? If this is not the default behaviour, what configuration is required in order to achieve this?

This is important for two reasons:

  1. So that the service activator/transformer which receives the messages will not be a bottleneck.

  2. To ensure that the endpoint component handles messages in the same thread that the internal channel uses, so they are part of the same transaction. If this is the case and the channel is persisted using JMS, messages will not be lost. Otherwise, if the endpoint run in a separate transaction, the fact that the messages are persited on the channel will not help if there is a JVM failure once a message has been passed to the endpoint component.

Thanks

Upvotes: 1

Views: 770

Answers (1)

Gary Russell
Gary Russell

Reputation: 174484

No; there is one instance of each endpoint, regardless of the threading on in the input channel.

  1. You avoid "bottlenecks" by careful design of the service by, typically, making it stateless.
  2. It is not clear what you mean; if the channel is backed by JMS, each thread on the output side can get its own transaction and mesages will be rolled back onto the queue in the event of a service failure. This is completely different to a simple executor channel (for which transactions can never work, and having a separate instance won't help either).

Perhaps if you can describe a specific use case / configuration, someone can provide some suggestions.

Upvotes: 1

Related Questions