WebApp 中的 NServiceBus
我尝试在 WebApp 中使用 DataBus 功能设置 NServiceBus,但没有成功。这就是我在总线配置方面的情况,
_containerProvider.Register(Component.For<IProducer>()
.UsingFactoryMethod(() => new NServiceBusProducer(() => Configure
.WithWeb()
.DefaultBuilder()
//.AsMasterNode()
.Log4Net()
.MsmqTransport()
.IsTransactional(false) // ??
.PurgeOnStartup(false)
.UnicastBus()
.DefiningMessagesAs(t => t.Namespace != null && t.Namespace == "Magma.CommunicationBus.Messages")
.JsonSerializer()
.FileShareDataBus(@"..\..\..\abc")
//.CreateBus()
//.Start()))
.SendOnly()))
.LifestyleSingleton());
我不知道NServiceBus创建存储文件夹时是否存在权限问题,但我什至看不到DataBus正在初始化。在“监听”端,我可以在输出中看到以下字符串:
- 文件共享数据总线已启动。位置:...
但我在 WebApp 输出中看不到这一点。另外,当 NServiceBus 初始化时,我可以看到(再次在输出中)总线正在使用的修改器列表。再次没有“DataBusMessageMutator”的踪迹,
仅供参考,我用它来发送电子邮件附件。我就是这样做的:
message.Attachements = new DataBusProperty<byte[]>(email.Attachments.Select(a =>
{
using (MemoryStream ms = new MemoryStream())
{
a.ContentStream.CopyTo(ms);
return ms.ToArray();
}
}).First());
我只尝试发送 1 个附件,但我计划发送附件列表。
我无法使其在“发送”端工作。当然,当变元尝试获取不存在的标头来构造它将读取的“事物”的文件路径时,它会在 NServiceBus 代码中某处的“侦听”端崩溃。它在“FileShareDataBus”类的“Get”方法中崩溃,因为“Path.Combine”调用中的“key”参数为 null。
我做错了什么或错过了什么?
I've tried to setup NServiceBus in a WebApp with the DataBus feature to no avail. This is what I have in terms of configuration of the bus,
_containerProvider.Register(Component.For<IProducer>()
.UsingFactoryMethod(() => new NServiceBusProducer(() => Configure
.WithWeb()
.DefaultBuilder()
//.AsMasterNode()
.Log4Net()
.MsmqTransport()
.IsTransactional(false) // ??
.PurgeOnStartup(false)
.UnicastBus()
.DefiningMessagesAs(t => t.Namespace != null && t.Namespace == "Magma.CommunicationBus.Messages")
.JsonSerializer()
.FileShareDataBus(@"..\..\..\abc")
//.CreateBus()
//.Start()))
.SendOnly()))
.LifestyleSingleton());
I don't know if it's a permission problem when NServiceBus is creating the storage folder, but I can't even see that the DataBus is initializing. On the 'listening' side I can see this with this string in the output:
- File share data bus started. Location: ...
But I can't see this in the WebApp output. Also, when NServiceBus is initializing I can see (again in the output) a list of mutators that the bus is using. And again there is no trace of the 'DataBusMessageMutator'
FYI I'm using this to send email attachments. This is how I do this:
message.Attachements = new DataBusProperty<byte[]>(email.Attachments.Select(a =>
{
using (MemoryStream ms = new MemoryStream())
{
a.ContentStream.CopyTo(ms);
return ms.ToArray();
}
}).First());
I'm trying with only 1 but I'm planning to send a list of attachments.
I can't make this working on the 'sending' side. Of course it crashes in the 'listening' side somewhere in the NServiceBus code when the mutator tries to get the non-existing header to construct the file path of the 'thing' it will read. It crashes in the 'Get' method of the 'FileShareDataBus' class because the 'key' parameter is null in the 'Path.Combine' call.
What am I doing wrong or missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我想我找到了答案。您似乎需要实现 I(Message|Command|Event) 接口才能使数据总线正常工作。另外,您可以使用以下方法发送项目列表:
我使用它来将多个附件发送到电子邮件。
但我仍然很好奇为什么它不适用于不引人注目的模式。我希望NServiceBus的人看到这个问题并解释一下。
Well I guess I found the answer. You seem to need to implement the I(Message|Command|Event) interface in order for the databus to work properly. Also, you can send list of items by using something like:
I'm using this to send multiple attachments to an email message.
But I'm still curious as to why it didn't work with the unobtrusive mode. I hope that the NServiceBus people see this question and explain this.