I am trying to receive Azure Queue Message from Java. I am able to receive message using BrokeredMessage in java. (I am novice to java).
My problem is message.getBody() is returning some header information as well (Not just the message as I need).
I get string3http://schemas.mi@string3http://schemas.microsoft.com/2003/10/Serialization/?? message appended with my body in front of it. How can I get rid of this header information.
And I also I noticed i get message in two batches. (Not the whole lot at once)
My first batch of message.getBody()returns below message
'@string3http://schemas.mi'
My Second batch of message.getBody()returns below message
@crosoft.com/2003/10/Serialization/?? + My actual message.
MY total message size is less than 500B, But I have set byte size to 4096. So is is not splinting because of size issue.
This is my receiver code I use.
ReceiveMessageOptions opts = ReceiveMessageOptions.DEFAULT;
opts.setReceiveMode(ReceiveMode.PEEK_LOCK);
while (true)
{
ReceiveQueueMessageResult resultQM =
service.receiveQueueMessage("MyqueueName", opts);
BrokeredMessage message = resultQM.getValue();
if (message != null && message.getMessageId() != null)
{
byte[] b = new byte[4096];
String s = null;
int numRead = message.getBody().read(b);
while (-1 != numRead)
{
s = new String(b);
s = s.trim();
System.out.print(s);
numRead = message.getBody().read(b);
}
}
}
This is the total output of System.out.print(s);. (But in two batches as I mentioned before)
total output
string3http://schemas.microsoft.com/2003/10/Serialization/??+ My actual message.
Any Help is much appreciated!