akka / alpakka

Alpakka is a Reactive Enterprise Integration library for Java and Scala, based on Reactive Streams and Akka.

Home Page:https://doc.akka.io/docs/alpakka/current/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting AccountingToken property on MQ using alpakka

haroldpirum opened this issue · comments

Versions used

Alpakka version: 3.0.4

Akka version: 2.6.19

Expected Behavior

I am trying to set JMS_IBM_MQMD_AccountingToken property for an MQ Message which is required to be a byte array as per:
https://www.ibm.com/docs/en/ibm-mq/7.5?topic=descriptor-message-object-properties

However, byte array is non standard Jms and not supported by alpakka as it throws an exception when creating the message.
https://www.ibm.com/docs/en/ibm-mq/7.5?topic=descriptor-message-object-properties#q032350___q032350_4

Actual Behavior

based on the code here: an exception is thrown when sending the message after adding:

val accountingToken = Array[Byte](1, 1, 1, 1, 1, 1, 1, 1, 1)
message.withProperties(Map(JmsConstants.JMS_IBM_MQMD_ACCOUNTINGTOKEN -> accountingToken ))

https://github.com/akka/alpakka/blob/master/jms/src/main/scala/akka/stream/alpakka/jms/impl/JmsMessageProducer.scala#L89

Relevant logs

Caused by: akka.stream.alpakka.jms.UnsupportedMessagePropertyType: Jms property 'JMS_IBM_MQMD_AccountingToken' has unknown type '[B'. Only primitive types and String are supported as property values.
at akka.stream.alpakka.jms.impl.JmsMessageProducer.$anonfun$populateMessageProperties$1(JmsMessageProducer.scala:89)
at akka.stream.alpakka.jms.impl.JmsMessageProducer.$anonfun$populateMessageProperties$1$adapted(JmsMessageProducer.scala:77)
at scala.collection.immutable.Map$Map3.foreach(Map.scala:448)
at akka.stream.alpakka.jms.impl.JmsMessageProducer.populateMessageProperties(JmsMessageProducer.scala:77)
at akka.stream.alpakka.jms.impl.JmsMessageProducer.send(JmsMessageProducer.scala:23)
at akka.stream.alpakka.jms.impl.JmsProducerStage$$anon$2.$anonfun$sendWithRetries$1(JmsProducerStage.scala:165)

Reproducible Test Case

Please provide a PR with a failing test.

If the issue is more complex or requires configuration, please provide a link to a project that reproduces the issue.

@haroldpirum would you be in the position to suggest a fix to this? I assume it just requires array support in populateMessageProperties.

hi @ennru - i can think of 2 immediate fixes.

  1. a specific fix for array[Byte] i.e. setObjectProperty for that case
  2. remove the exception and have the final case just call setObjectProperty.

Happy to create a PR for either.

Thanks,
Harold

I'd prefer 1. as setting a random instance is rarely what you want.

Hi @ennru please could you help to review the PR, thanks