在Msmq(私人)中获取邮件后,如何从消息队列中自动获取邮件 [英] How Do I Get Messages Automatically From Message Queuing Once Messages Are Acrrived In Msmq (Private)

查看:77
本文介绍了在Msmq(私人)中获取邮件后,如何从消息队列中自动获取邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建两个应用程序,一个是控制台应用程序,它将向客户端计算机(MSMQ)发送消息。另一个带有WCF服务的MSMQ驻留在所有客户机中,并从专用队列中读取所有消息。我的控制台应用程序正常运行意味着它正在向客户端计算机发但是WCF服务不会自动从队列中获取消息。请帮我解决这个问题。



这将是一个很好的帮助。



I)。以下是我的界面:



I am creating two applications one is console app which will be send messages to the client machines(MSMQ). And another one MSMQ with WCF service which resides in all the client machines and reads all the messages from Private queue. My console application working fine means it is sending messages to client machines. But WCF service does not picking up the messages from queue automatically. Please help me in resolving this issue.

It would be a great help.

I). Following is my Interface:

namespace MessageReceiver
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    [ServiceKnownType(typeof(MessageContainer))]
    public interface IMessageHandlerService
    {
        [OperationContract(IsOneWay = true, Action = "*")]
        void ProcessIncomingMessage(MsmqMessage<MessageContainer> incomingOrderMessage);
    }
}





II)。以下是我的实施课





II). Following is my implementation class

public class MessageHandlerService : IMessageHandlerService
    {
        #region IMessageHandlerService Members

        [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
        public void ProcessIncomingMessage(MsmqMessage<MessageContainer> incomingOrderMessage)
        {
            //processing incoming messages
        }

        #endregion
    }





III)。以下是我的合同





III). Following is my contracts

namespace MessageReceiver
{
    [DataContract]
    public class MessageContainer
    {
        public MessageContainer()
        {
        }

        [DataMember(IsRequired = true)]
        public string ProcessName { get; set; }

        [DataMember(IsRequired = true)]
        public string RoboName { get; set; }

        public MessageToRobo msg { get; set; }
    }

    public class MessageToRobo
    {
        [DataMember(IsRequired = true)]
        public string Value1 { get; set; }

        [DataMember(IsRequired = true)]
        public string Value2 { get; set; }

        [DataMember(IsRequired = true)]
        public string Value3 { get; set; }
    }
}





IV)。以下是我的web.config



IV). Following is my web.config

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <!--newly added code starts-->
      <endpointBehaviors>
        <behavior name="IncludeExceptionDetails">
          <callbackDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </endpointBehaviors>
      <!--newly added code ends-->      
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <!--newly added code starts-->
    <services>
      <service name="MessageReceiver.MessageHandlerService">
        <endpoint address="msmq.formatname:DIRECT=OS:MachineName\private$\MessageForRobo" binding="msmqIntegrationBinding" bindingConfiguration="IncomingMessageHandlerBinding" contract="MessageReceiver.IMessageHandlerService">
        </endpoint>
      </service>
    </services>
    <bindings>
      <msmqIntegrationBinding>
        <binding name="IncomingMessageHandlerBinding"

                 closeTimeout="00:30:00"

                 receiveTimeout="01:00:00"

                 retryCycleDelay="00:00:10"

                 receiveRetryCount="0"

                 exactlyOnce="true"

                 maxRetryCycles="3"

                 receiveErrorHandling="Move">
          <security mode="None"/>
        </binding>
      </msmqIntegrationBinding>
    </bindings>
    <!--newly added code ends-->
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <!--newly added code starts-->
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing, All" propagateActivity="true">
        <listeners>
          <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\logs\DNCTrace.svclog"/>
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
  <!--newly added code ends-->
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
  
</configuration>

推荐答案

\ MessageForRobo binding = msmqIntegrationBinding < span class =code-attribute> bindingConfiguration = IncomingMessageHandlerBinding contract = MessageReceiver.IMessageHandlerService >
< / endpoint >
< / service >
< / services >
< 绑定 >
< msmqIntegrationBinding >
< binding name = IncomingMessageHandlerBinding

closeTimeout = 00:30:00

< span class =code-attribute> receiveTimeout = 01:00:00

retryCycleDelay = 00:00:10

< span class =code-attribute> receiveRetryCount = 0

exactOnce = true < span class =code-attribute>

< span class =code-attribute> maxRetryCycles = 3

receiveErrorHandling = 移动 >
< 安全性 mode = / >
< / binding >
< /msmqIntegrationBinding>
</bindings>
<!--newly added code ends-->
<serviceHostingEnvironment multipleSiteBindingsEnabled=\"true\" />
</system.serviceModel>
<!--newly added code starts-->
<system.diagnostics>
<sources>
<source name=\"System.ServiceModel\" switchValue=\"Information, ActivityTracing, All\" propagateActivity=\"true\">
<listeners>
<add name=\"traceListener\" type=\"System.Diagnostics.XmlWriterTraceList ener\" initializeData=\"c:\logs\DNCTrace.svclog\"/>
</listeners>
</source>
</sources>
</system.diagnostics>
<!--newly added code ends-->
<system.webServer>
<modules runAllManagedModulesForAllRequests=\"true\"/>
</system.webServer>

</configuration>
\MessageForRobo" binding="msmqIntegrationBinding" bindingConfiguration="IncomingMessageHandlerBinding" contract="MessageReceiver.IMessageHandlerService"> </endpoint> </service> </services> <bindings> <msmqIntegrationBinding> <binding name="IncomingMessageHandlerBinding" closeTimeout="00:30:00" receiveTimeout="01:00:00" retryCycleDelay="00:00:10" receiveRetryCount="0" exactlyOnce="true" maxRetryCycles="3" receiveErrorHandling="Move"> <security mode="None"/> </binding> </msmqIntegrationBinding> </bindings> <!--newly added code ends--> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel> <!--newly added code starts--> <system.diagnostics> <sources> <source name="System.ServiceModel" switchValue="Information, ActivityTracing, All" propagateActivity="true"> <listeners> <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\logs\DNCTrace.svclog"/> </listeners> </source> </sources> </system.diagnostics> <!--newly added code ends--> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> </configuration>


这篇关于在Msmq(私人)中获取邮件后,如何从消息队列中自动获取邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆