Uploaded image for project: 'AMQ Broker'
  1. AMQ Broker
  2. ENTMQBR-2358

MESSAGES_ACKNOWLEDGED is incremented even if message consumption is rolled back

    XMLWordPrintable

Details

    • +
    • ARTEMIS-2305
    • Verified in a release
    • Hide

      Some way is required to run an XA transaction against the broker. I have been testing using a Message-Driven Bean (MDB) on EAP 7.1. The MDB should be defined to use container-managed transactions, and EAP will create an XA transaction against the broker before calling the MDB's onMessage() method. If the onMessage() method throws a RuntimeException, EAP will roll back the transaction.

      So I am testing using an MDB that simply throws a RuntimeException. When it consumes a message, it will be redelivered repeatedly, until the broker reaches its maximum retry count, in which case it will be transferred to a DLQ. So each time a message is added, MESSAGES_ADDED is incremented once, and MESSAGES_ACKNOWLEDGED is incremented many times, even though EAP has never really acknowledged anything.

      I am testing with EAP configured to communicate with AMQ 7 via a resource adapter. I don't know if the built-in Artemis broker in EAP would show the same behaviour.

      Show
      Some way is required to run an XA transaction against the broker. I have been testing using a Message-Driven Bean (MDB) on EAP 7.1. The MDB should be defined to use container-managed transactions, and EAP will create an XA transaction against the broker before calling the MDB's onMessage() method. If the onMessage() method throws a RuntimeException, EAP will roll back the transaction. So I am testing using an MDB that simply throws a RuntimeException. When it consumes a message, it will be redelivered repeatedly, until the broker reaches its maximum retry count, in which case it will be transferred to a DLQ. So each time a message is added, MESSAGES_ADDED is incremented once, and MESSAGES_ACKNOWLEDGED is incremented many times, even though EAP has never really acknowledged anything. I am testing with EAP configured to communicate with AMQ 7 via a resource adapter. I don't know if the built-in Artemis broker in EAP would show the same behaviour.

    Description

      If a message is added to a destination, the metric MESSAGES_ADDED is incremented, along with MESSAGE_COUNT. When a message is successfully removed, MESSAGE_COUNT is decremented, and MESSAGES_ACKNOWLEDGED is incremented. When a destination is empty, we would expect MESSAGES_ADDED and MESSAGES_ACKNOWLEDGED to be equal.

      Unfortunately, if a message is consumed as part of an XA transaction that rolls back, MESSAGES_ACKNOWLEDGED is still incremented, although the message has, by definition, not been acknowledged by the client. In situations where message processing sometimes fails and has to be re-tried, the statistics soon lose coherence. While this doesn't seem to be a problem except inasmuch as it leads to confusing metrics, it makes it difficult to troubleshoot other issues that require the metrics to be meaningful.

      Attachments

        Activity

          People

            csuconic@redhat.com Clebert Suconic
            rhn-support-kboone Kevin Boone
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: