如何从Azure服务总线主题订阅中接收JSON对象 [英] How to receive JSON object from the azure service bus topic subscriptions

查看:142
本文介绍了如何从Azure服务总线主题订阅中接收JSON对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对实施Azure Service Bus接收来自主题订阅的消息有疑问. 我们在组织中使用多个应用程序,我们需要在一个子系统与其他子系统之间共享数据,以便使用Azure Service Bus.在这里,我的一个应用程序经常向服务总线主题订阅发送一条消息.每当在我们的应用程序中创建新的用户帐户时,每次用户配置文件数据都会将数据发送到相应的服务总线主题订阅.我在下面提到了必须接收JSON对象的快照.该消息存储为JSON对象.

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.

在此处输入图片描述

JSON对象:

{"id":"N322333","firstName":"adsdddd","lastName":"asddd","email":"hello@gmail.com123ZXc","emailVerified":false,"dateOfBirth": "2016-08-03",登录":"qqqqqqqqqq",密码":"Pass @ 1234",家庭电话":"233322",手机":"1111111122asdf",工作电话":"22222", "gender":1,"centerId":"I23642","userType":"student","staffRole":null,"staffActive":false}

{"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}

现在,在转移到死信之前,我将接收已经发送到azure服务总线主题订阅队列的JSON对象. 可以将JSON对象存储在订阅上的JSON对象列表中.我搜索了很多无法找到合适解决方案的示例.请让我分享您的建议如何接收JSON对象列表?我会等你的答复.

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.

此致

Parthiban.

Parthiban.

推荐答案

BrokeredMessage的有效负载是应用程序的唯一业务.您可以控制发送邮件的内容.如果可以的话,您可以将JSON对象作为有效载荷发送到单个代理消息中,并处理列表.

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. 技术:如何接收多条消息
  2. 逻辑+技术:如何聚合多个消息并从逻辑上知道列表何时是要处理的完整列表.

第一项并不是那么困难,您可以使用 .ReceiveBatchAsync()

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.

一句话-从图片中看来,您所有的邮件都具有相同的ID.它切断时很难看到.这是一个好习惯

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

这篇关于如何从Azure服务总线主题订阅中接收JSON对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆