Uploaded image for project: 'ActiveMQ .Net'
  1. ActiveMQ .Net
  2. AMQNET-275

Session throws not in transaction error when no message has been received during transactional session

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 1.3.0
    • 1.4.0
    • ActiveMQ
    • None
    • Any

    Description

      When trying to upgrade the NMS libraries in the MassTransit, i noticed i started receiving exceptions:

      Apache.NMS.NMSException: Invliad State: Not Currently in a Transaction
         at Apache.NMS.ActiveMQ.TransactionContext.Commit()
         at Apache.NMS.ActiveMQ.Session.Commit()
         at MassTransit.Transports.Nms.NmsTransport.Receive(Func`2 receiver, TimeSpan timeout) in D:\Development.OSS\Masstransit\src\Transports\MassTransit.Transports.Nms\NmsTransport.cs:line 112
         at MassTransit.Transports.StreamEndpoint.Receive(Func`2 receiver, TimeSpan timeout) in D:\Development.OSS\Masstransit\src\MassTransit\Transports\StreamEndpoint.cs:line 65
         at MassTransit.Internal.ServiceBusReceiveContext.ReceiveFromEndpoint() in D:\Development.OSS\Masstransit\src\MassTransit\Internal\ServiceBusReceiveContext.cs:line 62
      

      Looking further into this, i noticed that these only occur when trying to consume a message from the queue in transactional acknowledgement mode when NO mesasge is received in the timespan configured.

      A simple test i did show this:

      [Test]
              public void session_can_be_commited_without_receiving_message()
              {
                  
                  
                      using (Session testsession = connection.CreateSession(AcknowledgementMode.Transactional) as Session)
                      {
                          Assert.IsTrue(testsession.Transacted);
                         // Assert.IsTrue(testsession.TransactionContext.InTransaction);
                          using (IMessageConsumer oTestConsumer = testsession.CreateConsumer(new ActiveMQ.Commands.ActiveMQQueue(destinationName)))
                          {
      
                              IMessage oreceived = oTestConsumer.Receive(new TimeSpan(0, 0, 0, 0, 100));
                              Assert.IsNull(oreceived);
                              testsession.Commit();
      
      
      
      
      
                          }
                      }
      
                      Assert.Pass("When getting here. It is ok");
              }
      

      Attachments

        1. SessionInInvalidState.patch
          5 kB
          Michel Van Hoof

        Activity

          People

            tabish Timothy A. Bish
            mvhoof Michel Van Hoof
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: