When sending an Exchange to an Endpoint you can either use a Route or a ProducerTemplate. This works fine in many scenarios. However you may need to guarantee that an exchange is delivered to the same endpoint that you delivered a previous exchange on. For example in the case of delivering a batch of exchanges to a MINA socket you may need to ensure that they are all delivered through the same socket connection. Furthermore once the batch of exchanges have been delivered the protocol requirements may be such that you are responsible for closing the socket.
Using a Producer
To achieve fine grained control over sending exchanges you will need to program directly to a Producer. Your code will look similar to:
In the case of using Apache MINA the producer.stop() invocation will cause the socket to be closed.