W/o Durability
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 cons type javax.jms.MessageConsumer. 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 cons to sess::createConsumer(dest) invoke conn::start() set msg to cons::receive() display msg invoke conn::close() goback. end method. end class.
W/ Durability
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 topic type javax.jms.Topic. 01 cons type javax.jms.MessageConsumer. 01 msg type javax.jms.Message. procedure division. set connFactory to new org.apache.activemq.ActiveMQConnectionFactory() set conn to connFactory::createConnection() invoke conn:setClientID("SampleClient") set sess to conn::createSession(false, type javax.jms.Session::AUTO_ACKNOWLEDGE) set topic to sess::createTopic("SampleTopic") set cons to sess::createDurableSubscriber(topic, "SampleSubscription") invoke conn::start() set msg to cons::receive() display msg invoke conn::close() goback. end method. end class.
Leave a comment