Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Visual Basic Code Example: Creating a Transactional Queue

Visual Basic Code Example: Creating a Transactional Queue

This example provides a private function that creates a public or private transactional queue based on a given queue path name.

Public queues cannot be created if there is no connection to the directory service. This restriction applies to dependent client computers, independent client computers that are working offline, and Message Queuing servers that have routing services enabled (for MSMQ 1.0, these servers are referred to as FRS servers).

The following procedure shows how the private function creates a transactional queue.

To create a transactional queue

  1. Declare the MSMQQueueInfo variable for the queue.

  2. Create a new MSMQQueueInfo object and assign it to the variable.

  3. Set the MSMQQueueInfo.PathName property to the UNC or DNS path name of the queue.

    The following are examples of UNC path names that can be used to create public and private queues for the local computer.

    .\testqueue                  ' Public queue path name.
    .\PRIVATE$\testqueue         ' Private queue path name.
For Message Queuing dependent clients, the local computer is the client's supporting server.

  1. Set optional queue properties. This example also specifies the label of the queue using MSMQQueueInfo.Label.

  2. Call MSMQQueueInfo.Create with the IsTransactional parameter of MSMQQueueInfo.Create set to True.


This code example contains no version-specific Message Queuing calls.

Sub CreateMyXactQueue(
                      strPathname As String
  Dim qinfo As MSMQQueueInfo
  Set qinfo = New MSMQQueueInfo
  qinfo.PathName = strPathname
  qinfo.Label = "TestQueue"
  On Error GoTo ErrorHandler
  qinfo.Create IsTransactional:=True
  MsgBox "Created Queue."
  Exit Sub
  MsgBox "Error " + Hex(Err.Number) + " was returned." _
          + Chr(13) + Err.Description
End Sub
© 2015 Microsoft