View Full Version : JMS example application
svsuresh
Feb 2nd, 2006, 01:05 AM
Hi,
i need JMS example.what are the requiements to write a complete JMS apllication.i have web server tomcat.what are the other jars requred to write a jms application.
let me kanow all required files to write my application
jstrachan
Feb 2nd, 2006, 01:48 AM
You could try downloading ActiveMQ
http://activemq.org/Download
and running the examples which contain all the jars you need...
http://activemq.org/Examples
Or try Sun's tutorial
http://java.sun.com/products/jms/tutorial/
svsuresh
Feb 2nd, 2006, 02:40 AM
hi,
is jndi proveder(broker) required for JMS or not.
without any broker who implementing the JMS can we run jms applications with tomcat server or not.
svsuresh
Feb 2nd, 2006, 11:35 PM
hi,Spring supports JMS support. what about provider for that. is JmsTemplate require any Jmf Provider connectionfactory or not. Is spring has own provider or not.how to use spring jms for the JMS implementations. what is the provider concept. i am using tomcat. how to setup for JMS with tomcat. how to set the context to see the connectionfactory in tomcat.
Please help to familiar JMS in spring.
jstrachan
Feb 3rd, 2006, 12:30 AM
hi,
is jndi proveder(broker) required for JMS or not.
without any broker who implementing the JMS can we run jms applications with tomcat server or not.
JMS does not require JNDI; you can configure JMS clients and a JMS broker in Spring (see ActiveMQ)
jstrachan
Feb 3rd, 2006, 12:33 AM
hi,Spring supports JMS support. what about provider for that. is JmsTemplate require any Jmf Provider connectionfactory or not. Is spring has own provider or not.how to use spring jms for the JMS implementations. what is the provider concept. i am using tomcat. how to setup for JMS with tomcat. how to set the context to see the connectionfactory in tomcat.
Spring's JMS support requires a JMS provider - yes the JmsTemplate requires a JMS ConnectionFactory).
For details of configuring Apache ActiveMQ in Spring see...
http://incubator.apache.org/activemq/Spring+Support
zwiglm
Jan 8th, 2007, 09:30 AM
Hi
I tried to set up the remoting tutorial from spring with jms (this one: http://www.springframework.org/docs/reference/remoting.html)
The problem i got with this simple example:
The main thread in my client keeps staying in wait() after using one of my remote methods on the server.
Anybody got an idea. I'd be glad.
Cheers,
Martin Z.
Dave Syer
Jan 8th, 2007, 09:47 AM
Did you try calling close() on your ApplicationContext when the client is finished? Often that is enough to free up resources in singletons and allow the VM to exit cleanly. If that works, create a JIRA issue and get someone to change the documentation.
zwiglm
Jan 8th, 2007, 10:02 AM
Thanks for the quick response.
There is no close() method for the Application Context.
Here's the code of my main method:
public static void main(String[] args) {
logger.info("Initializing client");
ApplicationContext ctx =
new ClassPathXmlApplicationContext(new String[]{"./client-appctx.xml", "./jms-setup.xml"});
UserService userService = (UserService) ctx.getBean("userService");
logger.info("Running client");
userService.addUser(new User("franz", "Franz Mayr", "frnz"));
// Thread never reaches next line of code here.
logger.info("All users: " + userService.findAllUsers());
logger.info("User Hinz: " + userService.findUserByLogin("hinz"));
logger.info("User Kunz: " + userService.findUserByLogin("kunz"));
logger.info("User ffff: " + userService.findUserByLogin("ffff"));
logger.info("Shutting down client");
}
Dave Syer
Jan 8th, 2007, 10:18 AM
ApplicationContext does not have the close method, but all the useful implementations of it do. You can cast your instance to ConfigurableApplicationContext to expose it.
zwiglm
Jan 8th, 2007, 10:34 AM
Again, thanks for the help.
I'll clarify:
public static void main(String[] args) {
logger.info("Initializing client");
ApplicationContext ctx =
new ClassPathXmlApplicationContext(new String[]{"./client-appctx.xml", "./jms-setup.xml"});
UserService userService = (UserService) ctx.getBean("userService");
logger.info("Running client");
//next line is reached
userService.addUser(new User("franz", "Franz Mayr", "frnz"));
//this next line and section is NEVER reached.
logger.info("All users: " + userService.findAllUsers());
logger.info("User Hinz: " + userService.findUserByLogin("hinz"));
logger.info("User Kunz: " + userService.findUserByLogin("kunz"));
logger.info("User ffff: " + userService.findUserByLogin("ffff"));
logger.info("Shutting down client");
}
I am sure I can't close AppContext before calling my service?!
Cheers,
Martin
Dave Syer
Jan 8th, 2007, 01:18 PM
No, but logging "Shutting down client" isn't going to do it either. Make the last line of your main ((ConfigurableApplicationContext )ctx).close(); and see what happens.
zwiglm
Jan 10th, 2007, 06:35 AM
@david_syer
Thanks for the well-intentioned help, but... that does not work.
Nothing happens.
The line where the ctx should be closed is never reached. I am starting to assume that there is a incompatibility between my spring and activemq versions.
Anyway. Cheers,
Martin
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.