0

How to send string as protocol buffer message? I want to do the following:

Message message1 = "some string"
ByteString data1 = (message1).toByteString();
System.out.println(String.format("Publishing [%s] on subject [%s]", message1, subject));
streamHandler1.publish(subject, data1);
Russell Sim
  • 1,693
  • 2
  • 14
  • 22
user3591433
  • 105
  • 1
  • 3
  • 11

1 Answers1

0

You can use protocol buffer to serialize your object into a byte array.

Then, send the byte array to a Solace appliance/VMR as part of a BytesMessage

There's a simple example of how to send a message at the Solace website. Note that the example makes use of TextMessage, but can be easily replaced with BytesMessage.

In sequence:

  1. Connect to the Solace Message Router
  2. Create a producer
  3. Create the BytesMessage object
  4. Serialize your protocol buffer into a byte array
  5. Attach the byte array to the previously created BytesMessage
  6. Send the message
Russell Sim
  • 1,693
  • 2
  • 14
  • 22