为什么 nservicebus 忽略我的订阅消息?
我有两个简单的控制台应用程序来集成 nservicebus。一个是发布者,另一个是订阅者。本例中的订阅者还通过 Send()
从另一个 Web 应用程序接收其他消息。当我在开发环境中本地运行它们时,没有任何问题,一切都按预期进行。我可以从网络应用程序发送消息并在我的“订阅者”上接收它们,以及在我的订阅者上接收发布的消息。
但是,当部署到 Server 2008 R2 时,订阅者会向发布者 StatusQueue 发送一条初始消息,其中包含以下内容:
<?xml version="1.0"?>
<Messages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.net/NServiceBus.Unicast.Transport">
<CompletionMessage>
<ErrorCode>0</ErrorCode>
</CompletionMessage>
</Messages>
我认为这只是初始的“我想订阅您发布的 Messages.* 类型的消息”。该消息仅位于队列中,并且永远不会被发布者接收。
发布者配置:
<MsmqSubscriptionStorageConfig
Queue="StatusQueueSubscriptions" />
<MsmqTransportConfig
InputQueue="StatusQueue"
ErrorQueue="StatusError"
NumberOfWorkerThreads="1"
MaxRetries="5"/>
订阅者配置:
<MsmqTransportConfig
InputQueue="AppsInputQueue"
ErrorQueue="AppsError"
NumberOfWorkerThreads="1"
MaxRetries="5"/>
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="Messages" Endpoint="StatusQueue"/>
</MessageEndpointMappings>
</UnicastBusConfig>
I have two simple console applications to integrate nservicebus. One is a publisher, the other a subscriber. The subscriber in the case also receives other messages via Send()
from yet another web application. When I run them locally in my dev environment, there are no problems, everything works as expected. I can send message from the web application and receive them on my "subscriber" as well as receive the published message on my subscriber.
However, when deploying to Server 2008 R2, the subscriber sends an initial message to publisher, StatusQueue, with this content:
<?xml version="1.0"?>
<Messages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.net/NServiceBus.Unicast.Transport">
<CompletionMessage>
<ErrorCode>0</ErrorCode>
</CompletionMessage>
</Messages>
I think this is just the initial "I wanna subscribe to messages you publish of type Messages.*". This message just sits in the queue and is never picked up by the publisher.
The publisher's config:
<MsmqSubscriptionStorageConfig
Queue="StatusQueueSubscriptions" />
<MsmqTransportConfig
InputQueue="StatusQueue"
ErrorQueue="StatusError"
NumberOfWorkerThreads="1"
MaxRetries="5"/>
The subscriber's config:
<MsmqTransportConfig
InputQueue="AppsInputQueue"
ErrorQueue="AppsError"
NumberOfWorkerThreads="1"
MaxRetries="5"/>
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="Messages" Endpoint="StatusQueue"/>
</MessageEndpointMappings>
</UnicastBusConfig>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的订阅被忽略的可能原因是发送到发布者的传入消息与您的订阅中定义的类型不匹配。
因此,当发布者收到消息时,它将根据其中保存的订阅对其进行评估,并且会发现没有匹配项,因此不会向您的订阅者发送任何消息。
这可能是因为 NServiceBus 中的消息类型不仅由程序集/类型名称定义,还由程序集版本和公钥令牌定义。
检查发布者和订阅者持有的消息程序集的版本/PK 令牌,并确保它们正确匹配。
更新
好吧,听起来您的输入队列上的权限在某种程度上阻止了您的发布者服务帐户读取消息。尝试给予服务帐户完全控制权。
另外,您是否检查了日志中的默认日志记录位置是否有错误? (C:\Users(用户名)\AppData\Local\Temp)
The likely reason your subscription is being ignored is that the incoming message to the publisher does not match the type defined in your subscription.
So when the publisher receives the message, it will evaluate it against the subscriptions held in it, and will find no match, so no message will be sent to your subscriber.
This can be because the message type in NServiceBus is defined not just by assembly/type name, but by assembly version and public key token.
Check the versions/PK tokens of the messages assemblies held by the publisher and subscriber and ensure they match exectly.
UPDATE
OK it sounds like The permissions on your input queue are in some way preventing your publisher service account to read messages. Try giving full control to the service account.
Also, have you checked the default logging location for errors in the log? (C:\Users(username)\AppData\Local\Temp)