Retrieving the MSMQ message

To use the Outgoing Service, your application needs to retrieve the messages from the queue. The default queue the Outgoing Services uses is .\private$\econnect_outgoing9. To develop applications that retrieve messages, add a reference to the System.Messaging assembly of the .NET framework. The basic procedure to retrieve a message from the queue is as follows:

  1. Create a message queue object.

    Instantiate a MessageQueue object. Use the path to the local outgoing queue .\private$\econnect_outgoing9. Populate the queue object’s Formatter property to allow the message to be deserialized. The following Visual Basic .NET example demonstrates these steps:

    Dim myQueue As New MessageQueue(".\private$\econnect_outgoing9")
    myQueue.Formatter = New ActiveXMessageFormatter
    1. Create a transaction object.

      The econnect_outgoing9 queue is a transactional queue. You must include a queue transaction object with your request. The following example creates the transaction object:

      Dim myTransaction As New MessageQueueTransaction
      1. Create a message object.

        Instantiate an object that will receive the message retrieved from the specified queue:

        Dim myMessage As New Message
        1. Retrieve a message.

          Use the object you created to retrieve a message from the queue. This example retrieves the first available message from the queue:

          myMessage = myQueue.Receive(myTransaction)
          1. Get the XML data from the message.

            The body of the message will contain a string. The string represents the XML document that describes the Microsoft Dynamics GP operation that triggered the message. The following example retrieves the string from an MSMQ message:

            Dim myDocument As [String] = CType(myMessage.Body, [String])