@Override
    public void connect() throws IllegalStateException, IOException {
        if (isConnected()) {
            throw new IllegalStateException("Already connected");
        }

        try {
            connection = connectionFactory.newConnection();
        } catch (TimeoutException e) {
            throw new IllegalStateException(e);
        }
        channel = connection.createChannel();
    }
@Test
    public void shouldFailWhenGraphiteHostUnavailable() {
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("some-unknown-host");

        try (GraphiteRabbitMQ unavailableGraphite = new GraphiteRabbitMQ(connectionFactory, "graphite")) {
            unavailableGraphite.connect();
            failBecauseExceptionWasNotThrown(UnknownHostException.class);
        } catch (Exception e) {
            assertThat(e.getMessage()).contains("some-unknown-host");
        }
    }