我正在尝试在已经使用 MSMQ 传递消息的现有系统环境中插入#Rebus。
当然,目的是让 Rebus 接管一切;-),但目前我无法更改任何已经使用 MSMQ 传输的现有代码。
所以,我想我可以在系统的新部分中使用 Rebus 并将消息发送到现有的应用程序队列,但出现了问题。
我像这样配置我的 Rebus:
_bus = Configure.With(new WindsorContainerAdapter(container))
.Logging(l => l.ColoredConsole(LogLevel.Debug))
.Transport(t => t.UseMsmqInOneWayClientMode())
.MessageOwnership(d => d.FromRebusConfigurationSection())
.Serialization(s => s.UseBinarySerializer())
.CreateBus().Start();
它按计划发送消息,但是当我现有的应用程序尝试从队列中读取时,会引发异常:
“无法反序列化作为参数传递的消息。无法识别序列化格式。”
有问题的方法调用是这样的:
// using System.Messaging.MessageQueue
receiveQueue.Receive(_queueTimeout, transaction);
通过代码挖掘我可以看到 Rebus 的 DefaultFilter 或多或少像我们的
return new MessagePropertyFilter
{
Label = true,
ArrivedTime = true,
Extension = true,
Body = true,
Id = true,
};
我们的 MessagePropertyFilter 配置如下:
var propertyFilter = new MessagePropertyFilter
{
Id = true,
Body = true,
Label = true
};
这种微妙的变化真的是异常的原因吗?我们还使用 BinaryFormatter 来序列化消息。
任何帮助将不胜感激 :-)