#176284 - 2007-05-15 06:40 PM
Creating Transactional Queues (MSMQ) in KiXtart
|
pearly
Getting the hang of it
Registered: 2004-02-04
Posts: 92
|
I'm having a tough time converting VB code into KiXtart. It has to do with the True constant value in VB that doesn't get recognized when I place alternative values -1 or 1.
Here is the VB Code:
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
ErrorHandler:
MsgBox "Error " + Hex(Err.Number) + " was returned." _
+ Chr(13) + Err.Description
End Sub
Without IsTransactional optional arg set to 'True', the sub-procedure creates non-transactional queues which I can create in KiXtart.
Here is the KiXtart code:
Function CreateMyXactQueue($strPathname)
Dim $qinfo
$qinfo = CreateObject("MSMQ.MSMQQueueInfo")
If @ERROR $CreateMyXactQueue = @ERROR EndIf
$qinfo.PathName = $strPathname
$qinfo.Label = "TestQueue"
;$qinfo.Create(1)
$qinfo.Create(-1)
If @ERROR $CreateMyXactQueue = @ERROR EndIf
EndFunction
I'm pretty sure 'True' in VB equals -1, but I've tried everything to make this work, but failed. If someone can shed some light on this, I'd appreciate it.
|
Top
|
|
|
|
#176292 - 2007-05-15 09:39 PM
Re: Creating Transactional Queues (MSMQ) in KiXtart
[Re: Shawn]
|
pearly
Getting the hang of it
Registered: 2004-02-04
Posts: 92
|
Shawn you rock!!!
I didn't know you can do the following
$TRUE = NOT 0
And yes there's a big difference between the code above and $TRUE = -1
Boolean vs. Long
Here's the final code:
Function CreateMyXactQueue($strPathname)
Dim $qinfo
Dim $TRUE
$TRUE = Not 0
$qinfo = CreateObject("MSMQ.MSMQQueueInfo")
If @ERROR $CreateMyXactQueue = @ERROR EndIf
$qinfo.PathName = $strPathname
$qinfo.Label = "TestQueue"
$qinfo.Create($TRUE)
If @ERROR $CreateMyXactQueue = @ERROR EndIf
EndFunction
|
Top
|
|
|
|
#176293 - 2007-05-15 09:42 PM
Re: Creating Transactional Queues (MSMQ) in KiXtart
[Re: Shawn]
|
pearly
Getting the hang of it
Registered: 2004-02-04
Posts: 92
|
If that doesn't work ... then its the following:
The VB code is using "named parameters" instead of positional paramaters - i forget the terminology but the point is that the Create method prolly takes more than one argument - and specifying it like this:
qinfo.Create IsTransactional:=True
allows you to pass the IsTransactional without actually knowing which "parm number" it is - it may be the first parm, or the second, or the last of many.
If this is the case - then you have to research the layout of the call, then dummy-out any parm before the one you want, like this:
$qinfo.Create(,,,$TRUE)
The trailing ones you can ignore. Hope this helps.
Thanks Shawn. Yes I looked in MSDN when I was first creating the function. This is what it says:
The Create method of the MSMQQueueInfo object creates a public or private queue based on the properties of the MSMQQueueInfo object. CopyCode imageCopy Code
Sub Create( _ [ ByRef IsTransactional As Variant ], _ [ ByRef IsWorldReadable As Variant ] _ )
Parameters
IsTransactional
[in, optional] Boolean. When True, it indicates that the queue is a transactional queue. All messages sent to a transactional queue or read from a transactional queue must be done as part of a transaction. The default is False.
IsWorldReadable
[in, optional] Boolean. When True, all members of the Everyone group can read the messages in the queue and its queue journal. When False, only the owner can read the messages. The default is False.
So it was the first argument of the method.
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 272 anonymous users online.
|
|
|