I'm using MSMQ web service to read data from a queue and store it in database. Currently I am running the service using Visual Studio 2010 (Is this the issue?). 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
- Message Queuing, Message Queuing Triggers, Net.Msmq Listner adapter and WAS services are running
- 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. When I make the call to the MSMQ service, instead of inserting the messages into the queue, it was invoking the MSMQ service.