You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by ajay <aj...@exterro.com> on 2013/07/03 14:21:15 UTC

Activemq - Duplicate Message persistence

Hi all,
I am getting following Exception when trying to save multiple messages using
activemq in jms session commit.

ERROR [STDERR] Caused by: java.sql.BatchUpdateException: Violation of
PRIMARY KEY constraint 'PK__ACTIVEMQ__3214EC2707020F21'. Cannot insert
duplicate key in object 'dbo.ACTIVEMQ_MSGS'.
2013-07-03 17:06:02,261 ERROR [STDERR] 	at
com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeBatch(Unknown
Source)
2013-07-03 17:06:02,261 ERROR [STDERR] 	at
org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:519)
2013-07-03 17:06:02,261 ERROR [STDERR] 	at
org.apache.activemq.store.jdbc.TransactionContext.executeBatch(TransactionContext.java:103)
2013-07-03 17:06:02,261 ERROR [STDERR] 	at
org.apache.activemq.store.jdbc.TransactionContext.executeBatch(TransactionContext.java:81)
2013-07-03 17:06:02,261 ERROR [STDERR] 	at
org.apache.activemq.store.jdbc.TransactionContext.commit(TransactionContext.java:166)
2013-07-03 17:06:02,261 ERROR [STDERR] 	... 18 more

2013-07-03 17:06:02,263 ERROR [STDERR] Caused by:
javax.transaction.xa.XAException: STORE COMMIT FAILED: Transaction rolled
back.
2013-07-03 17:06:02,263 ERROR [STDERR] 	at
org.apache.activemq.transaction.LocalTransaction.commit(LocalTransaction.java:77)
2013-07-03 17:06:02,263 ERROR [STDERR] 	at
org.apache.activemq.broker.TransactionBroker.commitTransaction(TransactionBroker.java:173)
2013-07-03 17:06:02,263 ERROR [STDERR] 	at
org.apache.activemq.broker.MutableBrokerFilter.commitTransaction(MutableBrokerFilter.java:103)
2013-07-03 17:06:02,263 ERROR [STDERR] 	at
org.apache.activemq.broker.TransportConnection.processCommitTransactionOnePhase(TransportConnection.java:420)
2013-07-03 17:06:02,263 ERROR [STDERR] 	at
org.apache.activemq.command.TransactionInfo.visit(TransactionInfo.java:100)
2013-07-03 17:06:02,263 ERROR [STDERR] 	at
org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:306)
2013-07-03 17:06:02,263 ERROR [STDERR] 	at
org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:179)
2013-07-03 17:06:02,263 ERROR [STDERR] 	at
org.apache.activemq.transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:116)
2013-07-03 17:06:02,263 ERROR [STDERR] 	at
org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:69)
2013-07-03 17:06:02,263 ERROR [STDERR] 	at
org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:218)
2013-07-03 17:06:02,263 ERROR [STDERR] 	... 5 more

Please let me know any code changes to be made in activemq persistence to
avoid persistence of duplicate messages.Its urgent!!!!!!!!

activemq table design has primary key with identity still it throws
exception.any configuration changes needs to be made on database table
creation side or any changes in activemq persistence in clusters?
Need ur valuable information.


Thanks,,
Ajay.V






--
View this message in context: http://activemq.2283324.n4.nabble.com/Activemq-Duplicate-Message-persistence-tp4668835.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re:Activemq - Duplicate Message persistence

Posted by SuoNayi <su...@163.com>.
Maybe several standalone brokers are operating on the same database?
How many brokers shard the database and what lock mechanism(row lock or lease lock)  are you using?


At 2013-07-03 20:21:15,ajay <aj...@exterro.com> wrote:
>Hi all,
>I am getting following Exception when trying to save multiple messages using
>activemq in jms session commit.
>
>ERROR [STDERR] Caused by: java.sql.BatchUpdateException: Violation of
>PRIMARY KEY constraint 'PK__ACTIVEMQ__3214EC2707020F21'. Cannot insert
>duplicate key in object 'dbo.ACTIVEMQ_MSGS'.
>2013-07-03 17:06:02,261 ERROR [STDERR] 	at
>com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeBatch(Unknown
>Source)
>2013-07-03 17:06:02,261 ERROR [STDERR] 	at
>org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:519)
>2013-07-03 17:06:02,261 ERROR [STDERR] 	at
>org.apache.activemq.store.jdbc.TransactionContext.executeBatch(TransactionContext.java:103)
>2013-07-03 17:06:02,261 ERROR [STDERR] 	at
>org.apache.activemq.store.jdbc.TransactionContext.executeBatch(TransactionContext.java:81)
>2013-07-03 17:06:02,261 ERROR [STDERR] 	at
>org.apache.activemq.store.jdbc.TransactionContext.commit(TransactionContext.java:166)
>2013-07-03 17:06:02,261 ERROR [STDERR] 	... 18 more
>
>2013-07-03 17:06:02,263 ERROR [STDERR] Caused by:
>javax.transaction.xa.XAException: STORE COMMIT FAILED: Transaction rolled
>back.
>2013-07-03 17:06:02,263 ERROR [STDERR] 	at
>org.apache.activemq.transaction.LocalTransaction.commit(LocalTransaction.java:77)
>2013-07-03 17:06:02,263 ERROR [STDERR] 	at
>org.apache.activemq.broker.TransactionBroker.commitTransaction(TransactionBroker.java:173)
>2013-07-03 17:06:02,263 ERROR [STDERR] 	at
>org.apache.activemq.broker.MutableBrokerFilter.commitTransaction(MutableBrokerFilter.java:103)
>2013-07-03 17:06:02,263 ERROR [STDERR] 	at
>org.apache.activemq.broker.TransportConnection.processCommitTransactionOnePhase(TransportConnection.java:420)
>2013-07-03 17:06:02,263 ERROR [STDERR] 	at
>org.apache.activemq.command.TransactionInfo.visit(TransactionInfo.java:100)
>2013-07-03 17:06:02,263 ERROR [STDERR] 	at
>org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:306)
>2013-07-03 17:06:02,263 ERROR [STDERR] 	at
>org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:179)
>2013-07-03 17:06:02,263 ERROR [STDERR] 	at
>org.apache.activemq.transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:116)
>2013-07-03 17:06:02,263 ERROR [STDERR] 	at
>org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:69)
>2013-07-03 17:06:02,263 ERROR [STDERR] 	at
>org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:218)
>2013-07-03 17:06:02,263 ERROR [STDERR] 	... 5 more
>
>Please let me know any code changes to be made in activemq persistence to
>avoid persistence of duplicate messages.Its urgent!!!!!!!!
>
>activemq table design has primary key with identity still it throws
>exception.any configuration changes needs to be made on database table
>creation side or any changes in activemq persistence in clusters?
>Need ur valuable information.
>
>
>Thanks,,
>Ajay.V
>
>
>
>
>
>
>--
>View this message in context: http://activemq.2283324.n4.nabble.com/Activemq-Duplicate-Message-persistence-tp4668835.html
>Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re:Re: Activemq - Duplicate Message persistence

Posted by SuoNayi <su...@163.com>.
What do you mean cluster?
You said you are using only one broker...




At 2013-07-04 13:17:05,ajay <aj...@exterro.com> wrote:
>Currently we are using only one broker and at database level even if we set
>no row lock or lock options violation of primary key exceptions throws when
>server is loaded in cluster.at a shot when two users commit javax session
>constraint violation occurs.
>
>
>
>--
>View this message in context: http://activemq.2283324.n4.nabble.com/Activemq-Duplicate-Message-persistence-tp4668835p4668865.html
>Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: Activemq - Duplicate Message persistence

Posted by ajay <aj...@exterro.com>.
Currently we are using only one broker and at database level even if we set
no row lock or lock options violation of primary key exceptions throws when
server is loaded in cluster.at a shot when two users commit javax session
constraint violation occurs.



--
View this message in context: http://activemq.2283324.n4.nabble.com/Activemq-Duplicate-Message-persistence-tp4668835p4668865.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re:Re: Activemq - Duplicate Message persistence

Posted by SuoNayi <su...@163.com>.
Only one broker can operate the database at the same time and only one broker 
can be the master which succeeds in grabbing the row lock in the shared database.
Other brokers should be waiting for succeeding in grabbing the row lock to become the master.
In your case I suspect your two brokers are both the master and your clients can connect to them both.


At 2013-07-04 13:25:40,ajay <aj...@exterro.com> wrote:
>I was wrong on that point.Two brokers are used.say n number of brokers.to be
>precise am pointing two servers to same dataabses
>
>
>
>--
>View this message in context: http://activemq.2283324.n4.nabble.com/Activemq-Duplicate-Message-persistence-tp4668835p4668868.html
>Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re:Re: Activemq - Duplicate Message persistence

Posted by SuoNayi <su...@163.com>.
No, it's working as designed. Your two brokers that share the same database can not be the master at the same time.
As default brokers with the same database configuration will use the row lock, do you disabled it specifically ?


At 2013-07-04 13:42:18,ajay <aj...@exterro.com> wrote:
>Yeah you are correct.do u have any idea to fix this issue? any code changes
>on session creation or by any means can we override the message id sequence
>generation in activemq.
>
>Ajay.
>
>
>
>--
>View this message in context: http://activemq.2283324.n4.nabble.com/Activemq-Duplicate-Message-persistence-tp4668835p4668871.html
>Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: Activemq - Duplicate Message persistence

Posted by ajay <aj...@exterro.com>.
Yeah you are correct.do u have any idea to fix this issue? any code changes
on session creation or by any means can we override the message id sequence
generation in activemq.

Ajay.



--
View this message in context: http://activemq.2283324.n4.nabble.com/Activemq-Duplicate-Message-persistence-tp4668835p4668871.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: Activemq - Duplicate Message persistence

Posted by ajay <aj...@exterro.com>.
I was wrong on that point.Two brokers are used.say n number of brokers.to be
precise am pointing two servers to same dataabses



--
View this message in context: http://activemq.2283324.n4.nabble.com/Activemq-Duplicate-Message-persistence-tp4668835p4668868.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.