ActiveMQ
  1. ActiveMQ
  2. AMQ-1719

Resource adapter stops consuming messages after broker is forcefully stopped/restarted during XA transaction.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.1.0
    • Fix Version/s: 5.8.0
    • Component/s: Broker, Connector
    • Labels:
      None
    • Environment:

      Windows XP, IBM WebSphere 6.1.0.15, Oracle 10.2.0.3, Java 1.5.0 ( IBM J9 VM), ActiveMQ 5.1.0 downloaded 2008-May-12.

      Description

      Have attached logs from websphere, activeMQ and also the content of the datadirectory for details of data state ( plus the smal program used to create the scenario).

      #1. Installed the resource adapter that came with ActiveMQ into the websperhe applicationserver and configured it to connect to external broker using failover.
      #2. Setup a JDBC XA datasource ( Oracle ) and JMS XA destination ( ActiveMQ ).
      #3. Created a small Message Driven bean that receives a JMS message that it tries to store in the database after which it sleeps for 5 secs. And deployed it to the WebSphere appserver.
      #4. Started the activemq broker without doing any modifications since the download and extract into the filesystem.
      #5. Started applicationserver.
      #6. Started publishing messages to the broker
      #7. As expected the Message driven bean received the messages one-by-one and processed them.
      #8. Used to ctrl-C on the broker to halt it in the middle of the processing. Resulting in a failed commit of XA transaction.
      #9. Waited a while and then started broker again.
      #10. Received Exception on client side and nothing more happened.

      Exception in thread "ActiveMQ Transport: tcp://localhost/127.0.0.1:61616" java.lang.NullPointerException
      at org.apache.activemq.state.ConnectionStateTracker$RemoveTransactionAction.run(ConnectionStateTracker.java:84)
      at org.apache.activemq.state.Tracked.onResponses(Tracked.java:31)
      at org.apache.activemq.transport.failover.FailoverTransport$3.onCommand(FailoverTransport.java:148)
      at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:143)
      at org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:206)
      at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:84)
      at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:196)
      at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:183)
      at java.lang.Thread.run(Thread.java:801)

        Activity

        Hide
        Johan Ekesparr added a comment -

        Ooops! Should be WebSphere 6.1.0.11

        Show
        Johan Ekesparr added a comment - Ooops! Should be WebSphere 6.1.0.11
        Hide
        Jerry Shea added a comment -

        We are getting a similar exception thrown occasionally during our stress tests. Exception happens on start up of some of our consumers. I am working on some reproduction code now but stack trace looks like this:

         
        Exception in thread "ActiveMQ Transport: tcp://localhost/127.0.0.1:62616" java.lang.NullPointerException
                at org.apache.activemq.state.ConnectionStateTracker$RemoveTransactionAction.run(ConnectionStateTracker.java:84)
                at org.apache.activemq.state.Tracked.onResponses(Tracked.java:31)
                at org.apache.activemq.transport.failover.FailoverTransport$3.onCommand(FailoverTransport.java:148)
                at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:143)
                at org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:206)
                at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:84)
                at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:196)
                at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:183)
                at java.lang.Thread.run(Unknown Source)
        

        We are using AMQ5.1, Jencks 2.1 on Windows XP SP2, Sun JDK1.6.03

        Show
        Jerry Shea added a comment - We are getting a similar exception thrown occasionally during our stress tests. Exception happens on start up of some of our consumers. I am working on some reproduction code now but stack trace looks like this: Exception in thread "ActiveMQ Transport: tcp://localhost/127.0.0.1:62616" java.lang.NullPointerException at org.apache.activemq.state.ConnectionStateTracker$RemoveTransactionAction.run(ConnectionStateTracker.java:84) at org.apache.activemq.state.Tracked.onResponses(Tracked.java:31) at org.apache.activemq.transport.failover.FailoverTransport$3.onCommand(FailoverTransport.java:148) at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:143) at org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:206) at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:84) at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:196) at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:183) at java.lang.Thread.run(Unknown Source) We are using AMQ5.1, Jencks 2.1 on Windows XP SP2, Sun JDK1.6.03
        Hide
        Hans Bausewein added a comment - - edited

        The NullPointerException occurs at the last line of the 'run()' method of RemoveTransactionAction:


        ConnectionStateTracker.java
        
            private class RemoveTransactionAction implements Runnable {
                private final TransactionInfo info;   
        
                public RemoveTransactionAction(TransactionInfo info) {
                    this.info = info;
                }
        
                public void run() {
                    ConnectionId connectionId = info.getConnectionId();
                    ConnectionState cs = connectionStates.get(connectionId);
                    cs.removeTransactionState(info.getTransactionId());
                }
            }
        

        Apparently there is no ConnectionState for "connectionId" (anymore).

        "removeTransactionState" removes the TransactionState identified by "transactionId" from a local Map, but since ConnectionState does not exist anymore, this is bogus.

        The NullPointerException itself is not a problem, but can be avoided by putting an

        "if (cs != null)

        {...}

        "

        around the last statement.

        The problem probably existed already.

        Show
        Hans Bausewein added a comment - - edited The NullPointerException occurs at the last line of the 'run()' method of RemoveTransactionAction: ConnectionStateTracker.java private class RemoveTransactionAction implements Runnable { private final TransactionInfo info; public RemoveTransactionAction(TransactionInfo info) { this .info = info; } public void run() { ConnectionId connectionId = info.getConnectionId(); ConnectionState cs = connectionStates.get(connectionId); cs.removeTransactionState(info.getTransactionId()); } } Apparently there is no ConnectionState for "connectionId" (anymore). "removeTransactionState" removes the TransactionState identified by "transactionId" from a local Map, but since ConnectionState does not exist anymore, this is bogus. The NullPointerException itself is not a problem, but can be avoided by putting an "if (cs != null) {...} " around the last statement. The problem probably existed already.
        Hide
        Claus Ibsen added a comment -

        I looked in the latest code, and added a fix for the potential NPE.

        Show
        Claus Ibsen added a comment - I looked in the latest code, and added a fix for the potential NPE.

          People

          • Assignee:
            Claus Ibsen
            Reporter:
            Johan Ekesparr
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development