nservicebus 订户无法取消订阅

发布于 2024-09-08 12:23:04 字数 984 浏览 8 评论 0原文

您好
我在我的项目中使用 NServiceBus 1.9 RTM。
我正在使用发布者-分发者-订阅者模型。
我使用以下代码进行订阅,

 var bus = NServiceBus.Configure.With()
                .SpringBuilder()                    
                    .XmlSerializer()
                .MsmqTransport()
                    .IsTransactional(false)
                    .PurgeOnStartup(false)
                .UnicastBus()
                    .ImpersonateSender(false)
                    .DoNotAutoSubscribe()
                    .LoadMessageHandlers()
                .CreateBus()
                .Start();
                bus.Subscribe<ITestMessage>();
                _isSubscribed = true;
                log.Info(" ITestMessage Subscribed successfully..");
                _serviceBus = bus;

在订阅者中,当我想取消订阅时,

_serviceBus.Unsubscribe<ITestMessage>();

我正在这样做,但它不会取消订阅,也不会抛出任何错误。取消订阅后,EventHandler 仍然从分发器接收消息。

我有什么遗漏的吗...?任何人都可以帮助我。


nRk

Hi
I am using NServiceBus 1.9 RTM in my project.
I am using Publisher - Distributor - Subscriber model.
In subscriber I subscribed using the follwoing code

 var bus = NServiceBus.Configure.With()
                .SpringBuilder()                    
                    .XmlSerializer()
                .MsmqTransport()
                    .IsTransactional(false)
                    .PurgeOnStartup(false)
                .UnicastBus()
                    .ImpersonateSender(false)
                    .DoNotAutoSubscribe()
                    .LoadMessageHandlers()
                .CreateBus()
                .Start();
                bus.Subscribe<ITestMessage>();
                _isSubscribed = true;
                log.Info(" ITestMessage Subscribed successfully..");
                _serviceBus = bus;

when i want to unsbuscribe I am doing like

_serviceBus.Unsubscribe<ITestMessage>();

But it's not unsubscribing nor throwing any error. After unsbuscribing also EventHandler still receiving messages from the distributor.

Is there anything that I am missing...? Anyone can help me.

nRk

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南街女流氓 2024-09-15 12:23:04

您需要明白,取消订阅并不是针对分销商,而是针对发布商。现在,可能是您没有在 MessageEndpointMappings 中为 ITestMessage 的发布者配置正确的端点,这就是取消订阅不起作用的原因。订阅也可能无法正常工作,但事实是您已正确配置了分发器,并且其他人已告诉发布者订阅 ITestMessage 的分发器,这一事实隐藏了这一点。

希望有帮助。

You need to understand that unsubscribing is not something you do against the distributor but rather against the publisher. Now, it could be that you haven't configured the right endpoint for the publisher of your ITestMessage in your MessageEndpointMappings, and that's why the unsubscribe isn't working. It's likely that the subscribe isn't working either, but that's hidden by the fact that you have configured your distributor correctly, and someone else has told the publisher to subscribe the distributor for the ITestMessage.

Hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文