我正在尝试编写一个将消息发布到Queue的java客户端。我正在使用Java 7和RAD 8.5。 RAD抱怨某些课程无法解决。请帮我解决。
import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.directory.InitialDirContext;
import com.ibm.msg.client.jms.JmsConnectionFactory;
import com.ibm.msg.client.jms.JmsDestination;
public class JMS_JNDI_Queue_Producer {
private static String initialContextUrl = "my url";
private static String connectionFactoryFromJndi = "my connection factory";
private static String destinationFromJndi = "my destination";
public static void main(String[] args) {
// Variables
Connection connection = null;
Session session = null;
Destination destination = null;
MessageProducer producer = null;
try {
String contextFactory = "com.sun.jndi.ldap.LdapCtxFactory";
Hashtable<String, String> environment = new Hashtable<String, String>();
environment.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
environment.put(Context.PROVIDER_URL, initialContextUrl);
Context context = new InitialDirContext(environment);
System.out.println("Initial context found!");
// Lookup the connection factory
JmsConnectionFactory cf = (JmsConnectionFactory) context.lookup(connectionFactoryFromJndi);
// Lookup the destination
destination = (JmsDestination) context.lookup(destinationFromJndi);
// Create JMS objects
connection = cf.createConnection("mqclient","busclient");
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
producer = session.createProducer(destination);
// Create a message
long uniqueNumber = System.currentTimeMillis() % 1000;
TextMessage message = session.createTextMessage("JmsProducer: Your lucky number today is "
+ uniqueNumber);
connection.start();
System.out.println("JMS client connection started!");
producer.send(message);
System.out.println("Sent message:\n" + message);
producer.close();
System.out.println("Producer closed.");
session.close();
System.out.println("Session closed.");
connection.close();
System.out.println("JMS client connection closed.");
} catch (JMSException ex) {
ex.printStackTrace();
} catch (NamingException ne) {
ne.printStackTrace();
} catch (Exception ex){
ex.printStackTrace();
}
}
}
所以RAD抱怨它找不到类com.ibm.msg.client.jms.JmsConnectionFactory和com.ibm.msg.client.jms.JmsDestination。
我尝试添加websphere 7运行时以及我在其他论坛中阅读的几个jar。什么都没发生
请提出任何想法