How to Send a Message to an Apache ActiveMQ Topic with Visual COBOL

class-id ActiveMQSample public.

method-id main public static.

local-storage section.

01 connFactory type javax.jms.ConnectionFactory.

01 conn type javax.jms.Connection.

01 sess type javax.jms.Session.

01 dest type javax.jms.Destination.

01 prod type javax.jms.MessageProducer.

01 msg type javax.jms.Message.

procedure division.
  set connFactory to new org.apache.activemq.ActiveMQConnectionFactory()

  set conn to connFactory::createConnection()

  set sess to conn::createSession(false, type javax.jms.Session::AUTO_ACKNOWLEDGE)

  set dest to sess::createTopic("SampleTopic")

  set prod to sess::createProducer(dest)

  set msg to sess::createTextMessage("Simples Assim")

  invoke prod::send(msg)

  invoke conn::close()

  goback.
end method.

end class.

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 , , , , , , Leave a comment

Leave a comment

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