• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Java Message Service (JMS) - How to sent the MDB onMessage() method's message to HttpServlet

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am creating a web chat application using JMS and MDB as a Message Listener.

I am sending a TextMessage to a QUEUE from a HttpServlet
I have one Message Driven Bean listening to the Queue.When I send the message MDB automatically recieves the message in onMessage() method and getting printed.. so far good.

BUT now i need to display the message in an jsp page when ever the onMessage() method triggers.

Here is my MDB Class

package com.chat.mdb;

import java.io.IOException;
import javax.jms.JMSException;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.GetMethod;

public class ChatBean implements javax.ejb.MessageDrivenBean,
javax.jms.MessageListener {

private javax.ejb.MessageDrivenContext messageContext = null;

public ChatBean() {
}

public void setMessageDrivenContext(
javax.ejb.MessageDrivenContext messageContext)
throws javax.ejb.EJBException {
this.messageContext = messageContext;
}

public void ejbCreate() {
//no specific action required for message-driven beans
}

public void ejbRemove() {
messageContext = null;
}

public void onMessage(javax.jms.Message message) {
System.out.println("Message Driven Bean - Message : \n" + message);
}}


In the above highlighted code i need to take this message to the servlet
to display the message in jsp.

Any help is appreciated.
Regards,
ved
 
author & internet detective
Posts: 41967
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ved,
That doesn't make sense. A servlet needs to get a request from the user in order to return a response.

It sounds like you want a user with a browser open to know when a message is processed. You could have onMessage set a flag that the servlet can read. Then the web page can poll to see if onMessage has happened yet.
 
ved dixit
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Basically what i want to do is, i want to get the message which is received on OnMessage method of MDB.

I have One servlet which takes the message from JSP page, forwards to a servlet, servlet is the message producer
which sends the Message to the JMS queue.

I want some kind of mechanism in which My bean will forward the message to the Servlet so that i can display that message
on my JSP page for the web-based chat application.

Actually i have tried to solve this issue and have spent almost 1 week, but no luck so far

If anyone can provide that exactly how can i achieve my goal, that would be really awesome !!

Looking for your help desperately !!!

Thanks in advance.
ved
 
Let's go to the waterfront with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic