1

I'm attempting to use MSMQ from Python using the win32com library, similar to this example. I'm able to put messages onto the queue, but in this case it's a transactional queue, so I need to create a transaction around the message send. Basically I'm attempting to do this VB example in python using COM.

I can't figure out how to get the transaction to happen:

import win32com.client
transaction=win32com.client.Dispatch("MSMQ.MSMQTransaction")
transaction.Begin()

gives:

AttributeError: MSMQ.MSMQTransaction.Begin

How do I begin the transaction? Am I on the right track?

Parand
  • 102,950
  • 48
  • 151
  • 186
  • For anyone needing the transaction, use `MSMQTransactionDispenser` and its `BeginTransaction` function, which returns an `MSMQTransaction` – mBardos Feb 10 '21 at 15:13

1 Answers1

4

You don't need an MSMQtransaction object to send a transactional message to a transactional queue.
Just set the transaction parameter to MQ_SINGLE_MESSAGE when you call Send().

Cheers
John Breakwell

John Breakwell
  • 4,667
  • 20
  • 25
  • 1
    Thanks John. Now I just have to figure out how to get a hold of the MQ_SINGLE_MESSAGE constant in python/com. You don't happen to know its numerical value by chance? - nevermind, found it: win32com.client.contants.MQ_SINGLE_MESSAGE – Parand Feb 24 '11 at 19:56