• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JMS

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

Am new to JMS. Just now started to learn .

I need to know what are the technical requirements are need to write simple JMS Program.

At Present thisis my system requirements,

1) Jdk 1.5
2) Tomcat 5.5

3) Servlet 2.0
4) JSP 1.2



Can i implement JMS in tomcat or not ?

Do i need any Application server?
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can i implement JMS in tomcat or not ?

No. Apache Tomcat is simply a servlet container for serving up servlets and JSP pages.

In order to build a messaging application, you need a message server. Apache ActiveMQ is an open-source server that is user-friendly and very robust. You can find it at:

http://projects.apache.org/indexes/alpha.html

Good luck!
[ June 27, 2008: Message edited by: James Clark ]
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by kavitha vasu:
Do i need any Application server?




Yes You need an application server in order to use your JMS destinations (e.g. Queue or Topic). After you setup your ConnectionFactory and destinations, you can simply start using it in your application.

For Application servers you have access to different commercial and open-source AS such as Jboss Application Server, GlassFish, ActiveMQ, and etc.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An application server is not required. Two command-line Java programs can communicate using the JMS API and a message server.
 
kavitha vasu
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

where can i download message server?
 
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kavita,
Its true thatyou need the I have implemented JMS full life cycle in weblogic server 10.0. Weblogic workshop editor is the best editor to do that. In my application i created on JMs client file that will send the messages to the JMS server that i created on weblogic. the mappings of that server provided to the JMs Client program. Then i created one message driven bean and using annotations i provided the JMS server mappings to that bean.

Now when my client prog. sends messages to the JMS server on weblogic. The MDB gets called and receives the message.

I am giving you the code for JMS client file as below.
**********************

/* JMS Implementation by Vijay Jamadade
package com.dao;
import java.io.Serializable;
import java.util.Properties;

import javax.jms.Message;
import javax.jms.ObjectMessage;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueReceiver;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.naming.Context;
import javax.naming.InitialContext;

public class TestJMS {
// get Logging instance
// private static LoggerDelegate log = new LoggerDelegate();

// Declare variables
// private static JMSQueueManager jmsQueueManager;

private QueueConnection connection;

private QueueSession session;

private Queue inboundQueue;

private Queue outboundQueue;

private QueueReceiver receiver;

private QueueSender sender;

private QueueConnectionFactory connFactory;

private ObjectMessage ackMessage;

private ObjectMessage dataMessage;

private Properties properties;

private InitialContext initialContext;

// private BgApplicationSession applicationSession;

// private Vector<ObjectMessage> messageQueue;

private ObjectMessage messageFromQueue;

private boolean connectedToQueue = false;

private String inboundQueueName;

private String outboundQueueName;

private int sorterId;

private String appServerIP;

private String jmsPort;

private String className = null ;

public void connectToQueue() {
try {

System.out.println("b4 the getInitialContext ");

properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
weblogic.jndi.WLInitialContextFactory.class.getName());
properties.put(Context.PROVIDER_URL, "t3://localhost:7001");


final Context initialContext = new InitialContext(properties);
System.out.println("Got the getInitialContext ");

//set queue connection
System.out.println("b4 the Connection Factory");
connFactory = (QueueConnectionFactory) initialContext.lookup("weblogic.jms.ConnectionFactory");
connection = (QueueConnection) connFactory.createQueueConnection();
System.out.println("Got the Connection Factory");

// set session, false implies session is not transacted
session = connection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
System.out.println("Got the session");

// set the queues
inboundQueue = (Queue) initialContext.lookup("jms/JMSQueue" );
outboundQueue = (Queue) initialContext.lookup("jms/JMSQueue1" );
System.out.println("Got the Queue");

/*
// Set receiver
receiver = session.createReceiver(inboundQueue);
receiver.setMessageListener(new MessageListenerImpl());
*/

// set sender
sender = session.createSender(inboundQueue);

// start messaging receiving
connection.start();
// connection.setExceptionListener(new ExceptionListenerImpl());
connectedToQueue = true;
ObjectMessage om = session.createObjectMessage();
om.setObject((Serializable) new String("TEStingfromremote"));
om.setIntProperty("id", 1);
sender.send(om);
System.out.println("Sent message");
//log.info(className,"Connection to JMS Queue established");
receiver = session.createReceiver(outboundQueue);
Message message = receiver.receive();
System.out.println("Received message from the message bean "+message);

}catch (Exception e) {
System.out.println("Error Sent message"+e);
}
}


}

*****************************
 
Ranch Hand
Posts: 8946
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can just download Apache ActiveMQ server as suggested by James and send/receive JMS messages.No need to download app server.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic