Java Code Examples for com.rabbitmq.client.ConnectionFactory#useNio()
The following examples show how to use
com.rabbitmq.client.ConnectionFactory#useNio() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RabbitMQClient_4_x_IT.java From pinpoint with Apache License 2.0 | 5 votes |
@Test public void testPush_nio() throws Exception { ConnectionFactory connectionFactory = getConnectionFactory(); connectionFactory.setAutomaticRecoveryEnabled(false); connectionFactory.useNio(); testRunner.runPushTest(); }
Example 2
Source File: RabbitMQClient_4_x_IT.java From pinpoint with Apache License 2.0 | 5 votes |
@Test public void testPush_nio_autorecovery() throws Exception { ConnectionFactory connectionFactory = getConnectionFactory(); connectionFactory.setAutomaticRecoveryEnabled(true); connectionFactory.useNio(); testRunner.runPushTest(); }
Example 3
Source File: RabbitMQClient_4_x_IT.java From pinpoint with Apache License 2.0 | 5 votes |
@Test public void testPull_nio() throws Exception { ConnectionFactory connectionFactory = getConnectionFactory(); connectionFactory.setAutomaticRecoveryEnabled(false); connectionFactory.useNio(); testRunner.runPullTest(); }
Example 4
Source File: RabbitMQClient_4_x_IT.java From pinpoint with Apache License 2.0 | 5 votes |
@Test public void testPull_nio_autorecovery() throws Exception { ConnectionFactory connectionFactory = getConnectionFactory(); connectionFactory.setAutomaticRecoveryEnabled(true); connectionFactory.useNio(); testRunner.runPullTest(); }
Example 5
Source File: RabbitMQClient_5_x_IT.java From pinpoint with Apache License 2.0 | 5 votes |
@Test public void testPush_nio() throws Exception { ConnectionFactory connectionFactory = getConnectionFactory(); connectionFactory.setAutomaticRecoveryEnabled(false); connectionFactory.useNio(); testRunner.runPushTest(); }
Example 6
Source File: RabbitMQClient_5_x_IT.java From pinpoint with Apache License 2.0 | 5 votes |
@Test public void testPush_nio_autorecovery() throws Exception { ConnectionFactory connectionFactory = getConnectionFactory(); connectionFactory.setAutomaticRecoveryEnabled(true); connectionFactory.useNio(); testRunner.runPushTest(); }
Example 7
Source File: RabbitMQClient_5_x_IT.java From pinpoint with Apache License 2.0 | 5 votes |
@Test public void testPull_nio() throws Exception { ConnectionFactory connectionFactory = getConnectionFactory(); connectionFactory.setAutomaticRecoveryEnabled(false); connectionFactory.useNio(); testRunner.runPullTest(); }
Example 8
Source File: RabbitMQClient_5_x_IT.java From pinpoint with Apache License 2.0 | 5 votes |
@Test public void testPull_nio_autorecovery() throws Exception { ConnectionFactory connectionFactory = getConnectionFactory(); connectionFactory.setAutomaticRecoveryEnabled(true); connectionFactory.useNio(); testRunner.runPullTest(); }
Example 9
Source File: AMQPObservableQueue.java From conductor with Apache License 2.0 | 4 votes |
private ConnectionFactory buildConnectionFactory() { final ConnectionFactory factory = new ConnectionFactory(); // Get rabbitmq username from config final String username = config.getProperty( String.format(AMQPConstants.PROPERTY_KEY_TEMPLATE, AMQPConfigurations.PROPERTY_USERNAME), ConnectionFactory.DEFAULT_USER); if (StringUtils.isEmpty(username)) { throw new IllegalArgumentException("Username is null or empty"); } else { factory.setUsername(username); } // Get rabbitmq password from config final String password = config.getProperty( String.format(AMQPConstants.PROPERTY_KEY_TEMPLATE, AMQPConfigurations.PROPERTY_PASSWORD), ConnectionFactory.DEFAULT_PASS); if (StringUtils.isEmpty(password)) { throw new IllegalArgumentException("Password is null or empty"); } else { factory.setPassword(password); } // Get vHost from config final String virtualHost = config.getProperty( String.format(AMQPConstants.PROPERTY_KEY_TEMPLATE, AMQPConfigurations.PROPERTY_VIRTUAL_HOST), ConnectionFactory.DEFAULT_VHOST); if (StringUtils.isEmpty(virtualHost)) { throw new IllegalArgumentException("Virtual host is null or empty"); } else { factory.setVirtualHost(virtualHost); } // Get server port from config final int port = config.getIntProperty( String.format(AMQPConstants.PROPERTY_KEY_TEMPLATE, AMQPConfigurations.PROPERTY_PORT), AMQP.PROTOCOL.PORT); if (port <= 0) { throw new IllegalArgumentException("Port must be greater than 0"); } else { factory.setPort(port); } // Get connection timeout from config final int connectionTimeout = config.getIntProperty( String.format(AMQPConstants.PROPERTY_KEY_TEMPLATE, AMQPConfigurations.PROPERTY_CONNECTION_TIMEOUT), ConnectionFactory.DEFAULT_CONNECTION_TIMEOUT); if (connectionTimeout <= 0) { throw new IllegalArgumentException("Connection timeout must be greater than 0"); } else { factory.setConnectionTimeout(connectionTimeout); } final boolean useNio = config.getBoolProperty( String.format(AMQPConstants.PROPERTY_KEY_TEMPLATE, AMQPConfigurations.PROPERTY_USE_NIO), false); if (useNio) { factory.useNio(); } return factory; }
Example 10
Source File: ConnectionFactoryProducer.java From hammock with Apache License 2.0 | 4 votes |
@Produces @ApplicationScoped public ConnectionFactory createConnectionFactory(RabbitMQConfiguration rabbitMQConfiguration) { ConnectionFactory connectionFactory = new ConnectionFactory(); connectionFactory.setAutomaticRecoveryEnabled(rabbitMQConfiguration.isAutomaticRecovery()); connectionFactory.setClientProperties(rabbitMQConfiguration.getClientProperties()); connectionFactory.setConnectionTimeout(rabbitMQConfiguration.getConnectionTimeout()); connectionFactory.setExceptionHandler(rabbitMQConfiguration.getExceptionHandler()); connectionFactory.setHandshakeTimeout(rabbitMQConfiguration.getHandshakeTimeout()); connectionFactory.setHeartbeatExecutor(rabbitMQConfiguration.getHeartbeatExecutor()); connectionFactory.setMetricsCollector(rabbitMQConfiguration.getMetricsCollector()); connectionFactory.setHost(rabbitMQConfiguration.getHost()); connectionFactory.setNetworkRecoveryInterval(rabbitMQConfiguration.getNetworkRecoveryInterval()); if(rabbitMQConfiguration.isNio()) { connectionFactory.useNio(); connectionFactory.setNioParams(rabbitMQConfiguration.getNioParams()); } connectionFactory.setPassword(rabbitMQConfiguration.getPassword()); connectionFactory.setPort(rabbitMQConfiguration.getPort()); connectionFactory.setRequestedChannelMax(rabbitMQConfiguration.getRequestedChannelMax()); connectionFactory.setRequestedFrameMax(rabbitMQConfiguration.getRequestedFrameMax()); connectionFactory.setRequestedHeartbeat(rabbitMQConfiguration.getRequestedHeartbeat()); connectionFactory.setSaslConfig(rabbitMQConfiguration.getSaslConfig()); connectionFactory.setSharedExecutor(rabbitMQConfiguration.getSharedExecutor()); connectionFactory.setShutdownExecutor(rabbitMQConfiguration.getShutdownExecutor()); connectionFactory.setShutdownTimeout(rabbitMQConfiguration.getShutdownTimeout()); connectionFactory.setSocketConfigurator(rabbitMQConfiguration.getSocketConf()); connectionFactory.setSocketFactory(rabbitMQConfiguration.getFactory()); connectionFactory.setThreadFactory(rabbitMQConfiguration.getThreadFactory()); connectionFactory.setTopologyRecoveryEnabled(rabbitMQConfiguration.isTopologyRecovery()); try { connectionFactory.setUri(rabbitMQConfiguration.getUri()); } catch (Exception e) { throw new RuntimeException("Unable to populate URI ",e); } connectionFactory.setUsername(rabbitMQConfiguration.getUsername()); connectionFactory.setVirtualHost(rabbitMQConfiguration.getVirtualHost()); if(rabbitMQConfiguration.getSslContext() != null) { connectionFactory.useSslProtocol(rabbitMQConfiguration.getSslContext()); } return connectionFactory; }