3 Replies Latest reply on Feb 6, 2002 9:07 PM by Hiram Chirino

    MDB problem

    John DeStefano Apprentice


      I have a question about message driven beans. We have an application that has a few moving parts so I will explain what's going on. We are using JBoss 2.4.1 with Tomcat 3.2 running on Windows 2000 server.

      There is a java program which listens on a socket for messages from a non-java messaging engine. When a message is received it is put on a queue. The messages contain patient data. At times sequential messages are for the same patient. This happens often. We have a MDB attached to the queue. When the bean executes it call another session bean to deal with the message.

      That session bean checks a database, MSSQL. If the patient is already in the database the record for the patient is updated. If it's a new patient the record is inserted. To do this the bean first does a query to lookup the patient and then depending on the results runs either an insert or an update against the database. The data access is through a pool. The transaction isolation level on the pool is currently TRANSACTION_READ_UNCOMMITTED. I have also set the level to SERIALIZED with the same results.

      The problem occurs when consecutive messages are for the same patient. What occurs is one bean trying to access the same record that another bean is currently holding onto. One of the beans throws an exception due to a database lock. Eventually the message is retried by the MDB and updates.

      Is there a way to configure the MDB, database pool and perhaps even the database to avoid this. As I said I tried to serialize the database pool but that seemed to have no effect on this issue.

      Any help would be appreciated.