简体   繁体   English

大众运输:向所有消费者发送消息并等待他们的回复

[英]Masstransit: send message to all consumers and wait for response from them

On one side I got a custom web page, that sends to me some number of messages for my testing purposes. 一方面,我有一个自定义网页,该网页向我发送了一些消息以用于测试。 On another side, I got 4 consumers, that listen to the same queue (round-robin pattern). 另一方面,我有4个消费者,他们监听相同的队列(循环模式)。

Each consumer needs to do a great job, after receiving the message, such as read message, encode the string and create a file, launch another application, send email to a customer. 每个消费者都需要做好工作,在接收到诸如读取的消息之类的消息之后,对字符串进行编码并创建文件,启动另一个应用程序,向客户发送电子邮件。

If I run my solution for one consumer, it works great. 如果我为一个消费者运行我的解决方案,那就很好用。 But if try to do the same for more then one consumer, I got exceptions. 但是,如果尝试为一个以上的消费者做同样的事情,我就会有例外。

All I try to do is if I got many messages in a queue, send a message to each consumer and wait for the response from them. 我要做的就是在队列中收到很多消息,向每个使用者发送一条消息,然后等待它们的响应。 Do it while I got messages in a queue. 在队列中有消息时执行此操作。

I will be happy if someone can help me and show where can I find such kind of information or some example. 如果有人可以帮助我并显示在哪里可以找到此类信息或示例,我将感到非常高兴。

You can achive what you are trying to do using a Saga. 您可以使用Saga实现您要执行的操作。

Here is the MassTransit documentation . 这是MassTransit文档

And here is a Saga sample project . 这是一个Saga示例项目

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM