Persisting/serializing JMS messages with acknowledgement

We process messages via Akka’s Alpakka using IBM MQ. And we want to use client acknowledgement when the message is finally processed.

Unfortunately the message processing goes through a workflow described via Akka Streams that may not be fully processed on the same node. And we use Akka’s persistence to store intermediate states of the transaction. Format used for persistence is JSON.

It would be ideal if the message acknowledgement token could be persisted. Unfortunately the message acknowledgement is described via a class like this:

case class AckEnvelope private[jms] (message: jms.Message, private val jmsSession: JmsAckSession) {

  val processed = new AtomicBoolean(false)

  def acknowledge(): Unit = if (processed.compareAndSet(false, true)) jmsSession.ack(message)
}

And this doesn’t look to be serializable. Not even with Java’s serialization. We need to persist that acknowledge() logic via Akka persistence, if possible.

Any way to do this, or am I out of luck? Maybe what I want to do here is incompatible with the way JMS is meant to be used, but I hope not :slightly_smiling_face:

Hi Alexandru,

JMS is an interesting example of early Java APIs.

The call to acknowledge is required to be called from the correct thread within the JMS MessageListener. So there is no way you can persist that information for later reuse.

If you find something to make it work, please let us know…

Cheers,
Enno.