2 Replies Latest reply on Jun 21, 2006 8:39 AM by Mark P Ashworth

    Sending messages in transaction causes duplicate key excepti

    Mark P Ashworth Newbie

      Good Day,

      I am trying to send a messages in a transaction from the client but this cause an exception of the server indicating that there would be a duplicate key violation on JMS_MESSAGE_REFERENCE primary key.

      The client application only commits the transaction once 1000 messages have been sent to the server.

      I have tried wrapping the MDB that consumes the event in a transaction in the ejb-jar.xml and I have also tried without a transaction defined but with no luck.

      2006-06-21 13:30:00,593 ERROR [org.jboss.jms.server.endpoint.ServerConnectionEndpoint] Exception occured
      java.sql.BatchUpdateException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'PK_JMS_MESSAGE_REFERENCE' defined on 'JMS_MESSAGE_REFERENCE'.
      at org.apache.derby.impl.jdbc.EmbedStatement.executeBatch(Unknown Source)
      at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:517)
      at org.jboss.messaging.core.plugin.JDBCPersistenceManager.handleBeforeCommit1PC(JDBCPersistenceManager.java:2650)
      at org.jboss.messaging.core.plugin.JDBCPersistenceManager$TransactionCallback.beforeCommit(JDBCPersistenceManager.java:4331)
      at org.jboss.messaging.core.tx.Transaction.commit(Transaction.java:171)
      at org.jboss.jms.server.endpoint.ServerConnectionEndpoint.sendTransaction(ServerConnectionEndpoint.java:390)
      at org.jboss.jms.server.endpoint.advised.ConnectionAdvised.org$jboss$jms$server$endpoint$advised$ConnectionAdvised$sendTransaction$aop(ConnectionAdvised.java:99)
      at sun.reflect.GeneratedMethodAccessor90.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
      at org.jboss.jms.server.container.ServerLogInterceptor.invoke(ServerLogInterceptor.java:105)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.aop.Advisor.dynamicInvoke(Advisor.java:723)
      at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:101)
      at org.jboss.jms.server.remoting.JMSServerInvocationHandler.invoke(JMSServerInvocationHandler.java:126)
      at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:842)
      at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:691)
      at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:443)
      at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:516)
      at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:253)

      Regards,
      Mark P Ashworth

        • 1. Re: Sending messages in transaction causes duplicate key exc
          Tim Fox Master

          I'm assuming this is using Derby?

          If so, there are no guarantees Derby will work with JBoss Messaging since we haven't put it through our testing (yet).

          As I say, if you'd like to contribute your Derby config that would be cool, and we can add a task to add Derby as supported config.

          • 2. Re: Sending messages in transaction causes duplicate key exc
            Mark P Ashworth Newbie

            Good Day,

            2006-06-21 14:25:29,312 ERROR [org.jboss.jms.server.endpoint.ServerConnectionEndpoint] Exception occured
            java.sql.SQLException: Unique constraint violation: in statement [INSERT INTO JMS_MESSAGE_REFERENCE (CHANNELID, MESSAGEID, TRANSACTIONID, STATE, ORD, DELIVERYCOUNT, RELIABLE, LOADED) VALUES (?, ?, ?, ?, ?, ?, ?, ?)]
            at org.hsqldb.jdbc.Util.throwError(Unknown Source)
            at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source)
            at org.jboss.resource.adapter.jdbc.CachedPreparedStatement.executeUpdate(CachedPreparedStatement.java:95)
            at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:251)
            at org.jboss.messaging.core.plugin.JDBCPersistenceManager.handleBeforeCommit1PC(JDBCPersistenceManager.java:2570)
            at org.jboss.messaging.core.plugin.JDBCPersistenceManager$TransactionCallback.beforeCommit(JDBCPersistenceManager.java:4331)
            at org.jboss.messaging.core.tx.Transaction.commit(Transaction.java:171)
            at org.jboss.jms.server.endpoint.ServerConnectionEndpoint.sendTransaction(ServerConnectionEndpoint.java:390)
            at org.jboss.jms.server.endpoint.advised.ConnectionAdvised.org$jboss$jms$server$endpoint$advised$ConnectionAdvised$sendTransaction$aop(ConnectionAdvised.java:99)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:585)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
            at org.jboss.jms.server.container.ServerLogInterceptor.invoke(ServerLogInterceptor.java:105)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            at org.jboss.aop.Advisor.dynamicInvoke(Advisor.java:723)
            at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:101)
            at org.jboss.jms.server.remoting.JMSServerInvocationHandler.invoke(JMSServerInvocationHandler.java:126)
            at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:842)
            at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:691)
            at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:443)
            at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:530)
            at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:253)