I did try the publish-subscribe option (thinking that it should work as you describe.) Apologies for not having mentioned this...
here's my integration (roughly):
Note the channel named 'inboundItemsPosted'. It's what passes the inbound messages from the JMS message driven channel adapter and passes it on to the ntegration-message-destination. I debugged this and got that inside of BroadcastingDispatcher, iin the dispatch(Message<?> message) method we have the following logic:
Code:
public boolean dispatch(Message<?> message) {
boolean dispatched = false;
int sequenceNumber = 1;
List<MessageHandler> handlers = this.getHandlers();
int sequenceSize = handlers.size();
for (final MessageHandler handler : handlers) {
final Message<?> messageToSend = (!this.applySequence) ? message
: MessageBuilder.fromMessage(message)
.setSequenceNumber(sequenceNumber++)
.setSequenceSize(sequenceSize)
.setCorrelationId(message.getHeaders().getId())
.setHeader(MessageHeaders.ID, UUID.randomUUID())
.build();
if (this.taskExecutor != null) {
this.taskExecutor.execute(new Runnable() {
public void run() {
invokeHandler(handler, messageToSend);
}
});
dispatched = true;
}
else {
boolean success = this.invokeHandler(handler, messageToSend);
dispatched = (success || dispatched);
}
}
return dispatched;
}
As there are no handleers in the handlers collection we never get a chance to set dispatched = true, which in turn is returned from the method as the success status variable. this value (the boolean) is then returned from protected boolean doSend(Message<?> msg, long timeout) in AbstractSubscribableChannel, which in turn is invoked by public final boolean send (Message<?> msg, long timeout) in AbstractMessageChannel, which in turn returns the boolean as whether or not the message was sent from the other variant of the send(Message<?> msg) method. Anyway, this bubbles up all the way back to the MessageChannelTemplate's doSend method.
So, I understand why this works that way, normally. Most integrations are dealing with static components that don't subscribe/disconnect as frequently as users on a web app... so I'm not recommending we change that fundamental behavior. Instead, I like the idea of that opt-in configuration option at the higher level that you suggested. I am fundamentally unsure of which option would be better, too. Functionality exposed as a message header is definitely the most flexible since it means it could be dynamic / arbitrary and still be an opt-in behavior.
Anyway, all input's greatly appreciated.
Thanks,