多线程是基于MQ的消息处理的最佳解决方案吗? [英] Is multi-threading is best solution for MQ based message processing?

查看:136
本文介绍了多线程是基于MQ的消息处理的最佳解决方案吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我必须每天通过MQ处理十万条消息请求。我想尝试多线程来读取MQ消息并响应(写入对MQ的响应)。这是一个连续的(24X7)过程。我可以使用.NET的多线程,它是否有助于更有效地处理?任何人都可以提供一些样本来源来处理这种使用多线程的处理吗?



提前谢谢,

Yoyakey



我尝试了什么:



我打开了两个主题。我通过线程1处理了第一条消息。第二条消息通过线程2.我无法使用线程1获取第三条消息。

Hi,

I have to process one hundred thousand message requests daily through MQ. I want to try multi-threading for reading the MQ message and responding (writing response to MQ). This is a continuous (24X7) process. Can I use multi-threading of .NET and will it help to process more efficiently? Could any one provide some sample source to handle this kind of processing in using multi-threading?

Thanks in advance,
Yoyakey

What I have tried:

I opened two threads. I processed first message through Thread 1. The second message through Thread 2. Am not able to use the Thread 1 for a third message.

推荐答案

正如SA在他的说法中所说的那样评论,这太模糊,无法合理地讨论。



你可以遇到多线程的各种问题 - 正如你所发现的那样 - 没有看到你的代码'然后使用了我无法进一步评论。



老实说,24小时内的100,000条消息量并不是特别高。这取决于这些消息的大小。更好的方法是根据您的要求找到WebSphere的最佳配置

这是我向您提供所提供的开发人员支持资源的地方,例如:

在Windows和UNIX上配置和调优WebSphere MQ以提高性能 [ ^ ]

前15个WebSphere MQ最佳实践 [ ^ ]

WebSphere MQ:IBM Support Portal [ ^ ]
As SA said in his comment, this is too vague to discuss sensibly.

You can run into all sorts of problems with multi-threading - as you have discovered - without seeing the code you've used then I can't really comment further.

To be honest, 100,000 messages over 24hrs is not particularly high volume. It depends how large those messages are. Better approach is to find the optimal configuration of WebSphere for your requirements
This is where I refer you to the developer support resources provided, e.g.:
Configuring and tuning WebSphere MQ for performance on Windows and UNIX[^]
The top 15 WebSphere MQ best practices[^]
WebSphere MQ : IBM Support Portal[^]


是的,你当然可以使用多线程允许一次处理多个消息。



这样做是否有意义是另一回事。每天100,000条消息大约是1秒,而不是特别高的速率。首先要考虑的是您对平均消息的处理是否需要超过一秒钟。如果是这样,您最终可能会遇到处理无法跟上传入消息的情况。这很糟糕,队列会溢出 - 多线程在这里会很好。



但是如果你的处理只花了几毫秒,那么多线程就无法获得。



多线程要考虑的另一件事是,你失去了同步处理。这意味着消息可能无法按照它们到达的相同顺序进行处理,因此如果任何消息依赖于前一个消息,您将进入一个痛苦的世界。
Yes, you can certainly use multithreading to allow for the processing more than one message at once.

Whether it makes sense to do so is another matter. 100,000 messages a day is about 1 a second, not a particularly high rate. The first thing to consider is whether your processing of an average message takes more than a second. If so, you could end up in a situation where your processing can't keep up with the incoming messages. This is bad, queues will overflow - multithreading would be good here.

If however your processing only takes a few milliseconds then there is nothing to be gained from going multithreaded.

One more thing to consider with multiple threads, you lose synchronous processing. That means the messages may not be processed in the same order they arrive, so if any message relies on a previous one you enter a world of pain.


这篇关于多线程是基于MQ的消息处理的最佳解决方案吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆