activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bobby_carp <amqfo...@thecarps.net>
Subject JMS message listener fails intermittently when removing the message with SQL exception "No operations allowed after statement closed"
Date Mon, 05 May 2014 21:24:25 GMT
I am running ActiveMQ 5.9, Apache 7, and MySQL 5.5.  I am finding that my JMS
message handler is intermittently failing when it is trying to remove the
message after my processing is done.  It seems to be a problem with the
MySQL connection, but I know the MySQL is up and right before the failure I
have successfully persisted an entity using Hibernate.  

I have configured ActiveMQ client using the PooledConnectionFactory as shown
in my Spring config:

    
    <bean id="amqConnectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactory"
destroy-method="stop">
        <property name="connectionFactory">
          <bean class="org.apache.activemq.ActiveMQConnectionFactory">
            <property name="brokerURL">
              <value>${jms.url}</value>
            </property>
            <property name="userName">
              <value>${jms.username}</value>
            </property>
            <property name="password">
              <value>${jms.password}</value>
            </property>
          </bean>
        </property>
    </bean>
  
    
    <bean id="connectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory">
        <constructor-arg ref="amqConnectionFactory" />
        <property name="exceptionListener" ref="jmsExceptionListener" />
        <property name="sessionCacheSize" value="100" />
    </bean>

    
    <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
        <constructor-arg ref="connectionFactory"/>
        <property name="defaultDestination" ref="incomingQueue"/>

        
        <property name="deliveryMode" value="1"/>
        
        <property name="sessionTransacted" value="true"/>
    </bean>

    
    <bean id="incomingQueue"
class="org.apache.activemq.command.ActiveMQQueue">
        <constructor-arg value="incoming.queue"/>
    </bean>

    
    <jms:listener-container concurrency="10"
connection-factory="connectionFactory" acknowledge="transacted">
        <jms:listener ref="queueListener" destination="incoming.queue" />
    </jms:listener-container>

The error that occurs is shown the stack trace below:

2014-05-03 18:03:30,379 WARN
[org.springframework.jms.listener.DefaultMessageListenerContainer#0-6]
DefaultMessageListenerContainer.invokeErrorHandler(696) | Execution of JMS
message listener failed, and no ErrorHandler has been set.
javax.jms.JMSException: STORE COMMIT FAILED: Transaction rolled back
        at
org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:54)
        at
org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1405)
        at
org.apache.activemq.TransactionContext.syncSendPacketWithInterruptionHandling(TransactionContext.java:757)
        at
org.apache.activemq.TransactionContext.commit(TransactionContext.java:322)
        at
org.apache.activemq.ActiveMQSession.commit(ActiveMQSession.java:562)
        at
org.apache.activemq.jms.pool.PooledSession.commit(PooledSession.java:162)
        at sun.reflect.GeneratedMethodAccessor38.invoke(Unknown Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at
org.springframework.jms.connection.CachingConnectionFactory$CachedSessionInvocationHandler.invoke(CachingConnectionFactory.java:348)
        at com.sun.proxy.$Proxy89.commit(Unknown Source)
        at
org.springframework.jms.support.JmsUtils.commitIfNecessary(JmsUtils.java:217)
        at
org.springframework.jms.listener.AbstractMessageListenerContainer.commitIfNecessary(AbstractMessageListenerContainer.java:577)
        at
org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:482)
        at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325)
        at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263)
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1103)
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1095)
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:992)
        at java.lang.Thread.run(Thread.java:744)
Caused by: javax.transaction.xa.XAException: STORE COMMIT FAILED:
Transaction rolled back
        at
org.apache.activemq.transaction.LocalTransaction.commit(LocalTransaction.java:75)
        at
org.apache.activemq.broker.TransactionBroker.commitTransaction(TransactionBroker.java:253)
        at
org.apache.activemq.broker.MutableBrokerFilter.commitTransaction(MutableBrokerFilter.java:112)
        at
org.apache.activemq.broker.TransportConnection.processCommitTransactionOnePhase(TransportConnection.java:424)
        at
org.apache.activemq.command.TransactionInfo.visit(TransactionInfo.java:100)
        at
org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:292)
        at
org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:149)
        at
org.apache.activemq.transport.MutexTransport.onCommand(MutexTransport.java:50)
        at
org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:113)
        at
org.apache.activemq.transport.AbstractInactivityMonitor.onCommand(AbstractInactivityMonitor.java:270)
        at
org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
        at
org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:214)
        at
org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:196)
        ... 1 more
Caused by: java.io.IOException: Failed to get store sequenceId for
messageId: ID:ip-172-31-12-248-58664-1398142500942-1:1:5:1:5, on:
queue://incoming.queue. Reason:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No
operations allowed after statement closed.
        at
org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:33)
        at
org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.getStoreSequenceIdForMessageId(JDBCPersistenceAdapter.java:843)
        at
org.apache.activemq.store.jdbc.JDBCMessageStore.removeMessage(JDBCMessageStore.java:194)
        at
org.apache.activemq.store.memory.MemoryTransactionStore$4.run(MemoryTransactionStore.java:348)
        at
org.apache.activemq.store.memory.MemoryTransactionStore$Tx.commit(MemoryTransactionStore.java:103)
        at
org.apache.activemq.store.memory.MemoryTransactionStore.commit(MemoryTransactionStore.java:259)
        at
org.apache.activemq.transaction.LocalTransaction.commit(LocalTransaction.java:70)
        ... 13 more
Caused by:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No
operations allowed after statement closed.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
        at com.mysql.jdbc.Util.getInstance(Util.java:386)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1013)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
        at com.mysql.jdbc.StatementImpl.checkClosed(StatementImpl.java:458)
        at
com.mysql.jdbc.PreparedStatement.setString(PreparedStatement.java:4410)
        at
org.apache.commons.dbcp.DelegatingPreparedStatement.setString(DelegatingPreparedStatement.java:135)
        at
org.apache.commons.dbcp.DelegatingPreparedStatement.setString(DelegatingPreparedStatement.java:135)
        at
org.apache.commons.dbcp.DelegatingPreparedStatement.setString(DelegatingPreparedStatement.java:135)
        at
org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter.getStoreSequenceId(DefaultJDBCAdapter.java:291)
        at
org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.getStoreSequenceIdForMessageId(JDBCPersistenceAdapter.java:840)
        ... 18 more

Any help is appreciated.  This seems like a straightforward use case so I'm
not sure what I am doing wrong or have configured wrong.

Thanks,
Bobby



--
View this message in context: http://activemq.2283324.n4.nabble.com/JMS-message-listener-fails-intermittently-when-removing-the-message-with-SQL-exception-No-operations-tp4680906.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message