locked
WCF - MSMQ - Windows Service RRS feed

  • Question

  • Hi,

    Let me explain you how I have to create to utilize msmqIntegrationBinding and netTcpBinding. The language I am using is C#.

    1) Created a WCF Service Library project.
    2) Created Windows Service project which has the above Library as reference
    3) Configuration Settings(app.config) for WCF Service Library is placed in Windows Service project and the endpoints are defined here. The following is a piece of code for MSMQ endpoints.
    4) Windows Service will be deployed in Server1 System.
    5) TradeClient1 application will be residing on Client1
    6) TradeClient2 application will be residing on Client2


    App.config
    ----------

    <endpoint address="msmq.formatname:DIRECT=OS:.\private$\tradequeue"
    binding="msmqIntegrationBinding" contract="TradeServiceLibrary.ITradeService"
    listenUriMode="Explicit">
    </endpoint>
    <endpoint address="net.tcp://localhost:8732/TradeServiceLibrary/TradeService/"
    binding="netTcpBinding" bindingConfiguration="" contract="TradeServiceLibrary.ITradeService" />
    


    Now my interest is create functions/procedures in WCF Service Library for this endpoints and a TradeClient1 to interact with msmqIntegrationBinding endpoint and TradeClient2 with netTcpBinding endpoint.

    Here MSMQ and Windows Service will be running all the time.

    1) The TradeClient1 sends message to MSMQ of Client1 using msmqIntegrationBinding.
    2) The message present in Client1 MSMQ will be forwarded to Server1 MSMQ (How this can be done?)
    3) Windows Service which is running on the Server1 will track at any time for any new messages sent by Client1 in Server1 MSMQ (Should I go for public queue or private queue?)
    4) If new message is found, it should check whether it is a duplicate message from client (To implement MessageQueueTransactionType.Automatic)
    5) If it is a new Message either Windows Service or Server1 MSMQ forwards the message to Client2 MSMQ over the network
    6) The MSMQ present in Client2 will receive message from Windows Service
    7) When TradeClient2 is up it should read messages from MSMQ and update accordingly.

    One last thing to mention...

    I would not like to go for Active Directory as we are only using LAN.

    Could you give any guidelines in proceeding this way!!


    Praveen
    • Edited by CPK_2011 Tuesday, August 11, 2009 9:02 AM
    Tuesday, August 11, 2009 8:31 AM

Answers

All replies

  • Hi Praveen,

    Regarding on the following things you mentioned:

    1) The TradeClient1 sends message to MSMQ of Client1 using msmqIntegrationBinding.
    2) The message present in Client1 MSMQ will be forwarded to Server1 MSMQ (How this can be done?)

    So the TradeClient1 send message to MSMQ on the same client1 machine via msmqIntegration endpoint. And you need a mechanism to forward the messsage from client1's MSMQ to server1's queue, correct? If so, why not directly let TradeClient1 send the message to server1's MSMQ?  If you want the message to be forwarded between client1's Queue and server1's Queue, you need another program to do so, you need to either have a background service which constantly pickup messge from client1's queue and send it to server1's queue, or make it another WCF service which copy message via a msmq binding.

    For the second question, I think a public queue will be better for other client's access.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Thursday, August 13, 2009 3:04 AM
  •      Thanks a million Steven.

         Yes, it would be better to send directly to Server MSMQ using Public Queues.

         But in my scenario, the Server may be down at any time. In that case it should atleast send to Client MSMQ

         Could you explain how transactions can be maintained to achieve this.


         



          

    Regards, Praveen
    Thursday, August 13, 2009 5:23 AM
  • Hi Praveen,

    So since your server may be down, you want your WCF client to send message to a msmq on client-side,correct? 

    If so,  just make that client queue as transactional(when you create it) so that your WCF or RAW msmq client can send message to it via transactional/reliable channel:
     

    #Queues in Windows Communication Foundation

    http://msdn.microsoft.com/en-us/library/ms731089.aspx

     

    #Previously, in MSMQ, WCF and IIS: Getting them to play nice:

    http://blogs.msdn.com/tomholl/archive/2008/07/14/msmq-wcf-and-iis-getting-them-to-play-nice-part-3.aspx


    if your client is using raw msmq api(system.messaging) to send the message, you can look for some msmq reference about how to send transactional message:

    http://www.codeproject.com/KB/dotnet/msmqpart2.aspx
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by CPK_2011 Friday, August 21, 2009 1:01 PM
    Monday, August 17, 2009 8:54 AM

  •  Hi Steven,

           I am sorry for late reply. 

           But here in transactions i need to explicity check record by record whether i am getting the messages in proper fashion or not. 

           The above links mention in general. But any detail info like tracking transaction id from client and server side simultaneously??

          I mean I want to maintain a table based on this transactions. Is it possible.

         Any help would be greatly appreciated.

        Thank you.
         
    Regards, Praveen
    Monday, August 17, 2009 9:33 PM
  • Hi Praveen,

    I'm not sure how you want to control and maintain the transaction. However, generally if you use the .NET 2.0 System.Transaction namespace API to create transaction scope for each operation, then the runtime automatically help scope the certain transaction and each TransactionScope can be specified explicitly so as not to impact other transactionScope. So we do not need to do further work inside to maintain transaction list. And after you finish the operation call, you can just commit the transaction scope which will be fine.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Friday, August 21, 2009 2:11 AM
  • Hi Steven,

             Thank you. I have got what you are saying.
    Regards, Praveen
    Friday, August 21, 2009 1:33 PM