Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

MessageListener in AQ JMS

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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("scdb02.de.db.com", "bcsftp", 1521, "thin");
queueConnection = queueConnectionFactory.createQueueConnection("BCSFTP", "bcsftp");
queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
queue=((AQjmsSession)queueSession).createQueue("TEST1");
//queue=queueSession.getQueue("THILAK_TEST_QUEUE");
System.out.println("queue: "+queue);
queueReceiver = queueSession.createReceiver(queue);
//queueReceiver = queueSession.createConsumer(queue);
System.out.println("queueReceiver Object Create: ");
sr = new SimpleQueueReceiver();
queueSession.setMessageListener(sr);
queueConnection.start();
System.out.println("AFTER Invoking TextListener(): "+queueSession .getMessageListener());

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

}
public static void main(String[] args) {

SimpleQueueReceiver sr = new SimpleQueueReceiver(1);
try{

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

}catch(Exception e)
{
System.out.println(e.getMessage());

}

}
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: " +
message.getClass().getName());
}
//queueSession.commit();
} catch (JMSException e) {
System.out.println("JMSException in onMessage(): " +
e.toString());
}

}
}

Oracle version is 9.2.0.6

Please let me know what is the problem with AQ JMS and how to resolve this issue..
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic