I have been looking into Spring Integration Source code and i guess that the problem might be in RetrievalBlockingMessageStore (used as messagestore by ReplyMessageCorrelator, which is used by SimpleMessagingGateway ). The method remove doesn't seem to be thread safe.
Code:
public Message<?> remove(Object key, long timeout) {
Message<?> message = this.targetMessageStore.remove(key);
return (message != null) ? message : waitForMessage(key, timeout, true);
}
this.targetMessageStore is a SimpleMessageStore and it isn't synchronized.
EDIT: Forget this message, I was wrong. The problem might be in waitForMessage