-
1. Re: How to achieve parallel processing in a single request?
mikefinn Nov 12, 2004 2:53 PM (in response to anders.hedstrom)Haven't done exactly this, but it seems as though you could define two request queues, and two MDBs (one for each respective queue) to do the work. In the SLSB code, create a message for each request, set a temp replyto queue on each and push to their respective queues. Then listen on one temp queue for the answer, then the other once you get an answer on the first. You could do the msg get from the temp queues in some kind of loop, so you're not blocking on one queue too long.
Getting the message would look something like:while ((!gotOne) && (!gotTwo) && (iter < max)) { queueOneGetOptions.setTimeout(1000); queueTwoGetOptions.setTimeout(1000); try { tempQueueOne.get(msgOne); } catch (TimedOutException te) {} try { tempQueueTwo.get(msgTwo); } catch (TimedOutException te) {} iter++; }
Seems like it would work.
Poor man's BPM....
HTH,
Mike -
2. Re: How to achieve parallel processing in a single request?
kalyan120 Nov 12, 2004 5:19 PM (in response to anders.hedstrom)Adding or restating to what Mike said:
If the three queries ( to the db and to the two external applications), can happen concurrently, create 3 MDBs one for the db and one each for the two external applications. Create 3 temporary queues and send the message (or command wrapped in a message) to each of them:dbSender.send(queryMessage1); exApp1.send(queryMessage2); exApp2.send(queryMessage3);
Create 3 Receivers, one each for each queue. And a message listener to all the receivers to receive the results and then process them. (You can have 3 message listeners attached, if you want to).
Send the results, in a blocking call to the 3rd external app. Once the result is obtained, send it back to the client.
In the SLSB code, you will have to block the control once you are done posting queries on the first three queues. This is because you wanted your code to be synchronous from client's prespective.
HTH,
Thanks,
Kalyan.