Hi,
Here is an example of code using JMS API.It is easy. You can find a lot of code through internet that are more complet.
I coud
test it successfully with a client Linux with JNDI. But I don't know how to test it with a client windows because Windows doesn't accept a .bindings file generated by JMSAdmin tools from Linux.
How to solve it ?
public static final
String INITIAL_CONTEXT_FACTORY = "com.sun.jndi.fscontext.RefFSContextFactory";
public static final String PROVIDER_URL = "file:/var/mqm";
public static final String SECU = "none";
public static final String QUEUE_CONNECTION_FACTORY = "DEVQCF";
public static final String QUEUE = "MYQUEUE";
Hashtable env;
InitialContext context;
QueueConnectionFactory qcf = null;
QueueConnection connection;
Queue queue;
env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
env.put(Context.PROVIDER_URL, PROVIDER_URL);
//env.put(Context.SECURITY_AUTHENTICATION,SECU);
boolean useJNDI = false;
try {
if( useJNDI ) {
System.out.println("useJNDI");
context = new InitialContext(env);
qcf = (javax.jms.QueueConnectionFactory) context.lookup (QUEUE_CONNECTION_FACTORY);
}
//Groupe mqs
connection = qcf.createQueueConnection("usre","password");
System.out.println("connection reussie1");
connection.start();
System.out.println("connection reussie2");
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
queue = session.createQueue("FMD_RCV");
//Envoie de message
MessageProducer sender = session.createProducer(queue);
sender.close();
session.close();
connection.close();