N服务总线数据总线
我需要移动一些大文件,并且我想使用 NserviceBus,因为这些文件不会保留在系统上。我一直在尝试使用 v.3 中的新数据总线功能来启动并运行它。 文件在一个进程中生成,然后传递到总线上。我的问题是我无法启动公共汽车。我下面有一个示例应用程序,基本上反映了我的设置,除了在“真实”应用程序中,总线位于不同的应用程序中(尚未推送到服务器,因此我只运行一个开发实例)
#region Declarations
private IBus Bus { get; set; }
#endregion
#region Constructors
public Sender()
{
if (Directory.Exists(BasePath))
{
Bus = Configure.Instance
.FileShareDataBus(BasePath)
.UnicastBus().DoNotAutoSubscribe()
.CreateBus()
.Start();
}
}
#endregion
#region Methods
public void SendMessage()
{
// get a list of file names
List<string> fileList = Directory.GetFiles(@"c:\test\").ToList();
Bus.Send<GenericListMessage>(message =>
{
message.Name = "TEST";
message.FileList = new DataBusProperty<List<string>>(fileList);
});
}
#endregion
我的 EndpointConfig.cs 看起来像这个:
public class EndpointConfig : IConfigureThisEndpoint, AsA_Client
{
}
internal class SetupDataBus : IWantCustomInitialization
{
public static string BasePath = @"c:\storage\";
public void Init()
{
Configure.Instance
.FileShareDataBus(BasePath)
.UnicastBus()
.DoNotAutoSubscribe();
}
}
我已经更改了 Sender 类中的代码以发送非 Databus 消息和简单的消息,并且效果很好。但是,当我尝试使用它发送数据总线消息时,我不断收到总线的 NullReferenceException 异常。如果有人能给我指点,我将非常感激。
I need to move some large files, and I wanted to use NserviceBus as the files are not persisted on the system. I have been trying to get this up and running using the new databus feature in v.3.
The files are generated in one process, then passed onto the bus. My problem is that I can't get the bus started. I have a sample application below that basically mirrors my set up, except that in the 'real' application, the bus lives in a different application (not pushed to a server yet so I just run a dev instance)
#region Declarations
private IBus Bus { get; set; }
#endregion
#region Constructors
public Sender()
{
if (Directory.Exists(BasePath))
{
Bus = Configure.Instance
.FileShareDataBus(BasePath)
.UnicastBus().DoNotAutoSubscribe()
.CreateBus()
.Start();
}
}
#endregion
#region Methods
public void SendMessage()
{
// get a list of file names
List<string> fileList = Directory.GetFiles(@"c:\test\").ToList();
Bus.Send<GenericListMessage>(message =>
{
message.Name = "TEST";
message.FileList = new DataBusProperty<List<string>>(fileList);
});
}
#endregion
My EndpointConfig.cs looks like this:
public class EndpointConfig : IConfigureThisEndpoint, AsA_Client
{
}
internal class SetupDataBus : IWantCustomInitialization
{
public static string BasePath = @"c:\storage\";
public void Init()
{
Configure.Instance
.FileShareDataBus(BasePath)
.UnicastBus()
.DoNotAutoSubscribe();
}
}
I have changed my code in the Sender class to send a non-Databus message, and a simple message, and this worked fine. But when I try to use it to send a Databus message I keep getting a NullReferenceException for the bus. If anyone can give me a pointer I would really appreciate it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要更改
private IBus Bus { get;放; }
到:
公共 IBus 巴士 { get;放; 。
获得总线的依赖注入
You need to change
private IBus Bus { get; set; }
to:
public IBus Bus { get; set; }
To get dependecy injection for the bus.