Reading MQ using threads
Currently we are developing an application to calculate tax & freight using taxware and we are using MQ to pass the message between our AIX and mainframe servers. Though the application is working, we found that the response time is very low. The current existing application is taking around 2 secs to calculate the tax & freight, but our new application is taking more than 6 seconds.
So, we want to use the multi-threading logic. Once we receive the response from mainframe (for tax & freight) via MQ, only one java application is reading that queue and process the message. Now, we would like to use more than one threads in the application to process multiple requests simultaneously.
We changed our code to use thread logic, but we are having a problem. The threads seems to be working "fast", so we observed that sometimes two threads read the same message and I would like to avoid this case. Can some one help me?
The threads should read the MQ sequentially, but once the message is read, the remaining process needs to be processed parallelly. We tried the "synchronized" block around the MQ read code, but it doesn't seem to work.
Can some one help me how to achieve this?
Thanks in advance,
If reading from that MQ is a critical operation it should be done in a synchronized block so that only one thread can read from it.
Originally Posted by pnbalaji