netMsmqbinding

config file :

for adding myqueue in the private queue

<appSettings>
<add key=”qname” value=”.\private$\myqueue”/>
</appSettings>

<system.serviceModel>
<services>
<service name=”WcfServiceNetMSMQ.Service1″ behaviorConfiguration=”WcfServiceNetMSMQ.Service1Behavior”>
<host>
<baseAddresses>
<add baseAddress = “http://localhost:8010/WcfServiceNetMSMQ/Service1/&#8221; />
</baseAddresses>
</host>
<endpoint address =”net.msmq://localhost/private/myqueue” binding=”netMsmqBinding” contract=”WcfServiceNetMSMQ.IService1″>
<identity>
<dns value=”localhost”/>
</identity>
</endpoint>
<endpoint address=”mex” binding=”mexHttpBinding” contract=”IMetadataExchange”/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name=”WcfServiceNetMSMQ.Service1Behavior”>
<serviceMetadata httpGetEnabled=”True”/>
<serviceDebug includeExceptionDetailInFaults=”False” />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>

In the host :

//take the qname from config
string qname = System.Configuration.ConfigurationManager.AppSettings[“qname”];
//
if (!MessageQueue.Exists(qname))
{
MessageQueue.Create(qname,true);
}

using (ServiceHost host = new ServiceHost(typeof(WcfServiceNetMSMQ.Service1)))
{
host.Open();
Console.WriteLine(“started…”);

Console.ReadLine();
host.Close();

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s