简体   繁体   English

使用不同的接收器实例查看和完成消息 - Azure 服务总线

[英]Peek and Complete Message using different Receiver Instances - Azure Service Bus

Scenario设想

When business transactions are performed, we're supposed to make that data available to end clients.当执行业务交易时,我们应该将这些数据提供给最终客户。

Current Design当前设计

Our web app publishes transaction messages are added to a topic on the Azure Service Bus.我们的 web 应用程序发布事务消息被添加到 Azure 服务总线上的主题。

We expose APIs to clients through which they can consume the data from those transactions.我们向客户端公开 API,他们可以通过这些 API 使用来自这些事务的数据。

Upon calling these APIs, we read the messages from the Subscription and return it to the client.在调用这些 API 时,我们从订阅中读取消息并将其返回给客户端。

Problem问题

We want a guaranteed delivery - we want to make sure the client acknowledges the delivery of the data.我们希望有保证的交付——我们希望确保客户确认数据的交付。 So we don't want to remove the message from the subscription immediately.所以我们不想立即从订阅中删除消息。 We want to keep it until the client acknowledges it.我们希望保留它,直到客户承认为止。

So we only want to do a "Peek" instead of "Receive".所以我们只想做一个“Peek”而不是“Receive”。

So the client calls the first API, to get the data, where we do a Peek.所以客户端调用第一个API,来获取数据,我们在这里做一个Peek。

And once the client has received the packets, the client would call a second API, to acknowledge.一旦客户端收到数据包,客户端将调用第二个 API 来确认。 At this point, we want to remove the message from the Subscription, making it Complete.此时,我们要从订阅中删除消息,使其完成。

The current design of the Service Bus Message Receiver is that, a Complete can be performed only using the same Receiver instance that performed the Peek, as per the documentation, and we also observed the same when we tried it out.服务总线消息接收器的当前设计是,根据文档,只能使用执行 Peek 的相同 Receiver 实例来执行 Complete,我们在尝试时也观察到了相同的情况。

Both the APIs, are two separate APIs and we cannot do the Peek and Complete using the same instance of the Receiver.这两个 API 都是两个独立的 API,我们不能使用相同的 Receiver 实例进行 Peek 和 Complete。

Thinking about options to somehow make the Receiver as a Singleton, across APIs within that App Service.考虑通过该应用服务内的 API 以某种方式使接收器成为 Singleton 的选项。 However this will be a problem when the App Service scales out.但是,当应用服务横向扩展时,这将是一个问题。

Is there a different way to achieve what we're trying to do here?有没有不同的方法来实现我们在这里尝试做的事情?

There is an option available in Azure Service Bus to defer messages. Azure 服务总线中有一个选项可以延迟消息。 Once a message is deferred, it can be received with the help of it's sequence number.一旦消息被延迟,它可以在它的序列号的帮助下被接收。

The first client should receive the message and instead of completing it, it should defer it and return it.第一个客户端应该收到消息,而不是完成它,它应该推迟并返回它。

The second client (which has sequence number) can receive the message from the Subscription.第二个客户端(具有序列号)可以接收来自订阅的消息。 Refer here for more details.有关详细信息,请参阅此处

Another option would be to not use a Service Bus Client on your backend and instead your clients could directly work with Service Bus using its Service REST API (assuming they can't use the AMQP client if I am understanding your scenario correctly).另一种选择是不在您的后端使用服务总线客户端,而是您的客户端可以使用其服务 REST API直接使用服务总线(假设如果我正确理解您的场景,他们不能使用 AMQP 客户端)。

There are APIs to有API

You could also proxy these requests if you'd like using your backend itself or a service like APIM if you are already using it.如果您想使用后端本身或APIM等服务(如果您已经在使用它),您也可以代理这些请求。

PS: Cross posting the answer for the same query on the MSDN forum PS:在MSDN 论坛上交叉发布相同查询的答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure服务总线-有关订阅的消息速览 - Azure Service Bus - Message Peek on Subscription Azure 服务总线 - 查看计划的消息 - Azure Service Bus - Peek a scheduled message 如何使用REST Client在Azure Service Bus主题上窥视锁定消息而不接收和删除 - How to Peek-Lock Message and not Receive and Delete on Azure Service Bus Topic using REST Client 尝试消息上的Azure服务总线异常以完成消息 - Azure service Bus Exception on trye to complete message Javascript/nodejs Azure 服务总线完成一条消息 - Javascript/nodejs Azure Service Bus Complete a message 如何在azure service bus中完成消息 - How to complete the message in azure service bus peek 和 receive 之间的区别(天蓝色服务总线) - Difference between peek and receive (azure service bus) 基于队列长度,Azure服务总线中包含消息,但是我无法接收或查看消息。 - Azure Service Bus have message in it base on Queue Length, but I cannot receive or peek message. 我可以配置azure功能来查看和读取服务总线队列中的消息但不删除它吗? - Can I configure azure function to peek and read message in service bus queue but not delete it? 有没有一种方法可以在Azure队列或Service Bus中获取“处理完成”消息事件? - There is a way to get “Process Complete” Message Event in Azure Queue or Service Bus?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM