Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Transaction usage invalid on sending to Transactional queues

591 views
Skip to first unread message

David Worsham

unread,
Oct 31, 2002, 8:59:56 AM10/31/02
to
Any attempt to post a message to a transactional queue results in the the
following exception:

"System.Messaging.MessageQueueException: The transaction usage is invalid.
at System.Messaging.MessageQueue.SendInternal(Object obj,
MessageQueueTransaction internalTransaction, MessageQueueTransactionType
transactionType)
at System.Messaging.MessageQueue.Send(Object obj, MessageQueueTransaction
transaction)
at QueuePost.QPost.sendTestMessage(String sQue, String strLabel, String
strBody) "

I have tried every usage variation I can think of for
MessageQueueTransaction (including not using it all), to no avail. Any
insights would be greatly appreciated. The code follows:

Public Sub sendTestMessage(ByVal sQue As String, ByVal strLabel As String,
ByVal strBody As String)
Dim oQue As New Messaging.MessageQueue()
Dim oMessage As New Messaging.Message()

oQue.MachineName = "<machinename>"
oQue.QueueName = sQue
Try
If oQue.Transactional Then
Dim objTxn as New MessageQueueTransaction()
objTxn.Begin()
oQue.Send(strLabel, strBody)
objTxn.Commit()
Else
oQue.Send(strLabel, strBody)
strResult = "Succeeded"
End If
Catch e As Messaging.MessageQueueException
strResult += e.Message & e.StackTrace
Finally
lblQueueResult.Text = strResult
End Try

frmQueueConfirmation.Visible = True
End Sub

Doron Juster [MS]

unread,
Oct 31, 2002, 11:47:02 AM10/31/02
to
Overloads Public Sub Send( _
ByVal obj As Object, _
ByVal label As String, _
ByVal transaction As MessageQueueTransaction _
)

On the send method, pass the transaction object as the third parameter.
In your code, you're doing a non-transactional send.

Thanks, Doron

--
This posting is provided "AS IS" with no warranties, and confers no rights.


"David Worsham" <dwor...@stewart.com> wrote in message
news:OBwTbWOgCHA.212@tkmsftngp12...

David Worsham

unread,
Oct 31, 2002, 1:04:54 PM10/31/02
to
Sorry, bad version of the code (I've edited it several times).

I am using the following and still receiving the error (double-checked the
fact that the queue is public and transactional, too):

If oQue.Transactional Then

Dim objBW As New BinaryWriter(New MemoryStream())

Dim objSR As New StreamReader(strFilePath)

Dim objTxn As New MessageQueueTransaction()

objBW.Write(objSR.ReadToEnd())

oMessage.BodyStream = objBW.BaseStream

oMessage.Label = "Test Message"

oQue.Send(oMessage, objTxn)

objBW.Close()

objSR.Close()

End If


"Doron Juster [MS]" <Dor...@Microsoft.com> wrote in message
news:OK6ZyzPgCHA.2620@tkmsftngp09...

David Worsham

unread,
Oct 31, 2002, 4:22:45 PM10/31/02
to
For some reason, switch to an ActiveXMessageFormatter instead of the default
XMLMessageFormatter did the trick. Thanks for the help.

"David Worsham" <dwor...@stewart.com> wrote in message

news:eEXvTfQgCHA.1960@tkmsftngp12...

0 new messages