Re: embedding openJMS into tomcat
Ken M <wgold-WNUMbkg7HQH83n0zhJamUgC/[email protected]>
| Newsgroups | gmane.comp.java.openjms.user |
|---|---|
| Message-ID | <[email protected]> |
TJ -
Embedding it isn't so hard. You just have to be able to pass OpenJMS
the location of the configuration file you would have used in the normal
standalone startup.
Here's a denatured version of what we do on servlet init().
...
JmsServer theJmsServer;
...
String configFile = config.getInitParameter("OpenJms.config");
// readable by the servlet's security manager. maybe none.
try
{
String PROVIDER_URLR = "tcp://" +
InetAddress.getByName("localhost").getHostAddress() + ":3035";
config.getServletContext().setAttribute("JMS_PROVIDER",
PROVIDER_URL);
}
catch (UnknownHostException e)
{
logger.log(Level.SEVERE, "Unknown Host in PROVIDER_URL.", e);
}
// Create and start the OpenJMS server
// All we can do is fire it off and let it go.
logger.info("Loading OpenJMS Server with config [" + configFile
+ "]");
try
{
theJMSServer = new JmsServer(configFile);
logger.info("OpenJMS Server instantiated, running init().");
theJMSServer.init(); // all of OpenJMS's startup work is
done in here.
}
catch (Throwable e)
{
logger.log(Level.SEVERE, "OpenJMS Server could not run.", e);
}
...
So when your Servlet init()s - the server starts. When tomcat or your
webapp dies, so does the JMS server.
In order to access and use the server - you would get the JNDI context
and interact normally using the context's PROVIDER_URL to create
Topic/QueueConnections etc.
Hope this helps.
Ken
TJ Greenier wrote:
> I also use OpenJMS with tomcat 5. I use an http connection and
> deployed the openjms tunnel servlet to my tomcat webapp. This worked
> very well for us.
>
> I do have a question though. Currently I start the openJMS server and
> tomcat servers seperately using each ones startup script. Has anyone
> started and stopped openJMS programmatically? if so, any
> suggestions? I want to put some code in a servlet that will start up
> openJMS when tomcat is started and shutdown openJMS when tomcat is
> shutdown. For my project this will be sufficient, because if tomcat
> is down then openjms can be down as well. Plus we are only connecting
> via http.
>
> Any ideas or thoughts are much appreciated.
>
> Thanks,
> TJ
>
> On 9/22/05, *Ken M* <wgold-WNUMbkg7HQH83n0zhJamUgC/[email protected]
> <mailto:wgold-WNUMbkg7HQH83n0zhJamUgC/[email protected]>> wrote:
>
> Stas -
>
> I use OpenJMS with Tomcat 5 with great results.
>
> I just embed the OpenJMS initialization into my webapp's servlet
> init()
> and presto chango - OpenJMS in Tomcat.
>
> I'm not sure if there's a way to make Tomcat use OpenJMS directly
> - as
> Tomcat doesn't really do anything by itself without a web
> application to
> control.
>
> OpenJMS is a perfect drop-in.
>
> Ken
>
>
> Stas Ostapenko wrote:
>
> >Hi !
> >
> >I'm wery interested in embedding openJMS into Tomcat.There is no docs
> >or some kind of tutorial how its can be done. I'm googling with no
> >results on this topic. Only some articles about using standalone
> >openJMS with Tomcat. Step by step tutorial will be simlpy great.
> >Is it possible to do something similar to Activemq +Tomcat
> integration
> >(http://activemq.codehaus.org/Tomcat) ?
> >
> >Plese help. Thanks.
> >Regards, Stas.
> >
> >
> >-------------------------------------------------------
> >SF.Net email is sponsored by:
> >Tame your development challenges with Apache's Geronimo App Server.
> >Download it for free - -and be entered to win a 42" plasma tv or
> your very
> >own Sony(tm)PSP. Click here to play:
> http://sourceforge.net/geronimo.php
> >_______________________________________________
> >openjms-user mailing list
> >[email protected]
> <mailto:[email protected]>
> >https://lists.sourceforge.net/lists/listinfo/openjms-user
> <https://lists.sourceforge.net/lists/listinfo/openjms-user>
> >
> >
> >
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App Server.
> Download it for free - -and be entered to win a 42" plasma tv or
> your very
> own Sony(tm)PSP. Click here to play:
> http://sourceforge.net/geronimo.php
> _______________________________________________
> openjms-user mailing list
> [email protected]
> <mailto:[email protected]>
> https://lists.sourceforge.net/lists/listinfo/openjms-user
>
>
--
----
The cause of America is, in a great measure,
the cause of all mankind. Many circumstances
have, and will arise, which are not local, but
universal, and through which the principles of
all lovers of mankind are affected, and in the
event of which, their affections are interested.
The laying a country desolate with fire and sword,
declaring war against the natural rights of all
mankind, and extirpating the defenders thereof
from the face of the earth, is the concern of
every man to whom nature hath given the power
of feeling; of which class, regardless of party
censure, is.
The author.
Philadelphia, Feb. 14, 1776.