public virtual void PublishMessage(object source, Message message)
{
// Store message in queue (message box). Not yet implemented, but is what publish/subscribe will do
// Process messages
if (source is IEndpoint)
{
foreach (var application in Applications)
{
foreach (var channel in application.Channels)
{
if (channel.Source.AcceptMessage(source, message))
{
channel.Source.ProcessMessage(source, message.Clone());
}
}
}
}
else if (source is Source)
{
// This is coming from source after transformation
foreach (Destination destination in ((Source) source).Channel.Destinations)
{
if (destination.AcceptMessage((Source) source, message))
{
destination.ProcessMessage((Source) source, message.Clone());
}
}
}
else if (source is Destination)
{
foreach (var application in Applications)
{
foreach (var port in application.Ports)
{
ProcessInPipeline(port.Endpoint, message);
}
}
}
else
{
throw new Exception(string.Format("Illegal route. Source: {0}, Message {2}", source, message.Id));
}
}