views:

4

answers:

0

Hi folks, i want to write the web service that will be read messages from DLQ.

As i understand if the message can not be delivered(there are other cases such as timeout, authentication etc.) from Client to Service, then message will be placed to DLQ(in this case i use custom DLQ), and DLQ Service will be called automatically. I wrote the 3 services: client, service and DLQ Service, but when i turn off the service(server) and make client calling service, then message is not placed to DLQ(appropriate methods not called in DLQ Service). But when i turn on service messages are delivered to service.

My code below :

// server app.config

<compilation debug="true" />

<services>

  <service name="Service.MyService" behaviorConfiguration="Service.Service1Behavior">

    <host>

      <baseAddresses>

        <add baseAddress = "http://localhost:8731/Design_Time_Addresses/Service/MyService/" />

      </baseAddresses>

    </host>

    <endpoint address ="net.msmq://localhost/private/MyServiceQueue"

binding="netMsmqBinding"

contract="Service.IMyService"

bindingConfiguration = "NoMSMQSecurity">

      <identity>

        <dns value="localhost"/>

      </identity>

    </endpoint>

  </service>

</services>

<serviceBehaviors>

  <behavior name="Service.Service1Behavior">

    <serviceMetadata httpGetEnabled="True"/>

    <serviceDebug includeExceptionDetailInFaults="False" />

  </behavior>

</serviceBehaviors>

//server code

namespace Service

{

[ServiceContract]

public interface IMyService

{

    [OperationContract(IsOneWay = true)]

    void GetData(int value);

}

}

namespace Service

{

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]

public class MyService : IMyService

{

    [OperationBehavior(TransactionScopeRequired = true)]

    public void GetData(int value)

    {

        tst = value;

        Transaction transaction = Transaction.Current;

    }

    private static int tst = 0;

}

}

//client app.config

<system.serviceModel>

    <bindings>

        <netMsmqBinding>

            <binding name="NetMsmqBinding_IMyService" closeTimeout="00:01:00"

                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"

                deadLetterQueue="Custom" durable="true" exactlyOnce="true"

                maxReceivedMessageSize="65536" maxRetryCycles="2" receiveErrorHandling="Fault"

                receiveRetryCount="5" retryCycleDelay="00:30:00" timeToLive="1.00:00:00"

                useSourceJournal="false" useMsmqTracing="false" queueTransferProtocol="Native"

                maxBufferPoolSize="524288" useActiveDirectory="false" 

                     customDeadLetterQueue="net.msmq://localhost/private/MyCustomDLQ">

                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />

                <security mode="None">

                    <transport msmqAuthenticationMode="WindowsDomain" msmqEncryptionAlgorithm="RC4Stream"

                        msmqProtectionLevel="Sign" msmqSecureHashAlgorithm="Sha1" />

                    <message clientCredentialType="Windows" />

                </security>

            </binding>

        </netMsmqBinding>

    </bindings>

    <client>

        <endpoint address="net.msmq://localhost/private/MyServiceQueue"

            binding="netMsmqBinding" bindingConfiguration="NetMsmqBinding_IMyService"

            contract="MyService.IMyService" name="NetMsmqBinding_IMyService">

            <identity>

                <dns value="localhost" />

            </identity>

        </endpoint>

    </client>

</system.serviceModel>

//client code

        using (TransactionScope scope = new TransactionScope())

        {

            MyService.MyServiceClient proxy = new MyService.MyServiceClient();



            try

            {

                proxy.Open();

                proxy.GetData(1);

            }

            finally

            {

                proxy.Close();

            }



            scope.Complete();

        }

//DLQ Service app.config :

<compilation debug="true" />

<services>

  <service name="ClientDQL.MyDLQService">

    <endpoint address="net.msmq://localhost/private/MyCustomDLQ"

              binding="netMsmqBinding"

              contract="ClientDQL.IMyDLQService"

              bindingConfiguration="NoMSMQSecurity">

      <identity>

        <dns value="localhost" />

      </identity>

    </endpoint>

  </service>

</services>

<bindings>

  <netMsmqBinding>

    <binding name = "NoMSMQSecurity">

      <security mode = "None">

      </security>

    </binding>

  </netMsmqBinding>

</bindings>

//DLQ service code

namespace ClientDQL { [ServiceContract] public interface IMyDLQService { [OperationContract(IsOneWay = true)] void GetData(int value); } }

namespace ClientDQL

{

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]

public class MyDLQService : IMyDLQService

{

    [OperationBehavior(TransactionScopeRequired = true)]

    public void GetData(int value)

    {

        MsmqMessageProperty msmqProperty = OperationContext.Current.IncomingMessageProperties[MsmqMessageProperty.Name] as MsmqMessageProperty;

    }

}

}

But DLQ Service has never been called. Where is a problem, what i am doing wrong ?? Please help

One more question :

How many attempts to send will make client before message will be placed to DLQ ?