protected override void HandleMessageInternal(IMessage message) { bool sent = false; ICollection <IMessageChannel> results = DetermineTargetChannels(message); if (results != null) { foreach (IMessageChannel channel in results) { if (channel != null) { if (_channelTemplate.Send(message, channel)) { sent = true; } } } } if (!sent) { if (_defaultOutputChannel != null) { sent = _channelTemplate.Send(message, _defaultOutputChannel); } else if (_resolutionRequired) { throw new MessageDeliveryException(message, "no channel resolved by router and no default output channel defined"); } } }
protected bool SendReplyMessage(IMessage replyMessage, IMessageChannel replyChannel) { if (logger.IsDebugEnabled) { logger.Debug("handler '" + this + "' sending reply Message: " + replyMessage); } return(_channelTemplate.Send(replyMessage, replyChannel)); }
protected override bool DoPoll() { IMessage message = _source.Receive(); if (message != null) { return(_channelTemplate.Send(message, _outputChannel)); } return(false); }
public void sendWithReturnAddress() { IList <string> replies = new List <string>(3); CountDownLatch latch = new CountDownLatch(3); IMessageChannel replyChannel = new SendWithReturnAddressChannel(replies, latch); MessageChannelTemplate template = new MessageChannelTemplate(); IMessage message1 = MessageBuilder.WithPayload("test1").SetReplyChannel(replyChannel).Build(); IMessage message2 = MessageBuilder.WithPayload("test2").SetReplyChannel(replyChannel).Build(); IMessage message3 = MessageBuilder.WithPayload("test3").SetReplyChannel(replyChannel).Build(); template.Send(message1, requestChannel); template.Send(message2, requestChannel); template.Send(message3, requestChannel); latch.Await(TimeSpan.FromMilliseconds(2000)); Assert.That(latch.Count, Is.EqualTo(0)); Assert.IsTrue(replies.Contains("TEST1")); Assert.IsTrue(replies.Contains("TEST2")); Assert.IsTrue(replies.Contains("TEST3")); }
public void Send() { MessageChannelTemplate template = new MessageChannelTemplate(); QueueChannel channel = new QueueChannel(); template.Send(new StringMessage("test"), channel); IMessage reply = channel.Receive(); Assert.IsNotNull(reply); Assert.That(reply.Payload, Is.EqualTo("test")); }
public void SendWithDefaultChannelProvidedByConstructor() { QueueChannel channel = new QueueChannel(); MessageChannelTemplate template = new MessageChannelTemplate(channel); template.Send(new StringMessage("test")); IMessage reply = channel.Receive(); Assert.IsNotNull(reply); Assert.That(reply.Payload, Is.EqualTo("test")); }
public void SendWithExplicitChannelTakesPrecedenceOverDefault() { QueueChannel explicitChannel = new QueueChannel(); QueueChannel defaultChannel = new QueueChannel(); MessageChannelTemplate template = new MessageChannelTemplate(defaultChannel); template.Send(new StringMessage("test"), explicitChannel); IMessage reply = explicitChannel.Receive(); Assert.IsNotNull(reply); Assert.That(reply.Payload, Is.EqualTo("test")); Assert.IsNull(defaultChannel.Receive(TimeSpan.Zero)); }
public void sendWithReturnAddress() { IList<string> replies = new List<string>(3); CountDownLatch latch = new CountDownLatch(3); IMessageChannel replyChannel = new SendWithReturnAddressChannel(replies, latch); MessageChannelTemplate template = new MessageChannelTemplate(); IMessage message1 = MessageBuilder.WithPayload("test1").SetReplyChannel(replyChannel).Build(); IMessage message2 = MessageBuilder.WithPayload("test2").SetReplyChannel(replyChannel).Build(); IMessage message3 = MessageBuilder.WithPayload("test3").SetReplyChannel(replyChannel).Build(); template.Send(message1, requestChannel); template.Send(message2, requestChannel); template.Send(message3, requestChannel); latch.Await(TimeSpan.FromMilliseconds(2000)); Assert.That(latch.Count, Is.EqualTo(0)); Assert.IsTrue(replies.Contains("TEST1")); Assert.IsTrue(replies.Contains("TEST2")); Assert.IsTrue(replies.Contains("TEST3")); }
public void SendWithoutChannelArgFailsIfNoDefaultAvailable() { MessageChannelTemplate template = new MessageChannelTemplate(); template.Send(new StringMessage("test")); }
public void SendWithExplicitChannelTakesPrecedenceOverDefault() { QueueChannel explicitChannel = new QueueChannel(); QueueChannel defaultChannel = new QueueChannel(); MessageChannelTemplate template = new MessageChannelTemplate(defaultChannel); template.Send(new StringMessage("test"), explicitChannel); IMessage reply = explicitChannel.Receive(); Assert.IsNotNull(reply); Assert.That(reply.Payload, Is.EqualTo("test")); Assert.IsNull(defaultChannel.Receive(TimeSpan.Zero)); }
public void SendWithDefaultChannelProvidedBySetter() { QueueChannel channel = new QueueChannel(); MessageChannelTemplate template = new MessageChannelTemplate(); template.DefaultChannel = channel; template.Send(new StringMessage("test")); IMessage reply = channel.Receive(); Assert.IsNotNull(reply); Assert.That(reply.Payload, Is.EqualTo("test")); }
public void Send() { MessageChannelTemplate template = new MessageChannelTemplate(); QueueChannel channel = new QueueChannel(); template.Send(new StringMessage("test"), channel); IMessage reply = channel.Receive(); Assert.IsNotNull(reply); Assert.That(reply.Payload, Is.EqualTo("test")); }
protected bool SendMessage(IMessage message) { return(_channelTemplate.Send(message, _outputChannel)); }
public void SendWithoutChannelArgFailsIfNoDefaultAvailable() { MessageChannelTemplate template = new MessageChannelTemplate(); template.Send(new StringMessage("test")); }