Question regarding commit/backout of a message using the pymqi module
andrew.arobert at gmail.com
Thu Jun 22 00:58:57 CEST 2006
Could someone help explain what I am doing wrong in
this code block?
This code block is an excerpt from a larger file that receives
transmitted files via IBM WebSphere MQSeries an drops it to the local
Transmission of the file works as designed but it has a flaw.
If the file cannot be created for whatever reason, the transmitted
message is lost.
What I am trying to do is ensure that a file transmit is considered
successful only after the created file's checksum matches.
If not, the code should treat it as an error and roll back the message
to MQSeries without a commit.
The basis for this should be around the pymqi.QueueManager class which
is named mq in the block listed below.
On execution, I get the traceback of:
Traceback (most recent call last):
File "M:\MQ\MQ\Scripts\receiver.py", line 269, in ?
File "M:\MQ\MQ\Scripts\receiver.py", line 109, in run
File "M:\MQ\MQ\Scripts\receiver.py", line 118, in connect
File "c:\python24\lib\site-packages\pymqi.py", line 738, in begin
raise MQMIError(rv, rv)
pymqi.MQMIError: MQI Error. Comp: 1, Reason 2121: WARNING:
Do you have any idea why this might be occurring?
self.qm_name = qm_name
self.queue_name = queue_name
# Will be set later
self.qm = None
self.message = None
Connect to queue manager
self.qm = mq.QueueManager(options.qmanager.upper() )
except mq.PYIFError, err:
Get a message from queue.
queue = mq.Queue(self.qm, self.queue_name)
pmo = mq.pmo(Options = CMQC.MQPMO_SYNCPOINT)
md = mq.md()
var = queue.get(self.message, md, pmo )
if e.reason != CMQC.MQRC_NO_MSG_AVAILABLE:
buff = StringIO(var)
tree = ElementTree(file=buff)
# Extract required elements and assign to local variables
key = "this should be a well-kept secret"
file_name = tree.find("dest").text
creation_time = tree.find("creation_time").text
contents = tree.find("contents").text
check = tree.find("checksum").text
#Decode temp file
original = file_encoder.decode(contents)
# Drop file to disk
if os.path.exists(file_name) is False:
mqevlog.event(sys.argv,"error","Output file path/name already
# Get checksum of newly created file
# Compare checksum of created file with value transmitted
if csums.checksum_compare(sys.argv,sum,check,file_name) == True:
received/transmitted files do not match")
Any help/insight you can provide on this would be greatly appreciated.
More information about the Python-list