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);
}
}
}
*****************************