Remote journal problem - MessageQueue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gerhard Swart

    #1

    Remote journal problem - MessageQueue

    Hi all. I'm writing a queue browser that reads queues from a specified
    machine and then display the data that's on the queue. I am using the
    MessageQueue Class in .Net(C#).

    I get the problem that I can't read the journal private queue on a remote
    machine. I don't know if this is possible though. I have tried all the
    possible options but can't seem to get it to work. The code that I tried is:

    MessageQueue _mq = new MessageQueue( "FormatName:DIR ECT=OS:" +
    "RemoteMachine\ private$\icsis_ el_queue\JOURNA L$);

    Any help will be appreciated.

    Thanks in advance


  • Daniel Bass

    #2
    Re: Remote journal problem - MessageQueue

    you can only access a remote machine's public queues.
    private queues are for messages sent internally on a machine.

    Dan.

    "Gerhard Swart" <tester1234@mic rosoft.com> wrote in message
    news:%23MslpCJl DHA.2068@TK2MSF TNGP09.phx.gbl. ..
    Hi all. I'm writing a queue browser that reads queues from a specified
    machine and then display the data that's on the queue. I am using the
    MessageQueue Class in .Net(C#).

    I get the problem that I can't read the journal private queue on a remote
    machine. I don't know if this is possible though. I have tried all the
    possible options but can't seem to get it to work. The code that I tried is:

    MessageQueue _mq = new MessageQueue( "FormatName:DIR ECT=OS:" +
    "RemoteMachine\ private$\icsis_ el_queue\JOURNA L$);

    Any help will be appreciated.

    Thanks in advance



    Comment

    • Gerhard Swart

      #3
      Re: Remote journal problem - MessageQueue

      Thanks Daniel,

      Since I'm a bit new to .Net I'm still learning all the nitty gritties.
      In one of my previous applications I wrote using MSMQ2 COM component(VB6),
      the application picked up the remote private journal. Was the application
      suppose to
      be able to do that, because if not then I would maybe have to make some
      changes to the app.
      Do you maybe know why the MSMQ functionality differ from the MessageQueue
      functionality?

      Thanks in advance

      "Daniel Bass" <I'm really @ sick of spam> wrote in message
      news:%239IUh4Jl DHA.1284@TK2MSF TNGP09.phx.gbl. ..[color=blue]
      > you can only access a remote machine's public queues.
      > private queues are for messages sent internally on a machine.
      >
      > Dan.
      >
      > "Gerhard Swart" <tester1234@mic rosoft.com> wrote in message
      > news:%23MslpCJl DHA.2068@TK2MSF TNGP09.phx.gbl. ..
      > Hi all. I'm writing a queue browser that reads queues from a specified
      > machine and then display the data that's on the queue. I am using the
      > MessageQueue Class in .Net(C#).
      >
      > I get the problem that I can't read the journal private queue on a remote
      > machine. I don't know if this is possible though. I have tried all the
      > possible options but can't seem to get it to work. The code that I tried[/color]
      is:[color=blue]
      >
      > MessageQueue _mq = new MessageQueue( "FormatName:DIR ECT=OS:" +
      > "RemoteMachine\ private$\icsis_ el_queue\JOURNA L$);
      >
      > Any help will be appreciated.
      >
      > Thanks in advance
      >
      >
      >[/color]


      Comment

      • Daniel Bass

        #4
        Re: Remote journal problem - MessageQueue

        MSDN's definitions:

        private queue
        A queue registered on the local computer (not in the directory service) that
        typically cannot be located by other applications. Private queues have the
        advantage of no directory service overhead (faster to create, no latency,
        and no replication), and they can be created and deleted when the directory
        service is not working.

        public queue
        A queue registered in the directory service that can be located by any
        Message Queuing application. Public queues are persistent and their
        registration information can be backed up on the enterprise, making them
        good for long-term use.

        From this I deduced that the queues that are private are only accessed by
        the application that created them?

        I don't think you should specify the "private" sub path name when accessing
        a queue reading or writing...

        I've created a wrapper for reading and writing synchronously if you'd like
        to have a look.
        I've changed the example, and removed a few references to the rest of the
        app in which it resided.

        *************** *************** *************** *************** *******
        using System;
        using System.Windows. Forms;
        using System.Messagin g;
        using System.IO;
        using System.Threadin g;

        namespace BIF_Queues
        {
        /// <summary>
        /// InterfaceTypeMS MQ handles the message queues for MSMQ (version 2/3).
        /// </summary>
        public class MSMQWrapper
        {
        //
        // Thread Safe Wrapper...
        //

        //
        // member variables
        //

        private MessageQueue m_Queue;
        private bool m_bValid = false;
        public Valid
        {
        get
        {
        return m_bValid;
        }
        }


        //
        // constructor
        //

        public MSMQWrapper(str ing szServer, string szAddress)
        {
        string szQueuePath = szServer + "\\" + szAddress;
        try
        {

        if ( !MessageQueue.E xists( szQueuePath ) )
        {
        if ( MessageBox.Show ("The path you specified for a
        queue, '" + szQueuePath +"' does not exists. Do you wish to create it? (
        Pressing 'No' disregard this queue ).", "MSMQ Queue not found!",
        MessageBoxButto ns.YesNo ) == DialogResult.Ye s )
        {
        m_Queue = MessageQueue.Cr eate(szQueuePat h);
        m_bValid = true;
        }
        }
        else
        {
        m_Queue = new MessageQueue(sz QueuePath);
        m_bValid = true;
        }

        m_szAddress = szQueuePath;
        }
        catch ( Exception ex )
        {
        DebugLog.Instan ce().WriteLog( "InterfaceTypeM SMQ [" +
        szQueuePath + "] :- Exception Error. " + ex.Message );
        }
        }


        //
        // overridden methods
        //

        public override eResult Send( string data )
        {
        m_Queue.Send(da ta);
        return eResult.RES_SUC CESS;
        }

        public override void Receive( out string data )
        {
        data = "";
        while (Global.Instanc e().Listening)
        {
        try
        {
        System.Messagin g.Message msg = m_Queue.Receive (new
        TimeSpan(0,0,0, 0,500)); // throws an exception if the method times out

        // message was received, strip out the padded XML,
        should it exist
        string szBuffer = Global.Instance ().StreamToStri ng(
        msg.BodyStream );
        szBuffer = szBuffer.Replac e("<?xml
        version=\"1.0\" ?>\r\n<string>" , "");
        szBuffer = szBuffer.Replac e("</string>", "");
        szBuffer = szBuffer.Replac e("&lt;","<") ;
        szBuffer = szBuffer.Replac e("&gt;",">") ;

        // stick it back into a buffer
        data = szBuffer;
        return;
        }
        catch ( Exception )
        {
        // wait a litte, and carry on, all the exception
        // means is no message was found no the queue.
        Thread.Sleep(10 00);
        }
        }

        return;
        }

        }
        }


        *************** *************** *************** *************** ***********

        so all you'd need to do is something like this:

        MSMQWrapper myQueue = new MSMQWrapper ( "myComputer ", "remoteQueu e" );
        myQueue.Send ("Test Data");
        String receivedData;
        myQueue.Receive ( receivedData );

        Although it's synchronous, you can use it in multithreaded instances, so
        that one thread would have the task of simply looking at a queue for data,
        and processing that data it downloaded, while the rest of the program got on
        and did something else.

        Hope that helps.
        Dan.

        *************** *************** *************** *************** ***********
        "Gerhard Swart" <tester1234@mic rosoft.com> wrote in message
        news:%23yXGyiKl DHA.1764@tk2msf tngp13.phx.gbl. ..
        Thanks Daniel,

        Since I'm a bit new to .Net I'm still learning all the nitty gritties.
        In one of my previous applications I wrote using MSMQ2 COM component(VB6),
        the application picked up the remote private journal. Was the application
        suppose to
        be able to do that, because if not then I would maybe have to make some
        changes to the app.
        Do you maybe know why the MSMQ functionality differ from the MessageQueue
        functionality?

        Thanks in advance

        "Daniel Bass" <I'm really @ sick of spam> wrote in message
        news:%239IUh4Jl DHA.1284@TK2MSF TNGP09.phx.gbl. ..[color=blue]
        > you can only access a remote machine's public queues.
        > private queues are for messages sent internally on a machine.
        >
        > Dan.
        >
        > "Gerhard Swart" <tester1234@mic rosoft.com> wrote in message
        > news:%23MslpCJl DHA.2068@TK2MSF TNGP09.phx.gbl. ..
        > Hi all. I'm writing a queue browser that reads queues from a specified
        > machine and then display the data that's on the queue. I am using the
        > MessageQueue Class in .Net(C#).
        >
        > I get the problem that I can't read the journal private queue on a remote
        > machine. I don't know if this is possible though. I have tried all the
        > possible options but can't seem to get it to work. The code that I tried[/color]
        is:[color=blue]
        >
        > MessageQueue _mq = new MessageQueue( "FormatName:DIR ECT=OS:" +
        > "RemoteMachine\ private$\icsis_ el_queue\JOURNA L$);
        >
        > Any help will be appreciated.
        >
        > Thanks in advance
        >
        >
        >[/color]


        Comment

        Working...