Click here to Skip to main content
15,880,469 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
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.
Posted
Updated 21-Jun-16 1:29am
Comments
Sergey Alexandrovich Kryukov 18-Jun-16 10:01am    
The idea makes no sense at all. Of course, you need to use multithreading, for many reasons and many ways. But handling different message in different threads has no justification. For example, you can dedicate a thread per communication channel, and only if you have fixed predefined number of channels. And a lot more uses. The rest of the question is too vague to discuss.
—SA

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[^]
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900