List of usage examples for com.rabbitmq.client ConnectionFactory setPort
public void setPort(int port)
From source file:uk.ac.soton.itinnovation.experimedia.arch.ecc.amqpAPI.impl.amqp.AMQPConnectionFactory.java
public void connectToAMQPSSLHost() throws Exception { // Safety first if (amqpHostIP == null) throw new Exception("AMQP Host IP not correct"); if (amqpConnection != null) throw new Exception("Already connected to host"); ConnectionFactory amqpFactory = new ConnectionFactory(); amqpFactory.setHost(amqpHostIP.getHostAddress()); amqpFactory.setPort(amqpPortNumber); amqpFactory.useSslProtocol();/*from w w w . j av a 2 s . c o m*/ try { amqpConnection = amqpFactory.newConnection(); } catch (Exception ex) { throw new Exception("Could not create AMQP host SSL connection: ", ex); } }
From source file:uk.ac.soton.itinnovation.experimedia.arch.ecc.amqpAPI.impl.amqp.AMQPConnectionFactory.java
public void connectToVerifiedAMQPHost(InputStream keystore, String password) throws Exception { // Safety first if (amqpHostIP == null) throw new Exception("AMQP Host IP not correct"); if (amqpConnection != null) throw new Exception("Already connected to host"); if (password == null) throw new Exception("Password is null"); char[] trustPassphrase = password.toCharArray(); KeyStore tks = KeyStore.getInstance("JKS"); try {//w ww . ja va2 s .co m tks.load(keystore, trustPassphrase); } catch (Exception ex) { factoryLog.error("Had problems loading keystore: " + ex.getMessage()); throw ex; } TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); tmf.init(tks); SSLContext sslContext = SSLContext.getInstance("SSLv3"); sslContext.init(null, tmf.getTrustManagers(), null); ConnectionFactory amqpFactory = new ConnectionFactory(); amqpFactory.setHost(amqpHostIP.getHostAddress()); amqpFactory.setPort(amqpPortNumber); amqpFactory.useSslProtocol(sslContext); try { amqpConnection = amqpFactory.newConnection(); } catch (IOException ioe) { throw new Exception("Could not create secure AMQP host connection", ioe); } }
From source file:uk.org.openeyes.oink.hl7v2.test.Hl7ITSupport.java
License:Open Source License
protected static ConnectionFactory initRabbit(String host, int port, String uname, String pwd, String vhost) { ConnectionFactory factory = new ConnectionFactory(); factory.setHost(host);/*from w w w. ja v a 2 s. c o m*/ factory.setPort(port); factory.setUsername(uname); factory.setPassword(pwd); factory.setVirtualHost(vhost); return factory; }
From source file:uk.trainwatch.rabbitmq.RabbitConnection.java
License:Apache License
private void createConnection() throws IOException { if (connection != null) { close();/*w ww. j a va2 s . c o m*/ } LOG.log(Level.FINE, "building connection"); ConnectionFactory factory = new ConnectionFactory(); factory.setUsername(username); factory.setPassword(password); if (virtualHost != null) { factory.setVirtualHost(virtualHost); } factory.setHost(host); if (portNumber > 0) { factory.setPort(portNumber); } channels.clear(); LOG.log(Level.FINE, "creating connection"); try { connection = factory.newConnection(); } catch (TimeoutException ex) { throw new IOException(ex); } }
From source file:ws.ament.hammock.rabbitmq.ConnectionFactoryProducer.java
License:Apache License
@Produces @ApplicationScoped/*w w w. ja v a2 s .c o m*/ 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; }
From source file:zebrogamq.gamelogic.ChannelsManager.java
License:Open Source License
private ConnectionFactory getConnectionFactory(final GameLogicState state) { ConnectionFactory factory = new ConnectionFactory(); factory.setHost(Util.getRabbitMQProperties().getProperty("gameLogicBrokerHost")); factory.setUsername(state.login);/*from w w w . j av a 2 s . c o m*/ factory.setPassword(state.password); factory.setVirtualHost(state.virtualHost); factory.setPort(Integer.valueOf(Util.getRabbitMQProperties().getProperty("gameLogicBrokerPort", String.valueOf(factory.getPort())))); factory.setConnectionTimeout(CONNECTION_ESTABLISHMENT_TIMEOUT); // set the heartbeat value for the amqp connections // to avoid the keeping of obsolete consumers factory.setRequestedHeartbeat(Integer.valueOf(Util.getRabbitMQProperties() .getProperty("amqpConnectionHeartbeat", String.valueOf(factory.getRequestedHeartbeat())))); return factory; }