How to Receive a Message from an Apache ActiveMQ Queue with Jython

from javax.jms import Session

from org.apache.activemq import ActiveMQConnectionFactory

connFactory = ActiveMQConnectionFactory()

conn = connFactory.createConnection()

sess = conn.createSession(False, Session.AUTO_ACKNOWLEDGE)

dest = sess.createQueue('SampleQueue')

cons = sess.createConsumer(dest)

conn.start()

msg = cons.receive()

print(msg)

conn.close()

Published by:

Fernando Ribeiro

Experienced tech executive with a 24-year track record in enterprise computing. Leading AWS's professional services application modernization division in Brazil. He's held diverse roles including management, solutions architecture, sales consultancy, and full-stack development at major players like Oracle, Red Hat, and IBM. Fernando also contributes to open source and writes about emerging technologies. The views expressed here are his own and do not necessarily reflect the views of AWS.

Categories SoftwareTags , , , , , , 2 Comments

2 thoughts on “How to Receive a Message from an Apache ActiveMQ Queue with Jython”

  1. Do you know how I can install the javax and org libraries to execute this script? pip install doesn’t work and I can’t find the anywhere.

  2. You can download them from Maven Central or other Java library repositories.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.