spring-integrationenterprise-integration

Spring Integration: channel interceptor vs endpoint?


When dealing with an enterprise integration flow in Spring-integration, is it more "proper" to handle concerns such as transmission validation and state tracking in Channel Interceptors, or endpoints like Service Activators and Filters? Or is that purely a matter of style?


Solution

  • Generally it's just style but most people prefer to limit interceptors for simple stuff like wiretapping, logging, etc, or something you want to apply globally to multiple channels via a global interceptor that matches on channel name patterns.

    But, it's not unusual to do validation in an interceptor.

    Not sure what you mean by "state tracking" but, generally, that's handled in message headers (when you want to pass state from one endpoint to another).