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 ))
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.
- a specific fix for array[Byte] i.e. setObjectProperty for that case
- 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