How to read byte attachment in solace

296 Views Asked by At

I am able to receive the InboundMessage message. When I dump it, I can see Binary Attachment but I am not able to extract Binary Attachment from InboundMessage.

I am using python to publish message and java to consume message.

Can anyone help me to extract Binary Attachment from InboundMessage

Binary Attachment:                      len=65
  80 04 95 36 00 00 00 00    00 00 00 8c 0b 6d 6f 64    ...6.........mod
  65 6c 2e 62 61 74 63 68    94 8c 05 42 61 74 63 68    el.batch...Batch
  94 93 94 29 81 94 7d 94    8c 04 6e 61 6d 65 94 8c    ...)..}...name..
  0c 68 65 6c 6c 6f 20 77    6f 72 6c 64 21 94 73 62    .hello.world!.sb
  2e                                                    .
 

Thanks in advance!

1

There are 1 best solutions below

0
Aaron On

If you are using the new Java API, then these are probably the methods you'd want to check out:

  • Message.getPayloadAsBytes() Docs link
  • Message.getPayloadAsString() Docs link
  • InboundMessage.getAndConvertPayload(Converter, Class) Docs link

If you are using JCSMP, then just cast the received BytesXMLMessaage to a BytesMessage and get the raw payload: ((BytesMessage)message).getData(). Or if you are publishing a Text message / String payload, then it would be ((TextMessage)message).getText().

Solace has 4 Java APIs, actually, and there are more for the other protocols Solace supports (MQTT, AMQP, etc.). Edit your question with more specifics about how you're publishing in Python & exactly which Java API you're consuming with.