Yes, channels are cached between template operations and there is no guarantee that the same channel will be used in that scenario.
The upcoming 2.0 release of Spring AMQP has a new mechanism to perform multiple tasks on the same channel [1].
For example:
Collection<?> messages = getMessagesToSend();
Boolean result = this.template.invoke(t -> {
messages.forEach(m -> t.convertAndSend(ROUTE, m));
t.waitForConfirmsOrDie(10_000);
return true;
});
It is guaranteed that the same channel is used in that case.
This will be available in the next milestone in a couple of weeks (it's in the BUILD-SNAPSHOT now).
With earlier releases you would have to use template.execute() with a ChannelCallback and use channel.basicPublish() calls within the scope of the callback.