Ejemplo n.º 1
0
        public TransportMessage Create(object message, Action <TransportMessageConfigurator> configure,
                                       TransportMessage transportMessageReceived)
        {
            Guard.AgainstNull(message, nameof(message));

            var transportMessagePipeline = _pipelineFactory.GetPipeline <TransportMessagePipeline>();

            try
            {
                var transportMessageConfigurator = new TransportMessageConfigurator(message);

                if (transportMessageReceived != null)
                {
                    transportMessageConfigurator.TransportMessageReceived(transportMessageReceived);
                }

                if (configure != null)
                {
                    configure(transportMessageConfigurator);
                }

                if (!transportMessagePipeline.Execute(transportMessageConfigurator))
                {
                    throw new PipelineException(string.Format(EsbResources.PipelineExecutionException,
                                                              "TransportMessagePipeline", transportMessagePipeline.Exception.AllMessages()));
                }

                return(transportMessagePipeline.State.GetTransportMessage());
            }
            finally
            {
                _pipelineFactory.ReleasePipeline(transportMessagePipeline);
            }
        }
Ejemplo n.º 2
0
        public TransportMessage CreateTransportMessage(object message, Action <TransportMessageConfigurator> configure)
        {
            Guard.AgainstNull(message, "message");

            var transportMessagePipeline = _bus.Configuration.PipelineFactory.GetPipeline <TransportMessagePipeline>(_bus);

            var transportMessageConfigurator = new TransportMessageConfigurator(message);

            if (_transportMessageReceived != null)
            {
                transportMessageConfigurator.TransportMessageReceived(_transportMessageReceived);
            }

            if (configure != null)
            {
                configure(transportMessageConfigurator);
            }

            if (!transportMessagePipeline.Execute(transportMessageConfigurator))
            {
                throw new PipelineException(string.Format(EsbResources.PipelineExecutionException, "TransportMessagePipeline",
                                                          transportMessagePipeline.Exception.AllMessages()));
            }

            return(transportMessagePipeline.State.GetTransportMessage());
        }
        public bool Execute(TransportMessageConfigurator configurator)
        {
            Guard.AgainstNull(configurator, "options");

            State.SetTransportMessageContext(configurator);

            return(base.Execute());
        }
Ejemplo n.º 4
0
 public static void SetTransportMessageContext(this IState <IPipeline> state, TransportMessageConfigurator configurator)
 {
     state.Replace(StateKeys.TransportMessageConfigurator, configurator);
 }