You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/10/19 08:39:10 UTC

[GitHub] [pulsar-dotpulsar] amareshmad commented on issue #116: Dot pulsar consumer message parsing

amareshmad commented on issue #116:
URL: https://github.com/apache/pulsar-dotpulsar/issues/116#issuecomment-1283640007

   @blankensteiner: pulsar supports with raw bytes & specific schema to transmit/receive. 
   Creating consumer with schema like string, bytearray,sequence . when I convert the consumer message data bytes to string,
   stringData = Encoding.UTF8.GetString(message.Data.ToArray()). there is no change in the received stringData format.
   
   What is best way to parse this kind of data. Producer side (java) saying they are creating properties and putting them into map, converting them and sending to pulsar server, the server is also nothing changes, when we receive lot of ascii, how can we avoid these by converting raw bytes.
   
   I saw few people are using in Java they have PulsarTextMessage to convert the bytes streams into data. (Similar to active mq ITextMessage) 
   
   ByteArrayInputStream bais = new ByteArrayInputStream((byte[]) msg.getBody());
   ObjectInputStream in = null;
   PulsarTextMessage pulsarTextMessage = null;
   Map<String, Object> headersMap = new HashMap<>();
   try {
   in = new ObjectInputStream(bais);
   pulsarTextMessage = ((PulsarTextMessage) in.readObject());
    
   System.out.println("from pulsar-jms-client:, msg is retreived from pulsarTextMessage "+pulsarTextMessage.getText());
   System.out.println("from pulsar-jms-client:, headers will be retrieved from pulsarTextMessage");
   
   System.out.println(pulsarTextMessage.getJMSDeliveryMode());
    
   System.out.println(pulsarTextMessage.getJMSDestination());
   System.out.println(pulsarTextMessage.getJMSType());
   }


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org