3

I am facing a dilemma with my code, My problem statement is that when I am sending JSon to Azure Service Bus through this piece of code

 BrokeredMessage message = new BrokeredMessage(jsonStr);

and printing the JSON in Sender code , through

System.out.println("Json---"+jsonStr);

This is working fine. But when I am receiving the JSON list from Queue through the same Azure Service Bus , I am able to receive it but some repeated end fields are getting appended after the JSOn list completion. I am using this below piece of code :

     if (message != null && message.getMessageId() != null)
                {
                    System.out.println("MessageID: " + message.getMessageId());


                    // Display the queue message.
                    System.out.print("From queue: ");
                  byte[] b = new byte[200];

                  String s = null;
                    int numRead = message.getBody().read(b);
                   System.out.println("numread--"+numRead);
                    while (-1 != numRead)
                    {
                        s = new String(b);
                        s = s.trim();

                        System.out.print(s);
                        numRead = message.getBody().read(b);
                        //System.out.println("numread--"+numRead);
                    }
} 

And the output I am getting with repeated fields appended at the end :

"oldPartNumber": null,
        "materialType": "4",
        "materialGroup": "HX",
        "bulkItemFlag": "N",
            "flexStringCollab04": null,
            "flexStringCollab05": null,
            "blockShipments": null,
            "earlyShipmentTolerance": 0,
            "overShipmentTolerance": 0.0,
            "priceMismatchToleranceMin": 0.0,
            "priceMismatchToleranceMax": 0.0
          }
        }
      ],
      "grFF": null
    }ingCollab04":null,"flexStringCollab05":null,"blockShipments":null,"earlyShipmentTolerance":0,"overShipmentTolerance":0.0,"priceMismatchToleranceMin":0.0,"priceMismatchTo

You can see last few fields are repeated in output even after the completion of JSOn List from the queue. I have not pasted the whole JSOn as problem is at the end only and my JSOn LISt is somehow contains more fields. I want to eliminate this problem.

Any help appreciated. Thanks in advance

nikita kakraniya
  • 141
  • 2
  • 14
  • Sounds wrong. How do you write your messages to the queue to begin with? – Sean Feldman Jan 15 '18 at 14:05
  • @SeanFeldman I am sending the message into the Azure Service Queue. Using Brokered Message Class and using this line of code: service.sendQueueMessage("sq-jcibe-microservice-e2open-dev", message); – nikita kakraniya Jan 16 '18 at 06:14
  • And BrokeredMessage is constructed using valid JSON? If that's the case, I suggest open an issue against this repo: https://github.com/Azure/azure-service-bus-java – Sean Feldman Jan 16 '18 at 06:52

0 Answers0