2011-12-23 3 views
1

キュー(MSMQ)にメッセージを書き込むレガシークライアントがあります。 WCFサービスを使用して、キューからXMLメッセージを取り出したいと思っていました。私はいくつかのMSFTドキュメントに従っていて、他の例では突っ込んできましたが、うまく動作しないようです。サービスホストが起動していますが、プロセスを起動してキューからメッセージを取り出していません。おそらくユーザーの間違いの可能性があります。WCF MsmqIntegrationBinding - キューからメッセージをピッキングしない

キューにメッセージが表示されますか?

コード例:

[ServiceContract] 
    [ServiceKnownType(typeof(XElement))] 
    public interface IMessageProcessor 
    { 
     [OperationContract(IsOneWay = true, Action = "*")] 
     void ProcessMessage(MsmqMessage<XElement> msg); 
    } 
    class MessageServiceClient : IMessageProcessor 
    { 
     [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)] 
     public void ProcessMessage(MsmqMessage<XElement> msg) 
     { 
      using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) 
      { 
       Console.WriteLine("Processing {0} ", msg.ToString()); 
       scope.Complete(); 
      } 

     } 

     static void Main(string[] args) 
     { 
      Uri baseAddress = new Uri(ConfigurationManager.AppSettings["baseAddress"]); 
      // Create a ServiceHost for the CalculatorService type and provide the base address. 
      using (ServiceHost serviceHost = new ServiceHost(typeof(MessageServiceClient), baseAddress)) 
      { 
       // Open the ServiceHostBase to create listeners and start listening for messages. 
       serviceHost.Open(); 

       // The service can now be accessed. 
       Console.WriteLine("The service is ready."); 
       Console.WriteLine("The service is running in the following account: {0}"); 
       Console.WriteLine("Press <ENTER> to terminate service."); 
       Console.WriteLine(); 
       Console.ReadLine(); 

       // Close the ServiceHostBase to shutdown the service. 
       serviceHost.Close(); 
      } 
     } 
    } 

アプリの設定:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <appSettings> 
    <!-- use appSetting to configure MSMQ queue name --> 
    <add key="QueueName" value=".\private$\MyMessageQueue" /> 
    <add key="baseAddress" value="http://localhost:8000/test/message" /> 
    </appSettings> 
    <system.serviceModel> 
    <services> 
     <service name="MessageServiceClient"> 
     <!-- .Net endpoint--> 
     <endpoint address="msmq.formatname:DIRECT=OS:.\private$\MyMessageQueue" 
        binding="msmqIntegrationBinding" 
        bindingConfiguration="DotNetBinding" 
        contract="WcfServiceClient.IMessageProcessor" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="MessageServiceBehavior"> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
      <serviceMetadata /> 
      <!--<serviceThrottling maxConcurrentCalls="20" maxConcurrentSessions="20" />--> 
      <serviceTimeouts /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <msmqIntegrationBinding> 
     <binding serializationFormat="ActiveX" name="ActiveXBinding" durable="false" exactlyOnce="false"> 
      <security mode="None" /> 
     </binding> 
     <binding serializationFormat="Xml" name="DotNetBinding" durable="false" exactlyOnce="false"> 
      <security mode="None" /> 
     </binding> 
     </msmqIntegrationBinding> 
    </bindings> 
    </system.serviceModel> 
</configuration> 

ない私が間違っているのかわから?以下の要素は、以下のようにする必要がありますあなたの設定で

-S-

+0

サービス名に完全修飾名が表示されません。 – Rajesh

答えて

3

:doesntの上記

<services> 
     <service name="WcfServiceClient.MessageServiceClient"> 
     <!-- .Net endpoint--> 
     <endpoint address="msmq.formatname:DIRECT=OS:.\private$\MyMessageQueue" 
        binding="msmqIntegrationBinding" 
        bindingConfiguration="DotNetBinding" 
        contract="WcfServiceClient.IMessageProcessor" /> 
     </service> 
    </services> 

あなたのサービス名は、名前空間が含まれ、それは常にの完全修飾名でなければなりませんサービス

+0

ありがとうございました!それ以上に見えました。 – scarpacci

関連する問題