MQSeries based file transfers using the pymqi module

A

Andrew Robert

Hi everyone,


Has anyone developed a pymqi module based file transfer method for use
with WebSphere MQSeries v5.3?

If so, would it be possible to point me towards examples of how this was
done?

Any help that can be provided would be greatly appreciated.


Thanks
 
D

Dariusz Suchojad

Andrew said:
> Hi everyone,
Hello,

> Has anyone developed a pymqi module based file transfer method for use
> with WebSphere MQSeries v5.3?
>
> If so, would it be possible to point me towards examples of how this
> was done?

I'm not sure I understand your question. Webshpere MQ expects your code
to give it a stream of bytes, there's nothing file-specific in using
base WMQ so it's your application's job to read a file, put its contents
onto the desired queue, and to get it off the queue some time later.

If the code below is not what you need then feel free to ask a more
specific question :)

import pymqi as mq

# Queue manager name
qm_name = "M01"

# Listener host and port
listener = "127.0.0.1(1414)"

# Channel to transfer data through
channel = "SYSTEM.DEF.SVRCONN"

# Input/output queue name
queue_name = "Q01"

# Make some data
file_name = "C:\\sample.txt"
sample_data = "Hello from PyMQI."
open(file_name,"w").write(sample_data)

# Connect to queue manager
qm = mq.QueueManager(None)
qm.connectTCPClient(qm_name, mq.cd(), channel, listener)

# Put a message onto the queue
queue = mq.Queue(qm, queue_name)
data = open(file_name).read()
queue.put(data)

# Close the queue, queue.put has implicitly opened the queue for output
# so we can't use the same pymqi.Queue object for getting the messages
# off the queue
queue.close()

# Now get the message, queue.get will implicitly open the queue for
# input
queue = mq.Queue(qm, queue_name)
msg = queue.get()
queue.close()

# Here's the message contents
print msg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top