}
private AMQConnection createConnectionWithFailover() throws NamingException, JMSException
{
AMQConnection connection;
AMQConnectionFactory connectionFactory = (AMQConnectionFactory)getConnectionFactory("default");
ConnectionURL connectionURL = connectionFactory.getConnectionURL();
connectionURL.setOption(ConnectionURL.OPTIONS_FAILOVER, "singlebroker");
connectionURL.setOption(ConnectionURL.OPTIONS_FAILOVER_CYCLE, "2");
BrokerDetails details = connectionURL.getBrokerDetails(0);
details.setProperty(BrokerDetails.OPTIONS_RETRY, "200");
details.setProperty(BrokerDetails.OPTIONS_CONNECT_DELAY, "1000");
connection = (AMQConnection)connectionFactory.createConnection("admin", "admin");
connection.setConnectionListener(this);
return connection;
}