This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes can I integrate JMS with Servlets??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "can I integrate JMS with Servlets???" Watch "can I integrate JMS with Servlets???" New topic
Author

can I integrate JMS with Servlets???

Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
Hi guys. I implemented an application using OpenJMS. I have a servlet that connects to the OpenJMS server and publishes the message(s). So it is basically integration with JMS + Tomcat.
Now I'm using J2EE reference implementation and i'm facing a bunch of problems. I'm planning to use MDB to handle my business logic when a message is published to the J2EE JMS server.
but... I have only seen examples of standalone applications. There's no example of how to integrate tomcat+servlets+JMS using J2EE. In fact, haven't found examples of this using any other application server..
has anyone experienced this?? any suggestion..?
thanks


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
Yes, integrating all of these things is possible.
One of the client projects that I've just worked on used BEA WebLogic 6.1 and utilised JSP/Servlets for the presentation and EJBs for business logic. There were certain parts of the application where messages were received by MDBs, and certain parts where session beans sent JMS messages in response to user actions from the presentation tier.
With the J2EE reference implementation, you get everything that you need to start building complete J2EE systems - including a copy of Tomcat that is a part of the server.
What sort of problems are you having?
Simon
Laurie Haischer
Greenhorn

Joined: Dec 18, 2001
Posts: 8
Originally posted by Simon Brown:
Yes, integrating all of these things is possible.
One of the client projects that I've just worked on used BEA WebLogic 6.1 and utilised JSP/Servlets for the presentation and EJBs for business logic. There were certain parts of the application where messages were received by MDBs, and certain parts where session beans sent JMS messages in response to user actions from the presentation tier.
With the J2EE reference implementation, you get everything that you need to start building complete J2EE systems - including a copy of Tomcat that is a part of the server.
What sort of problems are you having?
Simon

Is it possible for an individual developer to download and use BEA Weblogic 6.1 without having to buy a license. That is, is there a personal copy for development purposes only (no commercial usage) that is free (non-expiring)?
Laurie
Byron Estes
Ranch Hand

Joined: Feb 21, 2002
Posts: 313
Doesn't the problem you're having stem from the fact that Tomcat doesn't support MDB (Message Driven Beans) or EJB at all for that matter?
Apache does however have something (...I haven't used it or seen it used) to provide similar functionality in a servlet.
{begin cut/paste}
Package org.apache.commons.messagelet Description
This package provides the mechansim to deploy MessageListener beans in a servlet application server which are intialized and destroyed with a web-application as well as introducing MessageDrivenObjects which are MessageListeners which receive servlet-style lifecycle events and Messagelets which are servlets that process Messages.
So this package introduces the interface MessageDrivenObject which is a servlet equivalent of a Message Driven EJB which is part of the EJB 2.0 spec.
In addition this package provides support for Messagelets which are servlets used to process JMS messages. They reuse the same message listener beans infrastructure but dispatch JMS Messages to a servlet for further processing.
2 new interfaces are introduced, MessageletRequest which extends ServletRequest and MessageletResponse which extends ServletResponse which adds some extra JMS based semantics such as access to the Messenger which was used to receive the JMS Message..
{end cut/paste}
Link to Apache API
Let me know if this helps/how it works out.
Regards,
Byron Estes


Byron Estes<br />Sun Certified Enterprise Architect<br />Senior Consulant<br />Blackwell Consulting Services<br />Chicago, IL<br /><a href="http://www.bcsinc.com" target="_blank" rel="nofollow">www.bcsinc.com</a>
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
thank you guys...

Doesn't the problem you're having stem from the fact that Tomcat doesn't support MDB (Message Driven Beans) or EJB at all for that matter?

nope. As a matter of fact, i evaluated different app servers. tried to download weblogic but with no luck, always got corrupt files.
now I'm using forte for java EE, which supports EJB 2.0 (so it supports MDB).
I haven't done anything complex. I have a JSP form in which you can select a topic and publish a message. So my servlet only fetches the parameter topic (request.getParameter("topic")), connects to JMS and publish the message to that topic. It was working pretty ok with OpenJMS; but now that I'm using Forte for Java EE it doesn't even connect to JMS.
I think the problem is with the JNDI, because I was getting something like:
name JMS is not bound in this context.
Unfortunately, I was so yesterday that I deleted the whole servlet and started over again. I'm still not sure if you invoke JNDI this way.

I was able to run the MDB examples using the deploytool. but those are only standalone clients. No examples of servlets at all.
I'll try to recover my servlet and post it here..
thanks again
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
I've tried to reconstruct my servlet and it looks like this:

I'm just checking if I can connect to jms and send a message to my queue (jms/MyQueue).
the error is:
Marking servlet Publisher as unavailable
2002-07-10 16:07:00 StandardWrapperValve[Publisher]: Servlet Publisher is currently unavailable
why does this happen??
seshu kumar
Greenhorn

Joined: Jun 13, 2002
Posts: 23
you can use JBoss. Servlets/JMS/MDB works fine in JBoss.
JBoss comes with its own message Queue implementation. I havent tried it with external queue. Full Documentation on the latest version is not available as yet, so you would need some help from people who have done it before.
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
thanks for your suggestion... I know these guys at JBoss get more than 100.000 downloads per month, but I wonder how many of those downloads are really used. I have downloaded it many times but it really lacks of documentation, so the learning curve gets even worst..
and yeah, you can buy the documentation, I'd do it, but I heard that it is aimed for people that can look at the JBoss source code and understand it in couple of minutes... I'm not that good yet , time is what I need to become a guru.
So, why is this
Servlet Publisher is currently unavailable
happening ?? ...
thankkksssss
Byron Estes
Ranch Hand

Joined: Feb 21, 2002
Posts: 313
Food for thought...
It doesn't matter if the IDE your using supports MDB if the application server you are running in doesn't...
Maybe I'm way off on this one, I use WebSphere most of the time, but to my knowledge Tomcat will not support what you want to do using MDB at this time.
Byron Estes
 
 
subject: can I integrate JMS with Servlets???
 
Similar Threads
how efficient are threadds for sending mails??
a question about JMS + MDB..
http error 500 ServletException: Cannot allocate servlet instance...
how to use JMS application using tomcat
Getting Tomcat to recognize directory