public InMemoryPublishEndpointProvider(ISendEndpointProvider sendEndpointProvider, ISendTransportProvider transportProvider, IPublishPipe publishPipe)
 {
     _sendEndpointProvider = sendEndpointProvider;
     _publishPipe = publishPipe;
     _transportCache = transportProvider as InMemoryTransportCache;
     _publishObservable = new PublishObservable();
 }
 public InMemoryPublishEndpointProvider(ISendEndpointProvider sendEndpointProvider, ISendTransportProvider transportProvider, IPublishPipe publishPipe)
 {
     _sendEndpointProvider = sendEndpointProvider;
     _publishPipe          = publishPipe;
     _transportCache       = transportProvider as InMemoryTransportCache;
     _publishObservable    = new PublishObservable();
 }
 public Handle(InMemoryTransportCache cache)
 {
     _cache = cache;
 }
        public async Task Should_be_able_to_consume_messages_polymorphically_if_the_receiving_bus_support_the_binary_serializer()
        {
            var inMemoryTransportCache = new InMemoryTransportCache(Environment.ProcessorCount);
            var consumed = new TaskCompletionSource<Base>();

            var sourceBus = Bus.Factory.CreateUsingInMemory(x =>
            {
                x.SetTransportProvider(inMemoryTransportCache);
                x.UseBinarySerializer();
            });
            var recvBus = Bus.Factory.CreateUsingInMemory(x =>
            {
                x.SetTransportProvider(inMemoryTransportCache);
                x.SupportBinaryMessageDeserializer();
                x.UseJsonSerializer();
                x.ReceiveEndpoint("input_queue", configurator =>
                {
                    #pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
                    configurator.Handler<Base>(async ctx =>
                    {
                        consumed.TrySetResult(ctx.Message);
                    });
                    #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
                });
            });
            await sourceBus.StartAsync();
            await recvBus.StartAsync();

            // Create a recursive list
            var head = new ListNode { Value = 100 };
            var tail = new ListNode { Next = head, Value = 200 };
            head.Next = tail;

            var messageToSend = new Derived()
            {
                PropBase = 10,
                PropDerived = 20,
                Head = head
            };
            await sourceBus.Publish(messageToSend);

            var completedTask = await Task.WhenAny(consumed.Task, Task.Delay(250));

            Assert.AreEqual(consumed.Task, completedTask,
                "Timeout while waiting to receive the message sent on the source bus.");

            var message = await consumed.Task;
            Assert.NotNull(message);
            Assert.AreEqual(messageToSend.PropBase, message.PropBase);
            Assert.AreEqual(head.Value, message.Head.Value);
            Assert.AreEqual(tail.Value, message.Head.Next.Value);
            Assert.AreEqual(head.Value, message.Head.Next.Next.Value);

            await sourceBus.StopAsync();
            await recvBus.StopAsync();
        }
示例#5
0
 public Handle(InMemoryTransportCache cache)
 {
     _cache = cache;
 }