1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| try{
Context ictx = null;
QueueConnection conn = null;
Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY, IntialContext);
prop.put(fr.dyade.aaa.jndi2.client.NamingContextFactory.JAVA_HOST_PROPERTY, Host);
prop.put(fr.dyade.aaa.jndi2.client.NamingContextFactory.JAVA_PORT_PROPERTY, Port);
ictx = new InitialContext(prop);
QueueConnectionFactory qcf = (QueueConnectionFactory) ictx.lookup(
ConnectionFactory);
conn = qcf.createQueueConnection();
QueueSession session = conn.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
Queue queue = (Queue) ictx.lookup(Queue.toString());
conn.start();
javax.jms.TextMessage textMessage = session.createTextMessage();
javax.jms.QueueReceiver receiver = session.createReceiver(queue);
Boolean drap = true;
while(drap){
trans.begin();
textMessage = (TextMessage) receiver.receive();
String message = textMessage.getText();
textMessage.clearBody();
}
session.close();
conn.close();
}catch (Exception e){} |
Partager