int eprCount = 0;
for (Message attachmentMessage : attachmentMessages) {
Header header = attachmentMessage.getHeader();
if(header != null) {
Call call = header.getCall();
if(call != null) {
replyToEPRs.add(call.getReplyTo());
eprCount++;
}
}
}
// Only map the replyTo EPR if all attachments have the same replyTo EPR...
if(replyToEPRs.size() == 1 && eprCount == attachmentMessages.size()) {
Call call = aggregatedMessage.getHeader().getCall();
if(call == null) {
call = new Call();
aggregatedMessage.getHeader().setCall(call);
}
call.setReplyTo(replyToEPRs.iterator().next());
} else if(logger.isDebugEnabled()) {
if(replyToEPRs.size() == 0) {
logger.debug("Not mapping replyTo EPR for aggregate message '" + uuId + "'. No replyTo EPR to be mapped.");
} else if(replyToEPRs.size() > 1) {
logger.debug("Not mapping replyTo EPR for aggregate message '" + uuId + "'. Not all replyTo EPRs are the same: " + replyToEPRs);