2

ローカルプライベートキューがあります。また、msmqIntegrationBindingを使用してキューをリッスンするMVCアプリケーション内にWCFサービスがあります。問題は、メッセージがキューに入れられたときにサービスコントラクトが呼び出されないが、メッセージがすぐに消えることです。メッセージはポイズンキューにありません。これが、キューへのバインディングを宣言するconfig-partです。

<services>
  <service name="SkruvInfo.Web.Service.QueueMessageReceiver">
    <endpoint address="msmq.formatname:DIRECT=OS:LEIA\private$\screwinfo_autotests_messagequeue"
                      binding="msmqIntegrationBinding"
                      bindingConfiguration="MsmqBinding"
                      contract="SkruvInfo.Web.Service.IQueueMessageReceiver" />
  </service>
</services>

そしてここに契約があります:

[ServiceContract(Namespace = "http://localhost/SkruvWeb/Service")]
public interface IQueueMessageReceiver
{
    [OperationContract(IsOneWay = true, Action = "*")]
    void PutScrewInfoMessage(MsmqMessage<string> msg);
}

そして、これがサービスのメソッドです:

    [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
    public void PutScrewInfoMessage(System.ServiceModel.MsmqIntegration.MsmqMessage<string> msg)
    {
        log4net.Config.XmlConfigurator.Configure();
        var log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        try
        {
            log.Debug("Message from queue: " + msg.Body.ToString(CultureInfo.InvariantCulture));
            var xDoc = new XmlDocument();
            xDoc.LoadXml(msg.Body);
            CacheScrewInfoModelFromScrewInfoXmlDoc(xDoc);
        }
        catch (Exception e)
        {
            log.Error("Error parsing message from queue",e);
            EventLog.WriteEntry("Application","Message error for screws");
        }
    }

メッセージが消えるのにサービスを呼び出さない理由について何か提案はありますか?

4

2 に答える 2

1

ServiceKnownType 属性を使用してサービス コントラクトを変更してみてください。

[ServiceContract(Namespace = "http://localhost/SkruvWeb/Service")]
[ServiceKnownType(typeof(String))]
public interface IQueueMessageReceiver
{
    [OperationContract(IsOneWay = true, Action = "*")]
    void PutScrewInfoMessage(MsmqMessage<string> msg);
}

アップデート

MsmqIntegrationBinding を使用している場合、キュー クライアントは VB6 クライアントのようなレガシー アプリケーションであると想定していますか? その場合は、サービス バインディング構成でシリアル化形式を指定する必要があります。例えば:

  <msmqIntegrationBinding>
    <binding name="MsmqBinding" serializationFormat="ActiveX">
      <security mode="None" />
    </binding>
  </msmqIntegrationBinding>

許容値は、ここに記載されています。

于 2012-07-25T09:16:20.370 に答える