예제 #1
0
파일: Bus.cs 프로젝트: kjellski/async-dolls
 Task SendLocal(object message, TransportMessage incoming)
 {
     return Send(message, new SendOptions
     {
         Queue = readOnlyConfiguration.EndpointQueue
     }, incoming);
 }
예제 #2
0
파일: Bus.cs 프로젝트: kjellski/async-dolls
        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);
        }
예제 #3
0
파일: Bus.cs 프로젝트: kjellski/async-dolls
        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);
        }
예제 #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);
            }
        }
예제 #5
0
        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);
                }
            }
        }
예제 #6
0
 public Task DeadLetterAsync(TransportMessage message)
 {
     collector.Add(message);
     return Task.CompletedTask;
 }
예제 #7
0
 public Task HandOver(TransportMessage message)
 {
     collector.Add(message);
     return onMessage(message);
 }
예제 #8
0
            public Task PublishAsync(TransportMessage message, PublishOptions options)
            {
                var transportMessage = new TransportMessage(message);

                return onMessage(transportMessage);
            }
예제 #9
0
            public Task SendAsync(TransportMessage message, SendOptions options)
            {
                var transportMessage = new TransportMessage(message);

                return onMessage(transportMessage);
            }
예제 #10
0
 public Task HandOver(TransportMessage message)
 {
     return simulator.HandOver(message);
 }
예제 #11
0
파일: Bus.cs 프로젝트: kjellski/async-dolls
        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);
        }
예제 #12
0
파일: Bus.cs 프로젝트: kjellski/async-dolls
            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;
            }
예제 #13
0
파일: Bus.cs 프로젝트: kjellski/async-dolls
 public IncomingBusDecorator(Bus bus, IncomingPipeline incomingPipeline, TransportMessage incoming)
 {
     this.incoming = incoming;
     this.incomingPipeline = incomingPipeline;
     this.bus = bus;
 }
예제 #14
0
파일: Bus.cs 프로젝트: kjellski/async-dolls
 Task OnMessageAsync(TransportMessage message)
 {
     IncomingPipeline incomingPipeline = incomingPipelineFactory.Create();
     return incomingPipeline.Invoke(new IncomingBusDecorator(this, incomingPipeline, message), message, readOnlyConfiguration);
 }
예제 #15
0
 public Task DeadLetterAsync(TransportMessage message)
 {
     collector.Add(message);
     return Task.FromResult(0);
 }