factory.setRequestedHeartbeat(heartbeatTimeout); factory.setAutomaticRecoveryEnabled(true);
factory.setAutomaticRecoveryEnabled(this.automaticRecovery);
private void init() throws IOException { ConnectionFactory factory = new ConnectionFactory(); factory.setAutomaticRecoveryEnabled(true); factory.setHost(this.server); if (this.port > 0) factory.setPort(this.port); if (this.username != null && this.username.length() > 0) factory.setUsername(this.username); if (this.password != null && this.password.length() > 0) factory.setPassword(this.password); try { this.connection = factory.newConnection(); //Map<String, Object> map = this.connection.getServerProperties(); if (!this.connection.isOpen()) throw new IOException("no connection"); this.channel = connection.createChannel(); if (!this.channel.isOpen()) throw new IOException("no channel"); this.queues = new ConcurrentHashMap<>(); } catch (TimeoutException e) { throw new IOException(e.getMessage()); } }
/** * Set to true to enable amqp-client automatic recovery. Note: Spring AMQP * implements its own connection recovery and this is generally not needed. * @param automaticRecoveryEnabled true to enable. * @since 1.7.1 */ public void setAutomaticRecoveryEnabled(boolean automaticRecoveryEnabled) { this.connectionFactory.setAutomaticRecoveryEnabled(automaticRecoveryEnabled); }
/** * Set to true to enable amqp-client automatic recovery. Note: Spring AMQP * implements its own connection recovery and this is generally not needed. * @param automaticRecoveryEnabled true to enable. * @since 1.7.1 */ public void setAutomaticRecoveryEnabled(boolean automaticRecoveryEnabled) { this.connectionFactory.setAutomaticRecoveryEnabled(automaticRecoveryEnabled); }
public RabbitConnectionFactoryBean() { this.connectionFactory.setAutomaticRecoveryEnabled(false); }
public RabbitConnectionFactoryBean() { this.connectionFactory.setAutomaticRecoveryEnabled(false); }
@Bean public CachingConnectionFactory cf() throws Exception { ConnectionFactory cf = mock(ConnectionFactory.class); cf.setHost("localhost"); cf = spy(cf); willAnswer(i -> { this.connection = mock(Connection.class); willAnswer(ii -> { this.channel = mock(Channel.class); given(this.channel.isOpen()).willReturn(true); return this.channel; }).given(this.connection).createChannel(); return this.connection; }).given(cf).newConnection((ExecutorService) isNull(), anyString()); cf.setAutomaticRecoveryEnabled(false); CachingConnectionFactory ccf = new CachingConnectionFactory(cf); ccf.setSimplePublisherConfirms(true); return ccf; }
connFactory.setAutomaticRecoveryEnabled(true); connFactory.setRequestedHeartbeat(CloudBusGlobalProperty.RABBITMQ_HEART_BEAT_TIMEOUT); connFactory.setNetworkRecoveryInterval((int) TimeUnit.SECONDS.toMillis(CloudBusGlobalProperty.RABBITMQ_NETWORK_RECOVER_INTERVAL));
/** * Returns a rabbitmq-java connection factory instance with automatic recovery turned off by default. * This is necessary as rabbitmq-java > 4.0.0 enables it by default, resulting in two restored consumer in case of * connection resets. * * @return a com.rabbitmq.client.ConnectionFactory with automatic recovery disabled */ private ConnectionFactory makeConnectionFactory() { ConnectionFactory factory = new ConnectionFactory(); factory.setAutomaticRecoveryEnabled(false); return factory; }
private static com.rabbitmq.client.ConnectionFactory newRabbitConnectionFactory() { com.rabbitmq.client.ConnectionFactory connectionFactory = new com.rabbitmq.client.ConnectionFactory(); connectionFactory.setAutomaticRecoveryEnabled(false); return connectionFactory; }
private static com.rabbitmq.client.ConnectionFactory newRabbitConnectionFactory() { com.rabbitmq.client.ConnectionFactory connectionFactory = new com.rabbitmq.client.ConnectionFactory(); connectionFactory.setAutomaticRecoveryEnabled(false); return connectionFactory; }
/** * Returns a rabbitmq-java connection factory instance with automatic recovery turned off by default. * This is necessary as rabbitmq-java > 4.0.0 enables it by default, resulting in two restored consumer in case of * connection resets. * * @return a com.rabbitmq.client.ConnectionFactory with automatic recovery disabled */ private ConnectionFactory makeConnectionFactory() { ConnectionFactory factory = new ConnectionFactory(); factory.setAutomaticRecoveryEnabled(false); return factory; }
private com.rabbitmq.client.ConnectionFactory createRabbitConnectionFactory(AmqpServiceInfo serviceInfo) { com.rabbitmq.client.ConnectionFactory connectionFactory = new com.rabbitmq.client.ConnectionFactory(); connectionFactory.setAutomaticRecoveryEnabled(false); if (serviceInfo.getUris() != null && serviceInfo.getUris().size() > 0) { setConnectionFactoryUri(connectionFactory, serviceInfo.getUris().get(0)); } else { setConnectionFactoryUri(connectionFactory, serviceInfo.getUri()); } return connectionFactory; }
private com.rabbitmq.client.ConnectionFactory createRabbitConnectionFactory(AmqpServiceInfo serviceInfo) { com.rabbitmq.client.ConnectionFactory connectionFactory = new com.rabbitmq.client.ConnectionFactory(); connectionFactory.setAutomaticRecoveryEnabled(false); if (serviceInfo.getUris() != null && serviceInfo.getUris().size() > 0) { setConnectionFactoryUri(connectionFactory, serviceInfo.getUris().get(0)); } else { setConnectionFactoryUri(connectionFactory, serviceInfo.getUri()); } return connectionFactory; }
private com.rabbitmq.client.ConnectionFactory createRabbitConnectionFactory(AmqpServiceInfo serviceInfo) { com.rabbitmq.client.ConnectionFactory connectionFactory = new com.rabbitmq.client.ConnectionFactory(); connectionFactory.setAutomaticRecoveryEnabled(false); if (serviceInfo.getUris() != null && serviceInfo.getUris().size() > 0) { setConnectionFactoryUri(connectionFactory, serviceInfo.getUris().get(0)); } else { setConnectionFactoryUri(connectionFactory, serviceInfo.getUri()); } return connectionFactory; }
ConnectionFactory factory = new ConnectionFactory(); factory.setHost(getHostName()); factory.setUsername(getUserName()); factory.setPassword(getPassword()); factory.setAutomaticRecoveryEnabled(true); Connection connection = factory.newConnection();
protected ConnectionFactory createConnectionFactory() throws Exception { ConnectionFactory factory = new ConnectionFactory(); factory.setAutomaticRecoveryEnabled(false); factory.setUri(BROKER_URI); return factory; }
@Test public void setAddressesTwoHosts() throws Exception { ConnectionFactory mock = mock(com.rabbitmq.client.ConnectionFactory.class); doReturn(true).when(mock).isAutomaticRecoveryEnabled(); CachingConnectionFactory ccf = new CachingConnectionFactory(mock); ccf.setAddresses("mq1,mq2"); ccf.createConnection(); verify(mock).isAutomaticRecoveryEnabled(); verify(mock).setAutomaticRecoveryEnabled(false); verify(mock).newConnection(isNull(), aryEq(new Address[] { new Address("mq1"), new Address("mq2") }), anyString()); verifyNoMoreInteractions(mock); }
public RabbitConnectionProvider( String host, int port, String username, String password, String vhost ) { this.connectionFactory = new ConnectionFactory(); this.connectionFactory.setConnectionTimeout( 2000 ); this.connectionFactory.setVirtualHost( vhost ); this.connectionFactory.setHost( host ); this.connectionFactory.setPort( port ); this.connectionFactory.setUsername( username ); this.connectionFactory.setPassword( password ); this.connectionFactory.setAutomaticRecoveryEnabled( true ); this.connectionFactory.setTopologyRecoveryEnabled( true ); }