JBoss problem? Or Entity Bean's problem?
dookie23 Jul 26, 2005 12:37 PMHi I have been trying to solve this issue for a while but I still can't. I have tried this on JBoss 4.0.1sp1 and 4.0.2. Both give me the same result.
Ok, here is the scenario: I have the following bean calling sequence (servlet calling session bean, then MDB.. so on):
Servlet --> Session Bean --> MDB (of course, asynchronous)
So theoretically, The Session Bean should run concurrently with the MDB.
The problem that I am having is, before Session Bean's testSession() can finish (it has a while loop running for some time, code shown below), the MDB is stuck at the database fetch. It seems that the MDB cannot fetch the same row from the database. If the MDB fetches a different row from the database, the MDB runs fine even when the Session Bean is stuck in a loop.
My question is, why? Is there some kind of locking mechanism where the Session Bean has to release? Can anybody help?
Here are the code snipplets:
I have 4 classes:
A Servlet:
protected void service(HttpServletRequest req, HttpServletResponse resp) { ... InitialContext context = new InitialContext(); Object ref = context.lookup("ejb/QuestionSession"); QuestionSessionHome home = (QuestionSessionHome) javax.rmi.PortableRemoteObject.narrow( ref, QuestionSessionHome.class); QuestionSession session = home.create(); session.testSession(); // calling Session Bean's testSession method... }
A Stateless Session Bean:
public void testSession() { log.info("At testSession()"); DestinationLookupData data = testNumberOfContection(0, null); // fetching row 0 from database log.info("######## BEFORE READ ########"); log.info("QueueFilter: " + data.getQueue_filter()); log.info("######## AFTER READ ########"); sendToTopic("TRANSACTION_START"); // send asynchronously to MDB int counter = 0; while (true) // Some long long process.... { try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } if (counter > 20) break; counter++; } log.info("#####################################"); log.info("######## FINISHED WHILE LOOP ########"); log.info("#####################################"); }
A Message Driven Bean:
public void onMessage(Message message) { log.info("At onMessage()"); DestinationLookupData data = testNumberOfContection(0, null); // fetching row 0 from database log.info("######## BEFORE READ ########"); log.info("QueueFilter: " + data.getQueue_filter()); log.info("######## AFTER READ ########"); }
An Entity Bean:
With a finder method searching for a specific row in the database. The key is passed in by testNumberOfContection (the first parameter, both the SessionBean and MDB are running invoking that). Therefore, the MDB and SessionBean are looking for the same row in the database.
Thanks!!
Brian