/* * JBoss, Home of Professional Open Source. * Copyright 2009, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; import javax.jms.Connection; import javax.jms.ConnectionFactory; 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.InitialContext; import javax.naming.NamingException; /** * * @author rsvoboda@redhat.com */ public class TestAppAfterFailoverJMS { /** * @param args the command line arguments */ public static void main(String[] args) { Context context = null; Connection connection = null; try { Properties properties = new Properties(); properties.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); properties.setProperty("java.naming.provider.url", "jnp://127.0.0.2:1099"); properties.setProperty("java.naming.factory.url.pkgs", "org.jnp.interfaces.NamingContextFactory"); context = new InitialContext(properties); ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("/ConnectionFactory"); connection = connectionFactory.createConnection(); Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); session.close(); System.out.println("Done ...."); } catch (Exception e) { Logger.getLogger(TestAppAfterFailoverJMS.class.getName()).log(Level.SEVERE, null, e); } finally { if (connection != null) { try { connection.close(); } catch (JMSException ex) { Logger.getLogger(TestAppAfterFailoverJMS.class.getName()).log(Level.SEVERE, null, ex); } } if (context != null) { try { context.close(); } catch (NamingException ex) { Logger.getLogger(TestAppAfterFailoverJMS.class.getName()).log(Level.SEVERE, null, ex); } } } } }