简体   繁体   English

MSMQ服务未读取队列

[英]MSMQ service not reading the queue

I'm using MSMQ web service to read data from a queue and store it in database. 我正在使用MSMQ Web服务从队列中读取数据并将其存储在数据库中。 Currently I am running the service using Visual Studio 2010 (Is this the issue?). 当前,我正在使用Visual Studio 2010运行该服务(这是问题吗?)。 The code snippets are below. 代码段如下。

Contract 合同

[ServiceContract]
public interface IService1
{
    [OperationContract(IsOneWay = true,Action="*")]
    void DOWork(MsmqMessage<Param> p);
}

Implementation 履行

public class Service1:IService1
{
    [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
    public void DoWork(Param p)
    {
        new Service1BL().DoWork(p);
    }
}

Config 配置

<service name="NameSpace.Service1" behaviorConfiguration="MSMQServiceBehavior">
                <endpoint address="net.msmq://localhost/private/Service1" binding="netMsmqBinding" bindingConfiguration="PoisonBinding" contract="IService1"/>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>

<behavior name="MSMQServiceBehavior">
    <serviceDebug includeExceptionDetailInFaults="true"/>
    <serviceMetadata httpGetEnabled="True"/>
   </behavior>

<netMsmqBinding>
                <binding name="PoisonBinding" receiveRetryCount="1" maxRetryCycles="5" retryCycleDelay="00:00:05" receiveErrorHandling="Fault">
                    <security mode="None"/>
                </binding>
            </netMsmqBinding>

Additional Info 附加信息

  • I have tried with different queue names. 我尝试使用不同的队列名称。 Like .\\Private$\\Service1 and .\\Private$\\Service1.svc 像。\\ Private $ \\ Service1和。\\ Private $ \\ Service1.svc

    • Message Queuing, Message Queuing Triggers, Net.Msmq Listner adapter and WAS services are running 消息队列,消息队列触发器,Net.Msmq Listner适配器和WAS服务正在运行
    • I am explicitly inserting the messages into the queue 我明确地将消息插入队列

-- -

MessageQueue queue = new MessageQueue(@".\private$\service1");
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
{
   queue.Send(p, MessageQueueTransactionType.Single);
   queue.Close();
   scope.Complete();
}

The reason for this was, I am calling the MSMQ webservice from another web service. 原因是,我正在从另一个Web服务调用MSMQ Web服务。 When I make the call to the MSMQ service, instead of inserting the messages into the queue, it was invoking the MSMQ service. 当我调用MSMQ服务时,不是在将消息插入队列中,而是在调用MSMQ服务。

Check the spelling of your queue name format. 检查队列名称格式的拼写。

Instead of 代替

MessageQueue queue = new MessageQueue(@".\private$\service1");

you should instead try this: 您应该尝试以下操作:

MessageQueue queue = new MessageQueue(@"FormatName:DIRECT=OS:YOURMACHINENAME\private$\service1");

... where YOURMACHINENAME needs, of course, to be substituted with the name of the machine that holds the queue. ...当然,您的YOURMACHINENAME需要替换为持有队列的计算机的名称。 :-) :-)

Please note that the first part is case-sensitive . 请注意,第一部分区分大小写

I believe that this will work as well (change your single backslash to double backslashes). 我相信这也会起作用(将单反斜杠更改为双反斜杠)。 And you don't need to use the machine name (so when you move it from your local box to wherever, you don't need to change your code). 而且您不需要使用计算机名称(因此,当您将其从本地框移动到任何地方时,都无需更改代码)。

MessageQueue queue = new MessageQueue(@".\\private$\\service1")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM