The Mats Intercept API allows tooling to intercept all initiation and stage processing, and have a ton of metadata about such processing, in particular timings.

The JMS Mats implementation implements this API, in addition to the Mats API itself.

Logging (over SLF4J) and Metrics gathering (using Micrometer) is implemented as plugins to Mats using this API. The LocalHtmlInspectForMatsFactory also has an interceptor that gathers local statistics.

Features

You get detailed information about each stage’s processing, and how much time went into receiving and destructuring the message, decompressing it (if compressed), performing the transactional demarcation, invoking the “user lambda”, sending message, and committing.

You may also add and remove messages, and even intercept the entire user lambda invocation.

See JavaDoc here, in particular the main interfaces MatsInitiateInterceptor and MatsStageInterceptor.

Logging

Logging is implemented as an Intercept plugin: Initiations, Message reception, Process complete, and any sent messages, are logged. Each of the log lines have a rich set of MDC properties set, which, if you’ve configured your logging system sanely, will end up as fields. These props are metrics and states, which can both be used to query on, but also used to make statistics and graphs.

See JavaDoc here

Metrics

Metrics is also implemented as an Intercept plugin: Several key metrics are kept using Micrometer. You may expose these as e.g. Prometheus scrape or any other of the dozens metric collector/exposition solutions Micrometer support, it being “SLF4J for Metrics”. From your metrics system, you may then graph out e.g. stage timings, message broker send and commit times etc.

See JavaDoc here

Right, so we’ve seen how to make endpoints, talk with them, and install logging and other interceptors - but you should also monitor your broker. MatsBrokerMonitor can do that, check next chapter!

Updated: