Azure Service Bus subscription.close()不能按预期工作 [英] Azure Service Bus subscription.close() not working as intended

查看:76
本文介绍了Azure Service Bus subscription.close()不能按预期工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个横向扩展的应用程序,其中每个实例都连接到具有相同名称的azure服务总线订阅.最终结果是,只有一个实例可以对任何给定的消息进行操作,因为它们都在侦听相同的订阅.

I have a scaled out application, where each instance connects to a azure service bus subscription with the same name. The end result being that only a single instance gets to act on any given message because they are all listening to the same subscription.

有时,应用程序需要将实例置于空闲状态(服务结构ActiveSecondary副本).发生这种情况时,我需要关闭订阅,以便该实例不再接收消息.如果最初有2个实例,则一旦一个实例进入空闲状态,所有消息都应转到其余实例.这很重要,因此所有消息都由正确配置的主实例处理.

Occasionally the application needs to place an instance into an idle state (service fabric ActiveSecondary replica). When this occurs, I need to close the subscription so that this instance no longer receives messages. If there were 2 instances originally, once one gets placed into the idle state all message should go to the remaining instance. This is important so that all messages are handled by a properly configured primary instance.

当实例空闲时,取消令牌被取消.我有代码侦听取消消息,并在最初创建订阅时在SubscriptionClient上调用Close().

When the instance becomes idle, a cancellation token is cancelled. I have code listening for the cancellation and calling Close() on the SubscriptionClient generated when I created the subscription originally.

问题是,即使我在一个实例上调用Close()之后,消息仍然在它和主要实例之间随机分配.

The issue is, even after I call Close() on one instance, messages are still being randomly split between it and the primary.

是我做此事的方式本质上是错误的,还是我的代码中的其他原因导致了此行为?

Is the way I'm doing this inherently wrong, or is something else in my code causing this behavior?

推荐答案

忽略此帖子.原来,我在同一实例中有两次使用相同的订阅名称,因此它们正在争夺这些事件. close()函数按预期工作.

Disregard this post. Turns out I had the same subscription name used twice within a single instance, so they were competing for the events. The close() function works as expected.

这篇关于Azure Service Bus subscription.close()不能按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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