none
How to implement Pause feature on a Throttled WCF MSMQ Queue? Can I have Multiple Interfaces in single WCF Service? RRS feed

  • Question

  • I have a MSMQ WCF Service that uses throttling and System.Diagnostics.Process.Start to implement a (batch) execution queue and I used it for my first build today! The advantage is I can queue up multiple builds and have them execute one at a time.

    I got to thinking: What if I am half way thru the first build and there is another build in the queue (that has not started yet) and it is almost time to hibernate the laptop and go home instead of waiting for the second build to finish?

    How can I implement a "pause" feature so the current build finishes but it does not start on the second build waiting in the queue? Can this same service implement a second synchronous interface using DualHttpBinding?

    The first MSMQ interface implements a function called shellCommand which calls Process.Start and then blocks while that executes.

    How can I implement a second interface called QueueControl (in the same service) with a function Pause with DualHttpBinding or just WSHttpBinding that sets a flag in the implementation of shellCommand (of the first MSMQ interface) that causes it to exit the process instead of returning to fetch another entry from the queue?

    Anybody got an example? What would I boogle search for?

    Thanks

    Siegfried


    siegfried heintze


    • Edited by siegfried_ Saturday, February 20, 2016 3:09 AM
    Saturday, February 20, 2016 3:07 AM

Answers

  • Hi siegfried_,

    >>Do I have the option of just doing "public class MSMQBatchQueueImpl : IBatchQueueService, IQueueControl {}"

    Yes, you can create a such option:public class MSMQBatchQueueImpl : IBatchQueueService, IQueueControl {} to implement your requirement.

    >>What would my app.config look like? Would I define a new endpoint?

    Yes, you need to define a new endpoint to bind its contract to the IQueueControl, in this way one contract of the endpoint will bind to the IBatchQueueService, the contract of the other endpoint will bind to the IQueueControl.

    >>Where and how would I bind IQueueControl to HttpDualBinding?

    We can bind the IQueueControl to wsHttpDualBinding by using the following config code:

    endpoint address="" binding="wsDualHttpBinding" 
    contract="Yournamespace.IQueueControl">

    >>Would I still have a single baseAddress and single service?

    It is ok to use the following baseAddress for the wsHttpDualBinding:

    <baseAddresses>
         <add baseAddress="http://SW:8080/Design_Time_Addresses/MSMQNoSecurityService/MSMQService/"/>
     </baseAddresses>
    Besides, the following article will show us the detailed information about how to have multiple interfaces in WCF, please try to refer to:
    http://www.codeproject.com/Tips/830986/Multiple-Service-Contract-in-WCF .


    Best Regards,
    Amy Peng

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, February 26, 2016 9:20 AM
    Moderator

All replies

  • Hi Siegfried,

    >>How to implement Pause feature on a Throttled WCF MSMQ Queue?

    Based on your description, I assume that your requirement is to call QueueControl Intervals for a period of time, you could use loop and thread.sleep to implement it. Like this:

    while(true)
    
    {
    
      QueueControl();
    
      Thread.Sleep(3000);  //you could modify the value as you require.
    
    }

    >> Can this same service implement a second synchronous interface using DualHttpBinding?

    You could define a interface which inherits the other two interfaces like below:

    public interface IMyInterface : IInterface1, IInterface2

     

    Best regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, February 22, 2016 1:25 PM
    Moderator
  • Amy: Please explain the advantage of creating a third interface.

    Do I have the option of just doing "public class MSMQBatchQueueImpl : IBatchQueueService, IQueueControl {}"

    What would my app.config look like? Would I define a new endpoint? What would that look like. Where and how would I bind IQueueControl to HttpDualBinding? Would I still have a single baseAddress and single service? Can you help me modify my app.config? Here is my app.config so far (as borrowed and modified from Great WCF/MSMQ example from CodeProject).

    Thanks

    Siegfried

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.web>
        <compilation debug="true" />
      </system.web>
    
      <system.serviceModel>
        <services>
          <service name="MSMQNoSecurityService.MSMQService">
            <host>
              <baseAddresses>
                <add baseAddress="http://SW:8080/Design_Time_Addresses/MSMQNoSecurityService/MSMQService/"/>
              </baseAddresses>
            </host>
            <endpoint address="net.msmq://SW/private/TestQueue"
                      binding="netMsmqBinding" bindingConfiguration="MyBinding"
                      contract="MSMQNoSecurityService.IBatchQueueService">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <serviceMetadata httpGetEnabled="True" />
              <serviceDebug includeExceptionDetailInFaults="False" />
            <!-- Specify throttling behavior -->
            <serviceThrottling maxConcurrentCalls="1" maxConcurrentInstances="1" maxConcurrentSessions="1"/>
          </behavior>
        </serviceBehaviors>
        </behaviors>
    
        <bindings>
          <netMsmqBinding>
            <binding name="MyBinding"  >
              <security mode="None"/>
            </binding>
          </netMsmqBinding>
        </bindings>
      </system.serviceModel>
      <system.diagnostics>
        <!--
        <sources>
          <surce name="System.ServiceModel"
                switchValue="Critical,Information,ActivityTracing"
                    propagateActivity="true">
            <listeners>
              <add name="messages"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData="c:\Users\siegfried\Documents\logs\wcftrace.log" />
            </listeners>
          </source>
        </sources>
        -->
        <trace autoflush="true" />
        <!--
        <sources>
          <source name="System.ServiceModel.MessageLogging">
            <listeners>
              <add name="messages"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData="c:\Users\siegfried\Documents\logs\wcflog.log" />
            </listeners>
          </source>
        </sources>-->
      </system.diagnostics>
    
      <system.serviceModel>
        <diagnostics>
          <messageLogging
                  logEntireMessage="false"
                  logMalformedMessages="true"
                  logMessagesAtServiceLevel="true"
                  logMessagesAtTransportLevel="false"
                  maxMessagesToLog="500"
                  maxSizeOfMessageToLog="5000"/>
        </diagnostics>
      </system.serviceModel>
    
    
    </configuration>


    siegfried heintze


    • Edited by siegfried_ Monday, February 22, 2016 7:25 PM
    Monday, February 22, 2016 7:23 PM
  • Hi siegfried_,

    >>Do I have the option of just doing "public class MSMQBatchQueueImpl : IBatchQueueService, IQueueControl {}"

    Yes, you can create a such option:public class MSMQBatchQueueImpl : IBatchQueueService, IQueueControl {} to implement your requirement.

    >>What would my app.config look like? Would I define a new endpoint?

    Yes, you need to define a new endpoint to bind its contract to the IQueueControl, in this way one contract of the endpoint will bind to the IBatchQueueService, the contract of the other endpoint will bind to the IQueueControl.

    >>Where and how would I bind IQueueControl to HttpDualBinding?

    We can bind the IQueueControl to wsHttpDualBinding by using the following config code:

    endpoint address="" binding="wsDualHttpBinding" 
    contract="Yournamespace.IQueueControl">

    >>Would I still have a single baseAddress and single service?

    It is ok to use the following baseAddress for the wsHttpDualBinding:

    <baseAddresses>
         <add baseAddress="http://SW:8080/Design_Time_Addresses/MSMQNoSecurityService/MSMQService/"/>
     </baseAddresses>
    Besides, the following article will show us the detailed information about how to have multiple interfaces in WCF, please try to refer to:
    http://www.codeproject.com/Tips/830986/Multiple-Service-Contract-in-WCF .


    Best Regards,
    Amy Peng

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, February 26, 2016 9:20 AM
    Moderator