Write to a file in NServiceBus
Here is what I am trying to accomplish by using NServiceBus. I have a publisher and subscriber. The publisher publishes a message from its queue to the subscriber. Then, the subscriber takes 开发者_开发知识库the message and writes to a file. The file will be an input for a third-party GUI application (It fires when the file is created and ready to be accessed). (It has to be a file since the GUI application does not have the MSMQ functionality).
I think I can write the message into a file in the Handle() of the subscriber, but I am not sure how I can achieve this. Since, the subscriber will be fire as soon as the message arrives. Any help would be appreciate it. Thanks.Yes, you can absolutely do this. It's just a matter of doing File.WriteAllLines("myfile.txt", "some values here") using the standard File class from the .NET API.
In your case you will most likely want to pull different values from the message being received, but the specific format and structure of the file being written will depend heavily on the needs of the input/receiving application.
精彩评论