/** * @throws Exception * @throws URISyntaxException */ private void startClient() throws Exception, URISyntaxException { clientTransport = TransportFactory.connect( new URI( "tcp://localhost:" + serverPort + "?trace=true&wireFormat.maxInactivityDuration=1000")); clientTransport.setTransportListener( new TransportListener() { public void onCommand(Object command) { clientReceiveCount.incrementAndGet(); if (clientRunOnCommand != null) { clientRunOnCommand.run(); } } public void onException(IOException error) { if (!ignoreClientError.get()) { LOG.info("Client transport error:"); error.printStackTrace(); clientErrorCount.incrementAndGet(); } } public void transportInterupted() {} public void transportResumed() {} }); clientTransport.start(); }
protected Transport createTransport() throws Exception { Transport transport = TransportFactory.connect( new URI("failover://(tcp://localhost:1234?transport.connectTimeout=10000)")); transport.setTransportListener( new TransportListener() { @Override public void onCommand(Object command) {} @Override public void onException(IOException error) {} @Override public void transportInterupted() {} @Override public void transportResumed() {} }); transport.start(); this.failoverTransport = transport.narrow(FailoverTransport.class); return transport; }
@Test public void testLocalhostPortSyntax() throws Exception { transport = TransportFactory.connect(new URI("failover://(tcp://localhost:1111/localhost:2111)")); transport.setTransportListener( new TransportListener() { @Override public void onCommand(Object command) {} @Override public void onException(IOException error) {} @Override public void transportInterupted() {} @Override public void transportResumed() {} }); failoverTransport = transport.narrow(FailoverTransport.class); transport.start(); }
@Test(timeout = 30000) @Ignore("Test fails on windows") public void testReconnectUnlimited() throws Exception { Transport transport = TransportFactory.connect( new URI( "failover://(tcp://0.0.0.0:61616)?useExponentialBackOff=false&reconnectDelay=0&initialReconnectDelay=0")); transport.setTransportListener( new TransportListener() { @Override public void onCommand(Object command) {} @Override public void onException(IOException error) {} @Override public void transportInterupted() {} @Override public void transportResumed() {} }); transport.start(); this.failoverTransport = transport.narrow(FailoverTransport.class); assertTrue( "no implicit limit of 1000", Wait.waitFor( new Wait.Condition() { @Override public boolean isSatisified() throws Exception { return failoverTransport.getConnectFailures() > 1002; } })); }