public async Task RequestAndReplies() { var theOptions = new OptionsWrapper <RabbitMQOptions>(RabbitMQOptions.Default); var thePublisher = new RabbitMQIntegrationRequestPublisher(theOptions); // Request handler registrieren var theServiceCollection = new ServiceCollection(); theServiceCollection.AddIntegrationRequestHandler(typeof(MyRequestHandler)); ServiceProvider theServiceProvider = theServiceCollection.BuildServiceProvider(); var theSubscriber = new RabbitMQIntegrationRequestSubscriber(theOptions, theServiceProvider); ISubscription theSubscription = await theSubscriber.SubscribeAsync <MyRequest, MyReply>(topic : "MyTopic"); // Einen Request senden MyReply theReply = await thePublisher.PublishAsync <MyRequest, MyReply>(new MyRequest { Topic = "MyTopic", Number = 5 }); Assert.That(theReply.DoubledNumber, Is.EqualTo(10)); theSubscription.Cancel(); theSubscriber.Dispose(); thePublisher.Dispose(); }
public override Task <MyReply> SendRequest(MyRequest request, Grpc.Core.ServerCallContext context) { Console.WriteLine($"Server received message '{request.Message}'"); var reply = new MyReply(); reply.Message = $"Received message: {request.Message}"; reply.Foo = new Random().Next(); return(Task.FromResult(reply)); }
public void Handle(MyMessage message) { using (ConsoleColor.Cyan.AsForegroundColor()) { Console.WriteLine("Sending MyReply to: {0}", this.Bus.CurrentMessageContext.ReplyToAddress); var reply = new MyReply() { Content = "How you doing?" }; this.Bus.Reply(reply); Console.WriteLine("Reply sent."); } }