简体   繁体   中英

How to receive JSON object from the azure service bus topic subscriptions

I have doubt about to implement azure service bus receive messages from topic subscriptions. We are using multiple applications in our organization and we need to share data between one to other subsystems so that we are using azure service bus. Here one of my application has sent a message frequently to the service bus topic subscription. Whenever a new user account is created in our application every time the user profile data will be sending the data to the corresponding service bus topic subscriptions. I have mentioned below the snapshot which I have to receive the JSON object. The message is stored as a JSON object.

enter image description here

JSON object:

{"id":"N322333","firstName":"adsdddd","lastName":"asddd","email":"hello@gmail.com123ZXc","emailVerified":false,"dateOfBirth":"2016-08-03","login":"qqqqqqqqqq","password":"Pass@1234","homePhone":"233322","mobilePhone":"1111111122asdf","workPhone":"22222","gender":1,"centerId":"I23642","userType":"student","staffRole":null,"staffActive":false}

Now I'm going to receive those JSON object which I have already sent to the azure service bus topic subscriptions queue before moving to the deadletter. JSON objects can be stored a list of JSON objects on the subscription. I have searched lots of examples I could not able to find an appropriate solution. Please let me share your suggestion How can I receive the list of JSON objects? I'll be waiting for your response.

Regards,

Parthiban.

The payload of a BrokeredMessage is application`s sole business. You control what you send in your message. If you can, you could send your JSON object as a single payload in a single brokered message and handle the list.

In case you're asking about how to retrieve multiple messages and consolidate into a single list, that now has two aspects

  1. Technical: how to receive multiple messages
  2. Logical + technical: how to aggregate multiple messages and logically know when a list is a complete list to process.

First item is not that difficult, you could receive messages in batches using .ReceiveBatchAsync()

The second item truly depends on your implementation. If you need to aggregate those individuals messages and process a list, you have to answer questions such as how many messages constitute a list, do you have time period this is taking place, how and where do you store those items as they arrive. Perhaps you just store those messages and a separate process does the processing by constructing a list on a time period, etc.

One remark - from the image it looks like all of your messages have the same ID. Hard to see it as it cuts off. It's a good pract

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM