Example #1
0
        Task Publish <T>(CancellationToken cancellationToken = default)
        {
            var type    = typeof(T);
            var message = new OutgoingMessageBuilder().WithBody(new byte[0]).CorrelationId(type.FullName).PublishType(type).Build();

            return(messageDispatcher.Dispatch(message, new TransportTransaction(), cancellationToken));
        }
Example #2
0
        Task Publish <T>()
        {
            var type    = typeof(T);
            var message = new OutgoingMessageBuilder().WithBody(new byte[0]).CorrelationId(type.FullName).PublishType(type).Build();

            return(messageDispatcher.Dispatch(message, new TransportTransaction(), new ContextBag()));
        }
        public async Task Should_gracefully_shutdown()
        {
            await messagePump.Stop();

            var operations = new OutgoingMessageBuilder().WithBody(new byte[1]).SendTo(ReceiverQueue).Build(10000);
            await messageDispatcher.Dispatch(operations, new TransportTransaction(), new Extensibility.ContextBag());

            messagePump.Start(new PushRuntimeSettings(50));
            await Task.Delay(500);

            await messagePump.Stop();
        }
        public async Task Should_gracefully_shutdown()
        {
            await messagePump.StopReceive();

            var operations = new OutgoingMessageBuilder().WithBody(new byte[1]).SendTo(ReceiverQueue).Build(10000);
            await messageDispatcher.Dispatch(operations, new TransportTransaction());

            await messagePump.StartReceive();

            await Task.Delay(500);

            await messagePump.StopReceive();
        }
Example #5
0
        async Task Verify(OutgoingMessageBuilder builder, Action <IncomingMessage, BasicDeliverEventArgs> assertion)
        {
            var operations = builder.SendTo(queueToReceiveOn).Build();

            await messageDispatcher.Dispatch(operations, new TransportTransaction(), new ContextBag());

            var messageId = operations.MulticastTransportOperations.FirstOrDefault()?.Message.MessageId ?? operations.UnicastTransportOperations.FirstOrDefault()?.Message.MessageId;

            var result = Consume(messageId, queueToReceiveOn);

            var converter          = new MessageConverter();
            var convertedHeaders   = converter.RetrieveHeaders(result);
            var convertedMessageId = converter.RetrieveMessageId(result, convertedHeaders);

            var incomingMessage = new IncomingMessage(convertedMessageId, convertedHeaders, result.Body.ToArray());

            assertion(incomingMessage, result);
        }
        async Task Verify(OutgoingMessageBuilder builder, Action <IncomingMessage, BasicDeliverEventArgs> assertion, string queueToReceiveOn = "testEndPoint")
        {
            var operations = builder.SendTo(queueToReceiveOn).Build();

            MakeSureQueueAndExchangeExists(queueToReceiveOn);

            await messageDispatcher.Dispatch(operations, new TransportTransaction(), new ContextBag());

            var messageId = operations.MulticastTransportOperations.FirstOrDefault()?.Message.MessageId ?? operations.UnicastTransportOperations.FirstOrDefault()?.Message.MessageId;

            var result = Consume(messageId, queueToReceiveOn);

            var converter = new MessageConverter();

            var incomingMessage = new IncomingMessage(
                converter.RetrieveMessageId(result),
                converter.RetrieveHeaders(result),
                result.Body
                );

            assertion(incomingMessage, result);
        }
Example #7
0
 Task Verify(OutgoingMessageBuilder builder, Action <BasicDeliverEventArgs> assertion) => Verify(builder, (t, r) => assertion(r));
Example #8
0
 Task Verify(OutgoingMessageBuilder builder, Action <IncomingMessage> assertion) => Verify(builder, (t, r) => assertion(t));
 Task Verify(OutgoingMessageBuilder builder, Action <BasicDeliverEventArgs> assertion, CancellationToken cancellationToken = default) => Verify(builder, (t, r) => assertion(r), cancellationToken);
 Task Verify(OutgoingMessageBuilder builder, Action <IncomingMessage> assertion, CancellationToken cancellationToken = default) => Verify(builder, (t, r) => assertion(t), cancellationToken);
Example #11
0
 Task Verify(OutgoingMessageBuilder builder, ContextBag contextBag, Action <BasicDeliverEventArgs> assertion) => Verify(builder, (t, r) => assertion(r), contextBag);
 Task Verify(OutgoingMessageBuilder builder, Action <BasicDeliverEventArgs> assertion, string queueToReceiveOn = "testEndPoint") => Verify(builder, (t, r) => assertion(r), queueToReceiveOn);
 Task Verify(OutgoingMessageBuilder builder, Action <IncomingMessage> assertion, string queueToReceiveOn = "testEndPoint") => Verify(builder, (t, r) => assertion(t), queueToReceiveOn);