Ejemplo n.º 1
0
        private IOutboundMessage WrapOutboundMessage(object message, IOutboundRoute route)
        {
            var wrapper = (IOutboundMessageInternal)Activator.CreateInstance(typeof(OutboundMessage <>).MakeGenericType(message.GetType()));

            wrapper.Endpoint = route.DestinationEndpoint;
            wrapper.Message  = message;
            wrapper.Route    = route;

            return(wrapper);
        }
        private IOutboundMessage CreateOutboundMessage(object message, IOutboundRoute route)
        {
            var wrapper = (IOutboundMessage)Activator.CreateInstance(
                typeof(OutboundMessage <>).MakeGenericType(message.GetType()),
                message, null, route);

            _messageKeyProvider.EnsureKeyIsInitialized(wrapper.Content, wrapper.Headers);

            return(wrapper);
        }
Ejemplo n.º 3
0
        private IEnumerable <IOutboundEnvelope> CreateOutboundEnvelope(object message, IOutboundRoute route)
        {
            var headers   = new MessageHeaderCollection();
            var router    = _routers.GetOrAdd(route, _ => route.GetOutboundRouter(_serviceProvider));
            var endpoints = router.GetDestinationEndpoints(message, headers);

            foreach (var endpoint in endpoints)
            {
                yield return((IOutboundEnvelope)Activator.CreateInstance(
                                 typeof(OutboundEnvelope <>).MakeGenericType(message.GetType()),
                                 message,
                                 headers,
                                 endpoint,
                                 _routing.PublishOutboundMessagesToInternalBus));
            }
        }
Ejemplo n.º 4
0
 internal OutboundMessage(object content, IEnumerable <MessageHeader> headers, IOutboundRoute route)
     : this(content, headers, route?.DestinationEndpoint)
 {
     Route = route;
 }