Exemple #1
0
 Task SendLocal(object message, TransportMessage incoming)
 {
     return Send(message, new SendOptions
     {
         Queue = readOnlyConfiguration.EndpointQueue
     }, incoming);
 }
Exemple #2
0
        Task Send(object message, SendOptions options, TransportMessage incoming)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message), "You cannot send null");
            }

            var sendOptions = options ?? new SendOptions();
            LogicalMessage msg = factory.Create(message, sendOptions.Headers);

            return SendMessage(msg, sendOptions, incoming);
        }
Exemple #3
0
        Task Publish(object message, PublishOptions options, TransportMessage incoming)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message), "You cannot publish null");
            }

            var publishOptions = options ?? new PublishOptions();
            LogicalMessage msg = factory.Create(message, publishOptions.Headers);
            publishOptions.EventType = msg.MessageType;

            return SendMessage(msg, publishOptions, incoming);
        }
Exemple #4
0
        async Task Outgoing(TransportMessage message)
        {
            var address = message.Headers[AcceptanceTestHeaders.Destination].Parse();

            IList<MessageUnit> destinations;
            if (!units.TryGetValue(address, out destinations))
            {
                destinations = new MessageUnit[]
                {
                };
            }

            foreach (MessageUnit unit in destinations)
            {
                await unit.HandOver(message)
                    .ConfigureAwait(false);
            }
        }
        public TransportMessage(TransportMessage message)
        {
            Headers = new Dictionary<string, string>
            {
                {HeaderKeys.MessageId, message.Id},
                {HeaderKeys.CorrelationId, message.CorrelationId},
                {HeaderKeys.MessageType, message.MessageType},
                {HeaderKeys.ReplyTo, message.ReplyTo?.ToString() }
            };

            var stream = new MemoryStream();
            message.Body.Position = 0;
            message.Body.CopyTo(stream);
            stream.Position = 0;
            this.SetBody(stream);

            foreach (var pair in message.Headers)
            {
                if (!Headers.ContainsKey(pair.Key))
                {
                    Headers.Add(pair.Key, pair.Value);
                }
            }
        }
 public Task DeadLetterAsync(TransportMessage message)
 {
     collector.Add(message);
     return Task.CompletedTask;
 }
 public Task HandOver(TransportMessage message)
 {
     collector.Add(message);
     return onMessage(message);
 }
            public Task PublishAsync(TransportMessage message, PublishOptions options)
            {
                var transportMessage = new TransportMessage(message);

                return onMessage(transportMessage);
            }
            public Task SendAsync(TransportMessage message, SendOptions options)
            {
                var transportMessage = new TransportMessage(message);

                return onMessage(transportMessage);
            }
 public Task HandOver(TransportMessage message)
 {
     return simulator.HandOver(message);
 }
Exemple #11
0
        Task SendMessage(LogicalMessage outgoingLogicalMessage, DeliveryOptions options, TransportMessage incoming)
        {
            if (options.ReplyToAddress == null)
            {
                options.ReplyToAddress = configuration.EndpointQueue;
            }

            OutgoingPipeline outgoingPipeline = outgoingPipelineFactory.Create();
            return outgoingPipeline.Invoke(outgoingLogicalMessage, options, readOnlyConfiguration, incoming);
        }
Exemple #12
0
            static ReplyOptions GetOrCreateReplyOptions(TransportMessage incoming, ReplyOptions options = null)
            {
                Queue destination = incoming.ReplyTo;

                string correlationId = !string.IsNullOrEmpty(incoming.CorrelationId)
                    ? incoming.CorrelationId
                    : incoming.Id;

                if (options == null)
                {
                    return new ReplyOptions(destination, correlationId);
                }

                options.Queue = options.Queue ?? destination;
                options.CorrelationId = options.CorrelationId ?? correlationId;
                return options;
            }
Exemple #13
0
 public IncomingBusDecorator(Bus bus, IncomingPipeline incomingPipeline, TransportMessage incoming)
 {
     this.incoming = incoming;
     this.incomingPipeline = incomingPipeline;
     this.bus = bus;
 }
Exemple #14
0
 Task OnMessageAsync(TransportMessage message)
 {
     IncomingPipeline incomingPipeline = incomingPipelineFactory.Create();
     return incomingPipeline.Invoke(new IncomingBusDecorator(this, incomingPipeline, message), message, readOnlyConfiguration);
 }
Exemple #15
0
 public Task DeadLetterAsync(TransportMessage message)
 {
     collector.Add(message);
     return Task.FromResult(0);
 }