Пример #1
0
 public async Task StartAsync(EndpointConfiguration.ReadOnly configuration, Func <TransportMessage, Task> onMessage)
 {
     this.configuration = configuration;
     onMessageAsync     = onMessage;
     receiver           = await receiveMessages.StartAsync(this.configuration, OnMessageAsync)
                          .ConfigureAwait(false);
 }
Пример #2
0
 public async Task StartAsync(EndpointConfiguration.ReadOnly configuration, Func<TransportMessage, Task> onMessage)
 {
     this.configuration = configuration;
     onMessageAsync = onMessage;
     receiver = await receiveMessages.StartAsync(this.configuration, OnMessageAsync)
         .ConfigureAwait(false);
 }
Пример #3
0
        public void Setup()
        {
            this.pipelineStepRaisingException = async() =>
            {
                await Task.Run(() => { throw new InvalidOperationException(); });
            };

            this.testTransportMessage = new TestTransportMessage(typeof(Message).AssemblyQualifiedName);
            var readOnlyConfiguration = new EndpointConfiguration.ReadOnly(new EndpointConfiguration().MaximumImmediateRetryCount(MaxImmediateRetryCount).MaximumDelayedRetryCount(MaxDelayedRetryCount));
            var logicalMessage        = new LogicalMessage(typeof(Message), new Message(), null);

            this.incomingLogicalContext = new IncomingLogicalContext(logicalMessage, this.testTransportMessage, readOnlyConfiguration);
            this.busMock = new Mock <IBusForHandler>();

            this.testee = new DelayMessagesWhenImmediateRetryCountIsReachedStep();
        }
Пример #4
0
        public async Task Invoke(IBusForHandler bus, TransportMessage message, EndpointConfiguration.ReadOnly configuration)
        {
            var transportContext = new IncomingTransportContext(message, configuration);

            await InvokeTransport(transportContext, bus)
            .ConfigureAwait(false);

            // We assume that someone in the pipeline made logical message
            var logicalMessage = transportContext.Get <LogicalMessage>();

            var logicalContext = new IncomingLogicalContext(logicalMessage, message, configuration);

            currentContext = logicalContext;
            await InvokeLogical(logicalContext, bus)
            .ConfigureAwait(false);
        }
        public async Task <AsyncClosable> StartAsync(
            EndpointConfiguration.ReadOnly configuration,
            Func <TransportMessage, Task> onMessage)
        {
            MessageReceiver client =
                await this.factory
                .CreateMessageReceiverAsync(configuration.DestinationQueue(), ReceiveMode.PeekLock)
                .ConfigureAwait(false);

            OnMessageOptions options = configuration.Options();

            options.ExceptionReceived += (sender, args) => HandleExceptionReceived(configuration.DestinationQueue(), args);

            configuration.Configure(client).OnMessageAsync(brokeredMessage => onMessage(new TransportMessage(brokeredMessage)), options);

            return(new AsyncClosable(client.CloseAsync));
        }
Пример #6
0
        public async Task Invoke(IBusForHandler bus, TransportMessage message, EndpointConfiguration.ReadOnly configuration)
        {
            this.executingTransportPipeline = new Queue <IIncomingTransportStep>(this.registeredTransportPipeline);
            var transportContext = new IncomingTransportContext(message, configuration);

            transportContext.SetChain(this);
            await this.InvokeTransport(transportContext, bus)
            .ConfigureAwait(false);

            // We assume that someone in the pipeline made logical message
            var logicalMessage = transportContext.Get <LogicalMessage>();

            this.executingLogicalPipeline = new Queue <IIncomingLogicalStep>(this.registeredLogicalPipeline);
            var logicalContext = new IncomingLogicalContext(logicalMessage, message, configuration);

            logicalContext.SetChain(this);
            this.currentContext = logicalContext;
            await this.InvokeLogical(logicalContext, bus)
            .ConfigureAwait(false);
        }
        public void Setup()
        {
            try
            {
                throw new InvalidOperationException("Internal test exception");
            }
            catch (Exception exc)
            {
                this.internalException = exc;
            }

            this.pipelineStepRaisingException = async() =>
            {
                await Task.Run(() =>
                {
                    throw new InvalidOperationException();
                });
            };

            this.pipelineStepRaisingDeadletterMessageImmediatelyException = async() =>
            {
                await Task.Run(() =>
                {
                    throw new DeadletterMessageImmediatelyException(this.internalException);
                });
            };

            this.testTransportMessage = new TestTransportMessage(typeof(Message).AssemblyQualifiedName);
            var readOnlyConfiguration = new EndpointConfiguration.ReadOnly(new EndpointConfiguration().MaximumImmediateRetryCount(10).MaximumDelayedRetryCount(10));
            var logicalMessage        = new LogicalMessage(typeof(Message), new Message(), null);

            this.incomingLogicalContext = new IncomingLogicalContext(logicalMessage, this.testTransportMessage, readOnlyConfiguration);
            this.busMock = new Mock <IBusForHandler>();

            this.testee = new DeadletterMessageImmediatelyExceptionStep();
        }
 public IncomingLogicalContext(LogicalMessage logicalMessage, TransportMessage message, EndpointConfiguration.ReadOnly configuration)
     : base(configuration)
 {
     this.Set(logicalMessage);
     this.Set(message);
     this.Set <MessageHandler>(null, ShouldBeSnapshotted.Yes);
     this.Set(HandlerInvocationAbortPendingKey, false);
 }
Пример #9
0
 protected Context(EndpointConfiguration.ReadOnly configuration)
 {
     this.Set(configuration);
 }
Пример #10
0
            public Task <AsyncClosable> StartAsync(EndpointConfiguration.ReadOnly configuration, Func <TransportMessage, Task> onMessage)
            {
                this.onMessage = onMessage;

                return(Task.FromResult(new AsyncClosable(() => Task.FromResult(0))));
            }
Пример #11
0
 public IncomingTransportContext(TransportMessage message, EndpointConfiguration.ReadOnly configuration)
     : base(configuration)
 {
     this.Set(message);
 }
Пример #12
0
        public virtual async Task Invoke(LogicalMessage outgoingLogicalMessage, DeliveryOptions options, EndpointConfiguration.ReadOnly configuration, TransportMessage incomingTransportMessage = null)
        {
            this.executingLogicalPipeline = new Queue <IOutgoingLogicalStep>(this.registeredlogicalPipelineSteps);
            var logicalContext = new OutgoingLogicalContext(outgoingLogicalMessage, options, configuration);

            logicalContext.SetChain(this);
            await this.InvokeLogical(logicalContext)
            .ConfigureAwait(false);

            // We assume that someone in the pipeline made transport message
            var outgoingTransportMessage = logicalContext.Get <TransportMessage>();

            this.executingTransportPipeline = new Queue <IOutgoingTransportStep>(this.registeredTransportPipelineSteps);
            var transportContext = new OutgoingTransportContext(outgoingLogicalMessage, outgoingTransportMessage, options, configuration, incomingTransportMessage);

            transportContext.SetChain(this);
            await this.InvokeTransport(transportContext)
            .ConfigureAwait(false);
        }
Пример #13
0
 public OutgoingTransportContext(LogicalMessage message, TransportMessage outgoingTransportMessage, DeliveryOptions options, EndpointConfiguration.ReadOnly configuration, TransportMessage incomingTransportMessage = null)
     : base(configuration)
 {
     Set(message);
     Set(OutgoingTransportMessageKey, outgoingTransportMessage);
     Set(IncomingTransportMessageKey, incomingTransportMessage);
     Set(options);
 }
 public OutgoingLogicalContext(LogicalMessage message, DeliveryOptions options, EndpointConfiguration.ReadOnly configuration)
     : base(configuration)
 {
     this.Set(message);
     this.Set(options);
 }
 public static OnMessageOptions Options(this EndpointConfiguration.ReadOnly configuration)
 {
     return(new OnMessageOptions {
         AutoComplete = true, MaxConcurrentCalls = configuration.MaxConcurrency
     });
 }
 public static string DestinationQueue(this EndpointConfiguration.ReadOnly configuration)
 {
     return(configuration.EndpointQueue.Destination);
 }
 public static MessageReceiver Configure(this EndpointConfiguration.ReadOnly configuration, MessageReceiver receiver)
 {
     receiver.PrefetchCount = configuration.PrefetchCount;
     return(receiver);
 }
Пример #18
0
 public Task StartAsync(EndpointConfiguration.ReadOnly configuration, Func <TransportMessage, Task> onMessage)
 {
     return(Task.FromResult(0));
 }
Пример #19
0
 public Task StartAsync(EndpointConfiguration.ReadOnly configuration, Func <TransportMessage, Task> onMessage)
 {
     return(Task.CompletedTask);
 }