/** * @param threadFactory the thread factory. * @see com.rabbitmq.client.ConnectionFactory#setThreadFactory(java.util.concurrent.ThreadFactory) */ public void setThreadFactory(ThreadFactory threadFactory) { this.connectionFactory.setThreadFactory(threadFactory); }
/** * Set the {@link ThreadFactory} on the underlying rabbit connection factory. * @param threadFactory the thread factory. * @since 1.5.3 */ public void setConnectionThreadFactory(ThreadFactory threadFactory) { this.rabbitConnectionFactory.setThreadFactory(threadFactory); }
/** * Set the {@link ThreadFactory} on the underlying rabbit connection factory. * @param threadFactory the thread factory. * @since 1.5.3 */ public void setConnectionThreadFactory(ThreadFactory threadFactory) { this.rabbitConnectionFactory.setThreadFactory(threadFactory); }
/** * @param threadFactory the thread factory. * @see com.rabbitmq.client.ConnectionFactory#setThreadFactory(java.util.concurrent.ThreadFactory) */ public void setThreadFactory(ThreadFactory threadFactory) { this.connectionFactory.setThreadFactory(threadFactory); }
private Connection createConnection() throws KeyManagementException, NoSuchAlgorithmException, URISyntaxException, IOException, TimeoutException { final ConnectionFactory connectionFactory = new ConnectionFactory(); connectionFactory.setUri(this.uri); connectionFactory.setRequestedHeartbeat(this.heartbeat); // Use only daemon threads for connections. Otherwise, all connections would have to be explicitly // closed for the JVM to terminate. connectionFactory.setThreadFactory(new DaemonThreadFactory()); return connectionFactory.newConnection(); }
private Connection createConnection() throws KeyManagementException, NoSuchAlgorithmException, URISyntaxException, IOException, TimeoutException { final ConnectionFactory connectionFactory = new ConnectionFactory(); connectionFactory.setUri(this.uri); connectionFactory.setRequestedHeartbeat(this.heartbeat); // Use only daemon threads for connections. Otherwise, all connections would have to be explicitly // closed for the JVM to terminate. connectionFactory.setThreadFactory(new DaemonThreadFactory()); return connectionFactory.newConnection(); }
private Connection createConnection() throws KeyManagementException, NoSuchAlgorithmException, URISyntaxException, IOException, TimeoutException { final ConnectionFactory connectionFactory = new ConnectionFactory(); connectionFactory.setUri(this.uri); connectionFactory.setRequestedHeartbeat(this.heartbeat); // Use only daemon threads for connections. Otherwise, all connections would have to be explicitly // closed for the JVM to terminate. connectionFactory.setThreadFactory(new DaemonThreadFactory()); return connectionFactory.newConnection(); }
private Connection createConnection() throws KeyManagementException, NoSuchAlgorithmException, URISyntaxException, IOException, TimeoutException { final ConnectionFactory connectionFactory = new ConnectionFactory(); connectionFactory.setUri(this.uri); connectionFactory.setRequestedHeartbeat(this.heartbeat); // Use only daemon threads for connections. Otherwise, all connections would have to be explicitly // closed for the JVM to terminate. connectionFactory.setThreadFactory(new DaemonThreadFactory()); return connectionFactory.newConnection(); }
void connect() throws ControllerException { this.lock.lock(); try { if(connected()) { return; } final ConnectionFactory factory=new ConnectionFactory(); factory.setHost(this.brokerHost); factory.setPort(this.brokerPort); factory.setVirtualHost(this.virtualHost); factory.setThreadFactory(brokerThreadFactory()); factory.setExceptionHandler(new ConnectionManagerExceptionHandler(this)); this.connection = factory.newConnection(); createChannel(); } catch(IOException | TimeoutException e) { final String message = String.format("Could not connect to broker at %s:%s using virtual host %s",this.brokerHost,this.brokerPort,this.virtualHost); throw new ControllerException(this.brokerHost,this.brokerPort,this.virtualHost,message,e); } finally { this.lock.unlock(); } }
void connect() throws ControllerException { this.lock.lock(); try { if(connected()) { return; } final ConnectionFactory factory=new ConnectionFactory(); factory.setHost(this.brokerHost); factory.setPort(this.brokerPort); factory.setVirtualHost(this.virtualHost); factory.setThreadFactory(brokerThreadFactory()); factory.setExceptionHandler(new ConnectionManagerExceptionHandler(this)); this.connection = factory.newConnection(); createChannel(); } catch(IOException | TimeoutException e) { final String message = String.format("Could not connect to broker at %s:%s using virtual host %s",this.brokerHost,this.brokerPort,this.virtualHost); throw new ControllerException(this.brokerHost,this.brokerPort,this.virtualHost,message,e); } finally { this.lock.unlock(); } }
@Test public void testCreatesConnectionWithGivenFactory() throws Exception { com.rabbitmq.client.ConnectionFactory mockConnectionFactory = mock(com.rabbitmq.client.ConnectionFactory.class); doCallRealMethod().when(mockConnectionFactory).params(any(ExecutorService.class)); doCallRealMethod().when(mockConnectionFactory).setThreadFactory(any(ThreadFactory.class)); doCallRealMethod().when(mockConnectionFactory).getThreadFactory(); AbstractConnectionFactory connectionFactory = createConnectionFactory(mockConnectionFactory); ThreadFactory connectionThreadFactory = new CustomizableThreadFactory("connection-thread-"); connectionFactory.setConnectionThreadFactory(connectionThreadFactory); assertEquals(connectionThreadFactory, mockConnectionFactory.getThreadFactory()); }
static Connection create(final JocoteUrl url, final boolean automaticRecoveryEnabled) { try { final ConnectionFactory factory = new ConnectionFactory(); if (url.host != null) factory.setHost(url.host); if (url.port != null) factory.setPort(url.port); if (url.username != null) factory.setUsername(url.username); if (url.password != null) factory.setPassword(url.password); factory.setAutomaticRecoveryEnabled(automaticRecoveryEnabled); factory.setSharedExecutor(newSingleThreadExecutor()); factory.setShutdownExecutor(newSingleThreadExecutor()); factory.setThreadFactory(ClientConnectionFactory::newThread); factory.setExceptionHandler(new ExceptionHandler()); return factory.newConnection(); } catch (IOException | TimeoutException e) { throw new JocoteException(e); } }
void connect() throws ControllerException { this.write.lock(); try { if(this.connected) { return; } final ConnectionFactory factory=new ConnectionFactory(); factory.setHost(this.broker.host()); factory.setPort(this.broker.port()); factory.setVirtualHost(this.broker.virtualHost()); factory.setThreadFactory(brokerThreadFactory()); factory.setExceptionHandler(new BrokerControllerExceptionHandler(this)); this.connection = factory.newConnection(); createChannel(); } catch(IOException | TimeoutException e) { this.connected=false; final String message = String.format("Could not connect to broker at %s:%s using virtual host %s",this.broker.host(),this.broker.port(),this.broker.virtualHost()); throw new ControllerException(message,e); } finally { this.write.unlock(); } }
connectionFactory.setSocketConfigurator(rabbitMQConfiguration.getSocketConf()); connectionFactory.setSocketFactory(rabbitMQConfiguration.getFactory()); connectionFactory.setThreadFactory(rabbitMQConfiguration.getThreadFactory()); connectionFactory.setTopologyRecoveryEnabled(rabbitMQConfiguration.isTopologyRecovery()); try {
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; }