users@glassfish.java.net

MDB concurrent access of separate queues

From: <forums_at_java.net>
Date: Fri, 26 Aug 2011 10:06:48 -0500 (CDT)

 Hi everybody,

I've stumbled upon a race issue when two MDBs are listening for messages on
two separate queues. I'm using GlassFish Server Open Source Edition v3.1.1
and my IDE is Netbeans v.7.0.1.

I've created a simple EJB application containing a Web Service (testWS) which
receives a message and sends it to the first queue (testQueue). An MDB
(testMDB) listening on testQueue receives the message, concatenates a string
to it and forwards it to another queue (testQueue2). The second MDB
(testMDB2) listening on testQueue2 receives this message and prints it. Each
time the message passes a bean it is logged to the server log.

Both queues are created as separate resources on the server - i.e. with
separate Connection Pools and ConnectionFactories. Also, the MDBs are
configured to listen on their own queues.

Now, when I'm calling the testWS Web Service 4 times, each time sending 3
messages sequentially (1 testmsg, 2 testmsg, 3 testmsg), I get the following
output in server log:

 MDBtest  listening at address at http://AAnischevici:8080/testWS/testWS
INFO: MDBtest was successfully deployed in 344 milliseconds. INFO: WS > 1
testmsg INFO: MDB2 > 1 testmsg INFO: WS > 2 testmsg INFO: MDB2 > 2 testmsg
INFO: WS > 3 testmsg INFO: MDB2 > 3 testmsg INFO: WS > 1 testmsg INFO: MDB2 >
1 testmsg INFO: WS > 2 testmsg INFO: MDB2 > 2 testmsg INFO: WS > 3 testmsg
INFO: MDB1 > 3 testmsg INFO: MDB1 > MDB1+3 testmsg INFO: MDB1 > MDB1+MDB1+3
testmsg INFO: MDB2 > MDB1+MDB1+MDB1+3 testmsg INFO: WS > 1 testmsg INFO: MDB1
> 1 testmsg INFO: MDB2 > MDB1+1 testmsg INFO: WS > 2 testmsg INFO: MDB1 > 2
testmsg INFO: MDB2 > MDB1+2 testmsg INFO: WS > 3 testmsg INFO: MDB1 > 3
testmsg INFO: MDB2 > MDB1+3 testmsg INFO: WS > 1 testmsg INFO: MDB1 > 1
testmsg INFO: MDB1 > MDB1+1 testmsg INFO: MDB1 > MDB1+MDB1+1 testmsg INFO:
MDB2 > MDB1+MDB1+MDB1+1 testmsg INFO: WS > 2 testmsg INFO: MDB2 > 2 testmsg
INFO: WS > 3 testmsg INFO: MDB1 > 3 testmsg INFO: MDB1 > MDB1+3 testmsg INFO:
MDB1 > MDB1+MDB1+3 testmsg INFO: MDB2 > MDB1+MDB1+MDB1+3 testmsg   As can be
seen from this log something weird happens - the MDBs are accessing the wrong
queues and are racing for accessing the queues they're not supposed to be
listening on. Could anyone please shed a light on this? Maybe I'm missing
something and there should be a mechanism for isolating the queues?

You may find the entire Netbeans project attached.

Thank you!

Andy.


--
[Message sent by forum member 'XDex']
View Post: http://forums.java.net/node/837516