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

class-id ActiveMQSample public final.

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()

  goback.
end method.

end class.
Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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.