public MessagePreprocessResult HandleIncomingMessage(MessageContainer message, IMessageTransport transport)
        {
            log.Info("Preprocessing message: {0}", message.BodyStr);
            var m = typeRe.Match(message.BodyStr);

            if (!m.Success)
            {
                log.Warn("Did not match message type. Ignoring the message!");
                return(MessagePreprocessResult.CancelFurtherProcessing);
            }
            string mtype = m.Groups[1].Captures[0].Value;
            int    idx   = mtype.IndexOf(',');

            if (idx > 0)
            {
                mtype = mtype.Substring(0, idx);
            }
            log.Info("Message type is {0}", mtype);
            if (mtype.StartsWith("NGinnBPM.MessageBus.Messages"))
            {
                log.Info("It's a control message so we process it as usual");
                return(MessagePreprocessResult.ContinueProcessing);
            }
            List <MessageContainer> messages = new List <MessageContainer>();
            //now get destination endpoints from the subscribers database
            //and prepare a message clone for each destination
            List <string> destinations = new List <string>();

            foreach (string typeName in new string[] { mtype, "System.Object" })
            {
                foreach (string destination in SubscriptionManager.GetTargetEndpoints(typeName))
                {
                    if (!destinations.Contains(destination))
                    {
                        destinations.Add(destination);
                    }
                }
            }
            foreach (string destination in destinations)
            {
                var msg = message.Clone() as MessageContainer;
                msg.To = destination; //set destination. We don't update msg.From so the original endpoint is unchanged
                messages.Add(msg);
            }

            if (messages.Count > 0)
            {
                //send messages to their destinations
                transport.SendBatch(messages, MessageBusContext.ReceivingConnection);
                log.Info("Sent message to {0} destinations", messages.Count);
            }
            return(MessagePreprocessResult.CancelFurtherProcessing);
        }