Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6998349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:24:01+00:00 2026-05-27T20:24:01+00:00

Can any one provide sample program to dequeue messages in Java? I want standalone

  • 0

Can any one provide sample program to dequeue messages in Java? I want standalone java program which will do this task.

Lets say Oracle ha enqueued messages using JMS_TEXT_MESSAGE a payload type in queue “myqueue” whose owner is “myowner” & now I want to dequeue these messages using Java. Can any one provide sample program in stand alone Java?

Thanks!


@Ratha, I tried your sample & I can browse through all the messages & it works perfect!

However, when I try to consume those messages, I thought they’ll get removed from the queue & display it to me through below line:

 System.out.println("MESSAGE RECEIVED " + msg.getText());

But instead, it gives me error on below line:

 MessageConsumer consumer = session.createConsumer(queue);

Exception in thread "main" java.lang.AbstractMethodError: oracle.jms.AQjmsSession.createConsumer(Ljavax/jms/Destination;)Ljavax/jms/MessageConsumer;
at OracleAQClient.consumeMessage(OracleAQClient.java:141)
at OracleAQClient.main(OracleAQClient.java:159)

Can you please help me how to fix this error?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:24:02+00:00Added an answer on May 27, 2026 at 8:24 pm

    You can right vendor specific or vendor neutral code..
    To dequeue the message, use following code block

     public static void consumeMessage(String user, String queueName) {  
      Queue queue;
      try {
       QueueConnection QCon = getConnection();  
       Session session = QCon.createQueueSession(false,Session.CLIENT_ACKNOWLEDGE);
       QCon.start();
       queue = ((AQjmsSession) session).getQueue(user, queueName);
       MessageConsumer consumer = session.createConsumer(queue);
       TextMessage msg = (TextMessage) consumer.receive();
       System.out.println("MESSAGE RECEIVED " + msg.getText());
    
       consumer.close();
       session.close();
       QCon.close();
      } catch (JMSException e) {  
       e.printStackTrace();
      }
     }
    

    I have written, these posts, which contain more detail code;

    http://vvratha.blogspot.com/2011/10/creating-queue-in-oracleaq.html

    http://vvratha.blogspot.com/2011/10/java-client-for-jndi-lookup-with-ojms.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can any one provide me full 2 mapping file which implements cascade delete. measn
Hopefully this is a simple one, but can anyone provide some simple c# code
I am trying to run the Task-Android-sample given at Google Api Java Client I
can any one tell me the details about below displayed control?can i arrange images
I have a FindFile routine in my program which will list files, but if
I want to dequeue the messages from Oracle AQ. Oracle is enqueuing data into
Can anyone provide some real examples as to how best to keep script files
Can anyone provide some pseudo code for a roulette selection function? How would I
Can anyone provide a clear explanation / example of what these functions do, and
Can anyone provide me with a link to good article about using Firebird.NET with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.