• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Message Driven Servlet Problem

 
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have made Servlet with Message listener (I do not require MDB for that so no question why i am using servlet).

The code is following:



* in output i get Results

1) When i run servlet firstly then it showed proper output. Then if i will remove following code:
try {
Thread.sleep(Long.MAX_VALUE);
} catch (InterruptedException ex) {
Logger.getLogger(MessageConsumer.class.getName()).log(Level.SEVERE, null, ex);
}

then also it will show output correctly

2) When i change destinationname:
@Resource(mappedName = "jms/tConnectionFactoryTopic")
private ConnectionFactory connectionFactory;
@Resource(mappedName = "jms/MyTopic")
private Topic topic;
t is giving Messages for previous entries.

3) When i redeploy it and add Thread.Sleep then it will show messages for MyTopic

4) When i redeploy the Message Driven Servlet then too it does not show messages which were send during deploying

.
.
.

Kindly tell me how to manage all this properly without any Error.
 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello there,
Even if you do not want to use MDB you can use POJO that implements the MessageListener than servlet.
Servlet is not a very good fit because you need to hit the servlet to start your listener.
Also you should not fiddle with Threads inside the Servlet as it is already multi-threaded. That might be the reason you are seeing the behaviour you are explaining.
Hence even if you use a servlet, do not make attempt to sleep the thread or anything like that. By the way can you please let us know why you want to call Thread.sleep().

Regards,
Amit
 
Azrael Noor
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

Actually i need to handle multiple annotations which is not possible in single mdb.
i tried to do it through servlet.

I haven't studied POJO, thanks for telling that let me see wether it works.

I used thread.sleep because
when i hit servlet and it runs and does not listen to message.

I make servlet sleep first time, then it listen messages,
but after using first time if i remove thread.sleep
then it works fine(recieve messages without sleep)
but take entries of 1 connection factory only,
not work fine for multiple connection factories in single servlet. So Servlet and MDB both are not solving ma problem efficiently

let's see what POGO is. If you have any better solution do tell

Thank you for Replying
Azrael Noor
 
Azrael Noor
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No Need of It now.

Thank you, if anyone could add more information please
reply
    Bookmark Topic Watch Topic
  • New Topic