super.setRequestedFrameMax(this.requestedFrameMax); super.setRequestedHeartbeat(this.requestedHeartbeat); super.setConnectionTimeout(this.connectionTimeout); super.setClientProperties(this.clientProperties);
factory.setConnectionTimeout(this.connectionTimeout);
/** * @param connectionTimeout the connection timeout. * @see com.rabbitmq.client.ConnectionFactory#setConnectionTimeout(int) */ public void setConnectionTimeout(int connectionTimeout) { this.connectionFactory.setConnectionTimeout(connectionTimeout); }
/** * @param connectionTimeout the connection timeout. * @see com.rabbitmq.client.ConnectionFactory#setConnectionTimeout(int) */ public void setConnectionTimeout(int connectionTimeout) { this.connectionFactory.setConnectionTimeout(connectionTimeout); }
public void setConnectionTimeout(int connectionTimeout) { this.rabbitConnectionFactory.setConnectionTimeout(connectionTimeout); }
public void setConnectionTimeout(int connectionTimeout) { this.rabbitConnectionFactory.setConnectionTimeout(connectionTimeout); }
connFactory.setRequestedHeartbeat(CloudBusGlobalProperty.RABBITMQ_HEART_BEAT_TIMEOUT); connFactory.setNetworkRecoveryInterval((int) TimeUnit.SECONDS.toMillis(CloudBusGlobalProperty.RABBITMQ_NETWORK_RECOVER_INTERVAL)); connFactory.setConnectionTimeout((int) TimeUnit.SECONDS.toMillis(CloudBusGlobalProperty.RABBITMQ_CONNECTION_TIMEOUT));
/** * Set the connection timeout, zero for infinite, for an individual connection attempt. * * @throws NullPointerException if {@code connectionTimeout} is null */ public ConnectionOptions withConnectionTimeout(Duration connectionTimeout) { factory.setConnectionTimeout((int) connectionTimeout.toMillis()); return this; }
/** * Set the connection timeout, zero for infinite, for an individual connection attempt. * * @throws NullPointerException if {@code connectionTimeout} is null */ public ConnectionOptions withConnectionTimeout(Duration connectionTimeout) { factory.setConnectionTimeout((int) connectionTimeout.toMillis()); return this; }
connectionFactory.setConnectionTimeout(60000); connectionFactory.setRequestedHeartbeat(10);
public void connect() throws IOException { final ConnectionFactory factory = new ConnectionFactory(); factory.setHost(hostname); factory.setPort(port); factory.setVirtualHost(vHost); // Authenticate? if (username != null && !username.isEmpty() && password != null && !password.isEmpty()) { factory.setUsername(username); factory.setPassword(password); } factory.setConnectionTimeout((int) connectTimeout.getMillis()); try { connection = factory.newConnection(); } catch (TimeoutException e) { throw new IOException("Timeout while opening new AMQP connection", e); } channel = connection.createChannel(); // It's ok if the queue or exchange already exist. channel.queueDeclare(queueName, true, false, false, null); channel.exchangeDeclare(exchangeName, queueType, false, false, null); channel.queueBind(queueName, exchangeName, routingKey); }
super.setRequestedFrameMax(this.requestedFrameMax); super.setRequestedHeartbeat(this.requestedHeartbeat); super.setConnectionTimeout(this.connectionTimeout); super.setClientProperties(this.clientProperties);
private static Connection openConnection(FullAddress address) throws IOException { Connection connection = null; if (ENABLE_DEBUG) { System.err.println("trying to connect to " + address); } ConnectionFactory connectionFactory = new ConnectionFactory(); connectionFactory.setHost(address.address.getHost()); connectionFactory.setPort(address.address.getPort()); connectionFactory.setUsername(address.username); connectionFactory.setPassword(address.password); connectionFactory.setVirtualHost(address.vhost); connectionFactory.setConnectionTimeout(CONNECTION_OPEN_TIMEOUT); // try to open the connection connection = connectionFactory.newConnection(); if (ENABLE_DEBUG) { System.err.println("connected to " + address); } return connection; }
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 ); }
connectionFactory.setConnectionTimeout(rabbitConnectionTimeoutMS); connectionFactory.setRequestedHeartbeat(rabbitRequestedHeartbeatInSeconds); connectionFactory.setHost(rabbitHost);
public RabbitMQCollector.Builder toBuilder() throws KeyManagementException, NoSuchAlgorithmException, URISyntaxException { final RabbitMQCollector.Builder result = RabbitMQCollector.builder(); ConnectionFactory connectionFactory = new ConnectionFactory(); if (concurrency != null) result.concurrency(concurrency); if (connectionTimeout != null) connectionFactory.setConnectionTimeout(connectionTimeout); if (queue != null) result.queue(queue); if (uri != null) { connectionFactory.setUri(uri); } else { if (addresses != null) result.addresses(addresses); if (password != null) connectionFactory.setPassword(password); if (username != null) connectionFactory.setUsername(username); if (virtualHost != null) connectionFactory.setVirtualHost(virtualHost); if (useSsl != null && useSsl) connectionFactory.useSslProtocol(); } result.connectionFactory(connectionFactory); return result; } }
private static Connection newConnection(RabbitMQOptions config) throws IOException, TimeoutException { ConnectionFactory cf = new ConnectionFactory(); String uri = config.getUri(); // Use uri if set, otherwise support individual connection parameters List<Address> addresses = null; if (uri != null) { try { cf.setUri(uri); } catch (Exception e) { throw new IllegalArgumentException("Invalid rabbitmq connection uri " + uri); } } else { cf.setUsername(config.getUser()); cf.setPassword(config.getPassword()); addresses = config.getAddresses().isEmpty() ? Collections.singletonList(new Address(config.getHost(), config.getPort())) : config.getAddresses(); cf.setVirtualHost(config.getVirtualHost()); } cf.setConnectionTimeout(config.getConnectionTimeout()); cf.setRequestedHeartbeat(config.getRequestedHeartbeat()); cf.setHandshakeTimeout(config.getHandshakeTimeout()); cf.setRequestedChannelMax(config.getRequestedChannelMax()); cf.setNetworkRecoveryInterval(config.getNetworkRecoveryInterval()); cf.setAutomaticRecoveryEnabled(config.isAutomaticRecoveryEnabled()); //TODO: Support other configurations return addresses == null ? cf.newConnection() : cf.newConnection(addresses); }
/** * Configures the connection factory supplied by dependency injection using the * connection configuration annotated at the given class. * * @param clazz The class annotated with the connection configuration. */ public void configureFactory(Class<?> clazz) { ConnectionConfiguration connectionConfiguration = resolveConnectionConfiguration(clazz); if (connectionConfiguration == null) { return; } connectionFactory.setHost(connectionConfiguration.host()); connectionFactory.setVirtualHost(connectionConfiguration.virtualHost()); connectionFactory.setPort(connectionConfiguration.port()); connectionFactory.setConnectionTimeout(connectionConfiguration.timeout()); connectionFactory.setRequestedHeartbeat(connectionConfiguration.heartbeat()); connectionFactory.setUsername(connectionConfiguration.username()); connectionFactory.setPassword(connectionConfiguration.password()); connectionFactory.setRequestedFrameMax(connectionConfiguration.frameMax()); }
private ConnectionOptions(ConnectionOptions options) { nioParams = options.nioParams; useNio = options.useNio; factory = makeConnectionFactory(); factory.setClientProperties(options.factory.getClientProperties()); factory.setConnectionTimeout(options.factory.getConnectionTimeout()); factory.setHost(options.factory.getHost()); factory.setPort(options.factory.getPort()); factory.setUsername(options.factory.getUsername()); factory.setPassword(options.factory.getPassword()); factory.setVirtualHost(options.factory.getVirtualHost()); factory.setRequestedChannelMax(options.factory.getRequestedChannelMax()); factory.setRequestedFrameMax(options.factory.getRequestedFrameMax()); factory.setRequestedHeartbeat(options.factory.getRequestedHeartbeat()); factory.setSaslConfig(options.factory.getSaslConfig()); factory.setSocketFactory(options.factory.getSocketFactory()); factory.setThreadFactory(options.factory.getThreadFactory()); factory.setMetricsCollector(options.factory.getMetricsCollector()); if (useNio) factory.useNio(); factory.setNioParams(nioParams); hosts = options.hosts; addresses = options.addresses; name = options.name; executor = options.executor; nioParams = options.nioParams; useNio = options.useNio; }
private ConnectionOptions(ConnectionOptions options) { nioParams = options.nioParams; useNio = options.useNio; factory = makeConnectionFactory(); factory.setClientProperties(options.factory.getClientProperties()); factory.setConnectionTimeout(options.factory.getConnectionTimeout()); factory.setHost(options.factory.getHost()); factory.setPort(options.factory.getPort()); factory.setUsername(options.factory.getUsername()); factory.setPassword(options.factory.getPassword()); factory.setVirtualHost(options.factory.getVirtualHost()); factory.setRequestedChannelMax(options.factory.getRequestedChannelMax()); factory.setRequestedFrameMax(options.factory.getRequestedFrameMax()); factory.setRequestedHeartbeat(options.factory.getRequestedHeartbeat()); factory.setSaslConfig(options.factory.getSaslConfig()); factory.setSocketFactory(options.factory.getSocketFactory()); factory.setThreadFactory(options.factory.getThreadFactory()); factory.setMetricsCollector(options.factory.getMetricsCollector()); if (useNio) factory.useNio(); factory.setNioParams(nioParams); hosts = options.hosts; addresses = options.addresses; name = options.name; executor = options.executor; nioParams = options.nioParams; useNio = options.useNio; }