Message Driven Beans & Oracle AQ

I’ve followed the chapter “Interoperating with Oracle AQ JMS” in order to integrate Oracle Streams Advanced Queuing (AQ) with Weblogic. All is working properly now, but I’ve had some problems programming a Message Driven Bean (MDB) which consumes messages enqueued by a PL/SQL procedure, so I would like to specify the minimum configuration properties you need to deploy this type of bean, apart from the queue name, of course.

The first one is the destination type for the MDB destination, which  should be configured to either: javax.jms.Queue or javax.jms.Topic, and the second one is the connection factory JNDI name that you’ve configured on Weblogic. Here you have a basic example:

@MessageDriven(mappedName = "aqjms/TestTopicQ",
               activationConfig = {
   @ActivationConfigProperty(propertyName = "destinationType", 
                             propertyValue = "javax.jms.Topic")})
@MessageDestinationConfiguration(connectionFactoryJNDIName = "aqjms/TestTopicCF")
public class TestMDB implements MessageListener {
    static final Logger logger = LoggingHelper.getServerLogger();

    public void onMessage(Message message) {
        TextMessage msg = null;

        try {
            if (message instanceof TextMessage) {
                msg = (TextMessage) message;
      "MESSAGE BEAN: Message received: " + msg.getText());
            } else {
                logger.warning("Message of wrong type: " + 
        } catch (JMSException e) {
            logger.severe("TestMDB.onMessage: JMSException: " + e.toString());
        } catch (Throwable te) {
            logger.severe("TestMDB.onMessage: Exception: " + te.toString());



3 Comments on “Message Driven Beans & Oracle AQ”

  1. Deepak Jain says:

    Really good article. Short and sweet. I am facing a challenge though in the same scenario. I am able to enqueue the message using PLSQL and MDB is picking it up and processing. But somehow same message is not getting removed from Oracle Queue table. It will be really helpful if you can shed some light on it.

    • fcosfc says:

      Thank you very much for your kind comment. I can only imagine the situation you describe if you have a topic with another subscriber active (in addition to the MDB one) which is not dequeuing its messages. In that situation, and without a message expiration time, Oracle keeps the messages within the queue table. Hope this response helps!

      • Deepak Jain says:

        Thanks for the response. We removed the other subscriber. Testing with one subscriber and still after completion of MDB, Messages are still in oracle AQ with state as 0. My understanding is if messages are processed, it should not expired(move to exception queue). Once processed by MDB it should get dequeued or atleast state should change to something else.
        Am I missing anything configuration here? Any suggestion will really help.

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