File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes MessageListener in AQ JMS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "MessageListener in AQ JMS" Watch "MessageListener in AQ JMS" New topic

MessageListener in AQ JMS

bala.v reddy

Joined: Sep 13, 2005
Posts: 4

I am using AQ with JMS. when i run receiver with MessageListeners onMessage() method, it receives all messages which are already in Queue, but will not receive notification of any new messages that are enqueued at runtime.

here i am putting sample code

import javax.jms.*;
import oracle.jms.*;
public class SimpleQueueReceiver implements javax.jms.MessageListener
String queueName = null;
QueueConnectionFactory queueConnectionFactory = null;
QueueConnection queueConnection = null;
QueueSession queueSession = null;
Queue queue = null;
QueueReceiver queueReceiver = null;
ObjectMessage message = null;
Text1Listener queueListener = null;
SimpleQueueReceiversr =null;
SimpleQueueReceiver(int i)
try {
queueConnectionFactory = AQjmsFactory.getQueueConnectionFactory("", "bcsftp", 1521, "thin");
queueConnection = queueConnectionFactory.createQueueConnection("BCSFTP", "bcsftp");
queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
System.out.println("queue: "+queue);
queueReceiver = queueSession.createReceiver(queue);
//queueReceiver = queueSession.createConsumer(queue);
System.out.println("queueReceiver Object Create: ");
sr = new SimpleQueueReceiver();
System.out.println("AFTER Invoking TextListener(): "+queueSession .getMessageListener());

} catch (Exception e) {
System.out.println("Exception occurred: " +

public static void main(String[] args) {

SimpleQueueReceiver sr = new SimpleQueueReceiver(1);

synchronized(sr) {
while (true) {
try {
} catch (InterruptedException ie) {ie.printStackTrace();}

}catch(Exception e)


public void onMessage(Message message)
System.out.println("INSiDE Reading OnMessage(): " );
ObjectMessage msg = null;

try {
if (message instanceof ObjectMessage) {
msg = (ObjectMessage) message;
//System.out.println("Reading message: " + msg.getObject());
TestMessageType test=(TestMessageType)msg.getObject();
System.out.println("Reading message: You Got it ......" +test.getTestMessageType());
} else {
System.out.println("Message of wrong type: " +
} catch (JMSException e) {
System.out.println("JMSException in onMessage(): " +


Oracle version is

Please let me know what is the problem with AQ JMS and how to resolve this issue..
wood burning stoves
subject: MessageListener in AQ JMS
It's not a secret anymore!