Version 3

    Why Duplicate Keys when sending messages or could not delete messages when receiving messages?


    There are two common reasons for this.


    Two seperate JBossMQ instances running over of the same database


    You get the duplicate key because the other instance already added it and the could not delete because the other instance deleted it.


    You need to use seperate databases or change the table names JMS_MESSAGES and JMS_TRANSACTIONS so they don't collide.


    You are using a replicating database that isn't doing synchronous replication


    This issue only applies to the receiving side. The problem goes something like:


    1) Sender -> JBossMQ -> sql insert -> database1
    2) Receiver -> JBossMQ -> sql delete -> database2
    3) database1 -> replicate -> database2


    Of course step (3) should be before step (2) but it is not because the replication is asynchronous. There is a statement retries in recent versions that will do a small sleep before retrying the delete. Usually the delay in replication is less than a second.


    Race condition


    There was a bug JBAS-4324 where the checking for a duplicate id had a race condition, meaning two clients could get the same client id. This condition is illegal in jms. Since the client id is used in the generated key, this could cause a problem. But you would have to have a broken application that has two different clients requesting to


    with the same value at exactly the same time.