How to Send a Message to an Apache ActiveMQ Queue 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::createQueue("SampleQueue")

  set prod to sess::createProducer(dest)

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

  invoke prod::send(msg)

  invoke conn::close()

end method.

end class.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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