我正在使用 WCF MsMqIntegrationBinding,并且正在尝试将消息写入远程队列。感谢 Hugh 和 John Breakwell,我能够让他们只使用正常的消息调用来编写,但是当我尝试将 MsmqIntegrationBinding 与 WCF 一起使用时,我似乎无法将其放入远程队列。我没有收到任何错误消息,只是没有出现。
我添加了 useSourceJournal 来尝试看看这是否有助于识别问题。
有任何想法吗?
将消息写入队列的代码。当队列在本地时工作......只是不是远程:
for (int i = 0; i < 1; i++)
{
Console.WriteLine("Loop: " + i.ToString());
string path = ConfigurationManager.AppSettings["TestMessagesAll"];// @"D:\Demos\XmlMessages\";
string[] files = System.IO.Directory.GetFiles(path, "*.xml");
Parallel.ForEach(files, currentFile =>
{
string fileName = System.IO.Path.GetFileName(currentFile);
Console.WriteLine("Writing File {0}", fileName);
XElement xdoc = XElement.Load(path + fileName);
string xml = xdoc.ToString();
using (MessageClient strClient = new MessageClient("MessageResponseEndpoint"))
{
//MsmqMessage<XElement> strXmlMsg = new MsmqMessage<XElement>(xdoc);
MsmqMessage<string> strXmlMsg = new MsmqMessage<string>(xml);
strXmlMsg.Label = fileName;
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
{
strClient.SubmitStringMessage(strXmlMsg);
scope.Complete();
}
//Console.WriteLine(Environment.NewLine + "XML string has been submitted for processing:"
// + Environment.NewLine + "{0}", xdoc.ToString());
}
});
}
应用配置:
<bindings>
<msmqIntegrationBinding>
<binding name="MessageProcessorBinding" useSourceJournal="true">
<security mode="None"/>
</binding>
</msmqIntegrationBinding>
</bindings>
任何建议表示赞赏。
谢谢,
小号