Ejemplo n.º 1
0
            public async Task Should_be_asynchronous()
            {
                var shutdown = new CancellationTokenSource();

                var inputAddress = new Uri("loopback://localhost/input_queue");

                var transport = new InMemoryTransport(inputAddress, Environment.ProcessorCount);

                TaskCompletionSource <int> received = GetTask <int>();

                IPipe <ReceiveContext> receivePipe = Pipe.New <ReceiveContext>(x =>
                {
                    x.UseFilter(new DelegateFilter <ReceiveContext>(context =>
                    {
                        Console.WriteLine("Message: {0}", context.TransportHeaders.Get("MessageId", "N/A"));

                        received.TrySetResult(1);
                    }));
                });

                ReceiveTransportHandle receiveHandle = ((IReceiveTransport)transport).Start(receivePipe);

                var sendEndpoint = new SendEndpoint(transport, new JsonMessageSerializer(), inputAddress,
                                                    inputAddress);

                await sendEndpoint.Send(new A(), TestCancellationToken);

                await received.Task;

                shutdown.Cancel();

                await receiveHandle.Stop();
            }
Ejemplo n.º 2
0
            async Task ReceiveEndpointHandle.Stop(CancellationToken cancellationToken)
            {
                await _context.EndpointObservers.Stopping(new ReceiveEndpointStoppingEvent(_context.InputAddress, _endpoint)).ConfigureAwait(false);

                await _transportHandle.Stop(cancellationToken).ConfigureAwait(false);
            }
Ejemplo n.º 3
0
 Task ReceiveEndpointHandle.Stop(CancellationToken cancellationToken)
 {
     return(_transportHandle.Stop(cancellationToken));
 }