我编写了一个 C# WCF 服务,它应该处理传入的消息、解析它们包含的 XML 并将数据转录到数据库表中。
当我启动托管 WCF MSMQ 服务实现的 Windows 服务时,它会成功处理一条消息,然后停止。
这用于处理队列中的所有消息,直到我开始重命名。我有点茫然,因为它确实被调用了——但只有一次。事件日志中不会记录任何错误。Window Service 主机继续运行,并迅速响应来自 SCM 的服务停止指令。
<netMsmqBinding>
<binding name="Binding.MSMQ.TransportSecurity" maxReceivedMessageSize="32767">
<readerQuotas maxBytesPerRead="32767" maxStringContentLength="32767" maxArrayLength="32767"/>
<security mode="Transport">
<transport msmqAuthenticationMode="None" msmqEncryptionAlgorithm="RC4Stream"
msmqProtectionLevel="None" msmqSecureHashAlgorithm="Sha1" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netMsmqBinding>
...
<services>
<service behaviorConfiguration="Behavior.CommonSense.ChapterWriter"
name="CommonSense.ChapterWriter">
<endpoint address="net.msmq://localhost/private/bob.logwriter"
binding="netMsmqBinding" bindingConfiguration="Binding.MSMQ.TransportSecurity"
name="Endpoint.CommonSense.ChapterWriter.msmq" contract="CommonSense.IChapterWriter">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/CommonSense/ChapterWriter/" />
</baseAddresses>
</host>
</service>
</services>
...
using System.ServiceModel;
namespace CommonSense
{
[ServiceContract]
public interface IChapterWriter
{
[OperationContract(IsOneWay = true)]
void Write(string xml);
}
}