Visual Basic Code Example: Enforcing Target Journaling
Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista
This example provides a private Sub procedure that creates a queue that enforces target journaling. Target journaling is enforced by setting the MSMQQueueInfo.Journal property of the destination queue to MQ_JOURNAL.
Note
The MSMQQueueInfo.Journal property can be set when the queue is created, before calling MSMQQueueInfo.Create or later, before calling MSMQQueueInfo.Update. For an example of setting the journaling level of an existing destination queue, see Visual Basic Code Example: Setting MSMQQueueInfo.Journal.
In addition to setting the journaling level of the destination queue, this Sub procedure also sets the MSMQQueueInfo.JournalQuota property to specify the maximum size of the journal queue.
To enforce target journaling
Declare the MSMQQueueInfo variable for the queue.
Create a new MSMQQueueInfo object and assign it to the variable.
Set the MSMQQueueInfo.PathName property to the UNC or DNS path name of the queue.
Set optional queue properties. This example sets the following optional properties.
MSMQQueueInfo.Journal: Enforces target journaling.
MSMQQueueInfo.JournalQuota: Maximum size of queue journal.
MSMQQueueInfo.Label: Specifies label for queue.
Call MSMQQueueInfo.Create to create the queue.
Code Example
The following code example can be run on all versions of Message Queuing.
Sub EnforceTargetJournaling( _
strPathname As String, _
lJournalLevel As Long, _
lJournalQuota As Long _
)
Dim qinfo As MSMQQueueInfo
' Create a new MSMQQueueInfo object.
Set qinfo = New MSMQQueueInfo
' Specify the path name of the queue.
qinfo.PathName = strPathname
' Set optional queue properties.
qinfo.Label = "TestQueue"
qinfo.Journal = lJournalLevel
qinfo.JournalQuota = lJournalQuota
' Create queue.
On Error GoTo ErrorHandler
qinfo.Create
MsgBox "A queue that saves a copy of all messages removed from the queue was created."
Exit Sub
ErrorHandler:
MsgBox "Error " + Hex(Err.Number) + " was returned." _
+ Chr(13) + Err.Description
End Sub