protected void SendReply(IMessage message, IMessageChannel defaultReplyChannel)
        {
            IMessageChannel replyChannel = _outputChannel;

            if (replyChannel == null)
            {
                replyChannel = ResolveReplyChannelFromMessage(message);
                if (replyChannel == null)
                {
                    replyChannel = defaultReplyChannel;
                }
            }
            if (replyChannel != null)
            {
                if (defaultReplyChannel != null && !defaultReplyChannel.Equals(replyChannel))
                {
                    message = MessageBuilder.FromMessage(message).SetHeaderIfAbsent(MessageHeaders.REPLY_CHANNEL, defaultReplyChannel).Build();
                }
                _channelTemplate.Send(message, replyChannel);
            }
            else if (logger.IsWarnEnabled)
            {
                logger.Warn("unable to determine reply target for aggregation result: " + message);
            }
        }
        protected override void ProcessBarrier(MessageBarrier <IDictionary <object, IMessage>, object> barrier)
        {
            IList <IMessage> messageList = new List <IMessage>(barrier.Messages.Values);

            if (!barrier.IsComplete && messageList.Count > 0)
            {
                if (_completionStrategy.IsComplete(messageList))
                {
                    barrier.SetComplete();
                }
            }
            if (barrier.IsComplete)
            {
                RemoveBarrier(barrier.CorrelationId);
                IMessage result = AggregateMessages(messageList);
                if (result != null)
                {
                    if (result.Headers.CorrelationId == null)
                    {
                        result = MessageBuilder.FromMessage(result).SetCorrelationId(barrier.CorrelationId).Build();
                    }
                    SendReply(result, ResolveReplyChannelFromMessage(messageList[0]));
                }
            }
        }