NServiceBus 未在测试系统上发布
我有以下设置:
一个名为
CoreHost
的服务应该接收一个ExecuteWorkflowByAttributeCommand
,它是Bus.Send
并发布之后 WorkflowByAttributeExecuted。
一个“客户端”使用
Bus.Send
执行命令并订阅WorkflowByAttributeExecuted
消息。
处理程序如下所示:
public void Handle(WorkflowByAttributeCommand message)
{
MessageLifetimeLogger.Info("Received WorkflowByAttribute Command", ...);
var log = _executor.ExecuteWithLog(message.Attribute,
message.SerializedWorkItem,
message.Id);
Bus.Publish(new WorkflowByAttributeExecuted(message.Id, log));
MessageLifetimeLogger.Info("Completed WorkflowByAttribute Command", ...);
}
在我的开发机器上它运行良好,但在我们的测试系统上却运行不佳。
命令被接收并且处理程序显然被执行(日志包含适当的条目),但没有发布消息。
令我惊讶的是日志在两台机器上看起来完全不同。
工作机器日志包含
Received message MHP.Domain.Common.Core.Messaging.WorkflowByAttribute.WorkflowByAttributeCommand, MHP.Domain.Common.Core, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null with ID 6e15d4f7-7aa7-4be3-bd80-e70497bc5051\66585 from sender TestServerQueue@PC-SB-11
Activating: WorkflowByAttributeHandler
// some log entries generated by the Handle method
Sending message MHP.Domain.Common.Core.Messaging.WorkflowByAttribute.WorkflowByAttributeExecuted, MHP.Domain.Common.Core, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null with ID 6e15d4f7-7aa7-4be3-bd80-e70497bc5051\66587 to destination TestServerQueue@PC-SB-11.
WorkflowByAttributeHandler Done.
其中不工作机器日志仅包含
Received message MHP.Domain.Common.Core.Messaging.WorkflowByAttribute.WorkflowByAttributeCommand, MHP.Domain.Common.Core, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null with ID 6e15d4f7-7aa7-4be3-bd80-e70497bc5051\66585 from sender TestServerQueue@PC-SB-11
// some log entries generated by the Handle method
但是所有消息类型似乎都已成功注册:
Subscribing TestServerQueue@VM-SCRUM-VLOG to message type MHP.Domain.Common.Core.Messaging.WorkflowByAttribute.WorkflowByAttributeExecuted, MHP.Domain.Common.Core, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null |
Subscribing TestServerQueue@VM-SCRUM-VLOG to message type MHP.Domain.Common.Core.Messaging.WorkflowByAttribute.WorkflowByAttributeCommand, MHP.Domain.Common.Core, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null |
服务器的 app.config 看起来像
<MsmqTransportConfig
InputQueue="CoreHostQueue"
ErrorQueue="ErrorQueue"
NumberOfWorkerThreads="1"
MaxRetries="5" />
<UnicastBusConfig>
<MessageEndpointMappings>
</MessageEndpointMappings>
</UnicastBusConfig>
另一个包含消息映射
<MsmqTransportConfig
InputQueue="TestServerQueue"
ErrorQueue="ErrorQueue"
NumberOfWorkerThreads="2"
MaxRetries="5" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="MHP.Domain.Common.Core.Messaging.WorkflowByAttribute.WorkflowByAttributeCommand, MHP.Domain.Common.Core" Endpoint="CoreHostQueue"/>
<add Messages="MHP.Domain.Common.Core.Messaging.WorkflowByAttribute.WorkflowByAttributeExecuted, MHP.Domain.Common.Core" Endpoint="CoreHostQueue"/>
</MessageEndpointMappings>
</UnicastBusConfig>
I have the following Setup:
One service called
CoreHost
should receive aExecuteWorkflowByAttributeCommand
which isBus.Send
to it and publishWorkflowByAttributeExecuted
afterwards.One "client" which uses
Bus.Send
to execute the command and is subscribed to theWorkflowByAttributeExecuted
message.
The Handler looks like this:
public void Handle(WorkflowByAttributeCommand message)
{
MessageLifetimeLogger.Info("Received WorkflowByAttribute Command", ...);
var log = _executor.ExecuteWithLog(message.Attribute,
message.SerializedWorkItem,
message.Id);
Bus.Publish(new WorkflowByAttributeExecuted(message.Id, log));
MessageLifetimeLogger.Info("Completed WorkflowByAttribute Command", ...);
}
On my development machine it runs fine but on our test system the same does not.
The command is received and the handler is obviously executed (the log contains the appropriate entries) but no message is published.
What surprises me is that the log looks completely different on both machines.
The working machines log contains
Received message MHP.Domain.Common.Core.Messaging.WorkflowByAttribute.WorkflowByAttributeCommand, MHP.Domain.Common.Core, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null with ID 6e15d4f7-7aa7-4be3-bd80-e70497bc5051\66585 from sender TestServerQueue@PC-SB-11
Activating: WorkflowByAttributeHandler
// some log entries generated by the Handle method
Sending message MHP.Domain.Common.Core.Messaging.WorkflowByAttribute.WorkflowByAttributeExecuted, MHP.Domain.Common.Core, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null with ID 6e15d4f7-7aa7-4be3-bd80-e70497bc5051\66587 to destination TestServerQueue@PC-SB-11.
WorkflowByAttributeHandler Done.
whereby the not working machines log contains only
Received message MHP.Domain.Common.Core.Messaging.WorkflowByAttribute.WorkflowByAttributeCommand, MHP.Domain.Common.Core, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null with ID 6e15d4f7-7aa7-4be3-bd80-e70497bc5051\66585 from sender TestServerQueue@PC-SB-11
// some log entries generated by the Handle method
However all message types seem to be registered successfully:
Subscribing TestServerQueue@VM-SCRUM-VLOG to message type MHP.Domain.Common.Core.Messaging.WorkflowByAttribute.WorkflowByAttributeExecuted, MHP.Domain.Common.Core, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null |
Subscribing TestServerQueue@VM-SCRUM-VLOG to message type MHP.Domain.Common.Core.Messaging.WorkflowByAttribute.WorkflowByAttributeCommand, MHP.Domain.Common.Core, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null |
The app.config of the server looks like
<MsmqTransportConfig
InputQueue="CoreHostQueue"
ErrorQueue="ErrorQueue"
NumberOfWorkerThreads="1"
MaxRetries="5" />
<UnicastBusConfig>
<MessageEndpointMappings>
</MessageEndpointMappings>
</UnicastBusConfig>
The other one contains the message mappings
<MsmqTransportConfig
InputQueue="TestServerQueue"
ErrorQueue="ErrorQueue"
NumberOfWorkerThreads="2"
MaxRetries="5" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="MHP.Domain.Common.Core.Messaging.WorkflowByAttribute.WorkflowByAttributeCommand, MHP.Domain.Common.Core" Endpoint="CoreHostQueue"/>
<add Messages="MHP.Domain.Common.Core.Messaging.WorkflowByAttribute.WorkflowByAttributeExecuted, MHP.Domain.Common.Core" Endpoint="CoreHostQueue"/>
</MessageEndpointMappings>
</UnicastBusConfig>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
订阅未持久存储。感谢 Andreas Öhlund 的帮助!
The subscriptions where not stored durably. Thanks to Andreas Öhlund for help!
请注意,只有在发布者和订阅者上保存您要发布的消息的程序集的版本和公钥标记相同时,发布者才会成功评估订阅。
原因是订阅者在启动时向发布者发送的订阅消息包含此信息。
检查发布者订阅存储中存储的订阅消息,并确保版本/PKT 与订阅者匹配。
Be aware that the publisher will only evaluate the subscription successfully if the version and public key token of the assembly holding the messages you are publishing are identical on both publisher and subscriber.
The reason for this is that the subscription messages sent by the subscriber to the publisher on start up contain this information.
Check the subscription messages stored in the publishers subscription store and make sure the version/PKT match with the subscribers.