super.setPort(this.port); super.setUsername(this.username); super.setPassword(this.password); super.setVirtualHost(this.virtualHost); if (this.uri != null) {
factory.setPassword(password);
factory.setVirtualHost(this.virtualHost); factory.setUsername(this.username); factory.setPassword(this.password);
cf.setPort(Integer.parseInt(context.getProperty(PORT).evaluateAttributeExpressions().getValue())); cf.setUsername(context.getProperty(USER).evaluateAttributeExpressions().getValue()); cf.setPassword(context.getProperty(PASSWORD).getValue());
public RabbitmqProducer(MaxwellContext context) { super(context); exchangeName = context.getConfig().rabbitmqExchange; props = context.getConfig().rabbitmqMessagePersistent ? MessageProperties.MINIMAL_PERSISTENT_BASIC : null; ConnectionFactory factory = new ConnectionFactory(); factory.setHost(context.getConfig().rabbitmqHost); factory.setPort(context.getConfig().rabbitmqPort); factory.setUsername(context.getConfig().rabbitmqUser); factory.setPassword(context.getConfig().rabbitmqPass); factory.setVirtualHost(context.getConfig().rabbitmqVirtualHost); try { this.channel = factory.newConnection().createChannel(); if(context.getConfig().rabbitmqDeclareExchange) { this.channel.exchangeDeclare(exchangeName, context.getConfig().rabbitmqExchangeType, context.getConfig().rabbitMqExchangeDurable, context.getConfig().rabbitMqExchangeAutoDelete, null); } } catch (IOException | TimeoutException e) { throw new RuntimeException(e); } }
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()); } }
public static void main(String[] args) { try { ConnectionFactory factory = new ConnectionFactory(); factory.setUsername("guest"); factory.setPassword("guest"); factory.setHost("60.205.191.82"); factory.setPort(5672); Connection conn = factory.newConnection(); Channel channel = conn.createChannel(); // channel.qu channel.queueDeclare("hello", false, false, false, null); String message = "Hello World!"; channel.basicPublish("", "hello", null, message.getBytes()); System.out.println(" [x] Sent '" + message + "'"); channel.close(); conn.close(); } catch (IOException e) { e.printStackTrace(); } catch (TimeoutException e) { e.printStackTrace(); } } }
/** * @param password the password. * @see com.rabbitmq.client.ConnectionFactory#setPassword(java.lang.String) */ public void setPassword(String password) { this.connectionFactory.setPassword(password); }
/** * @param password the password. * @see com.rabbitmq.client.ConnectionFactory#setPassword(java.lang.String) */ public void setPassword(String password) { this.connectionFactory.setPassword(password); }
/** * Sets the password. */ public ConnectionOptions withPassword(String password) { factory.setPassword(password); return this; }
connFactory.setPassword(CloudBusGlobalProperty.RABBITMQ_PASSWORD); logger.info("use RabbitMQ password: ******");
@Bean public ConnectionFactory connectionFactory() throws Exception { ConnectionFactory connectionFactory = new ConnectionFactory(); connectionFactory.setHost(env.getProperty("mq.host").trim()); connectionFactory.setPort(Integer.parseInt(env.getProperty("mq.port").trim())); connectionFactory.setVirtualHost(env.getProperty("mq.vhost").trim()); connectionFactory.setUsername(env.getProperty("mq.username").trim()); connectionFactory.setPassword(env.getProperty("mq.password").trim()); return connectionFactory; }
/** * @param props RabbitMQ 配置信息 */ public RabbitMQClusterPolicy(Properties props){ this.exchange = props.getProperty("exchange", "j2cache"); factory = new ConnectionFactory(); factory.setHost(props.getProperty("host" , "127.0.0.1")); factory.setPort(Integer.valueOf(props.getProperty("port", "5672"))); factory.setUsername(props.getProperty("username" , null)); factory.setPassword(props.getProperty("password" , null)); //TODO 更多的 RabbitMQ 配置 }
/** * Sets the ConnectionFactory parameters */ private void setFactoryConfiguration() { factory.setHost(this.host); factory.setPort(this.port); factory.setVirtualHost(this.virtualHost); factory.setUsername(this.username); factory.setPassword(this.password); }
//executed once ConnectionFactory factory = new ConnectionFactory(); factory.setHost("someHost"); factory.setUsername("user"); factory.setPassword("pass"); Connection connection = factory.newConnection();
protected void setFactoryDefaults() { factory.setHost("localhost"); factory.setPort(5672); factory.setUsername("guest"); factory.setPassword("guest"); factory.setVirtualHost("/"); }
@Bean public ConnectionFactory rabbitMqConnectionFactory() { final ConnectionFactory connectionFactory = new ConnectionFactory(); connectionFactory.setHost(environment.getRequiredProperty("rabbitmq.host")); connectionFactory.setPort(environment.getRequiredProperty("rabbitmq.port", Integer.class)); connectionFactory.setUsername(environment.getRequiredProperty("rabbitmq.user")); connectionFactory.setPassword(environment.getRequiredProperty("rabbitmq.pass")); return connectionFactory; }
@Bean BrokerRunning brokerRunning(final RabbitMqSetupService rabbitmqSetupService) { final BrokerRunning brokerRunning = BrokerRunning.isRunning(); brokerRunning.setHostName(rabbitmqSetupService.getHostname()); brokerRunning.getConnectionFactory().setUsername(rabbitmqSetupService.getUsername()); brokerRunning.getConnectionFactory().setPassword(rabbitmqSetupService.getPassword()); return brokerRunning; }
protected ConnectionFactory createFactory(Properties properties) { LOG.debug("Creating RabbitMQ connection factory with properties: {}", properties); ConnectionFactory factory = new ConnectionFactory(); factory.setUsername(USERNAME.readFrom(properties)); factory.setPassword(PASSWORD.readFrom(properties)); factory.setVirtualHost(VIRTUAL_HOST.readFrom(properties)); factory.setHost(HOST.readFrom(properties)); factory.setPort(Integer.parseInt(PORT.readFrom(properties))); factory.setExceptionHandler(handleChannelExceptions()); return factory; }
public ConnectionFactory connectionFactory() { ConnectionFactory connectionFactory = new ConnectionFactory(); connectionFactory.setHost(getHostIp()); connectionFactory.setPort(getPort()); connectionFactory.setUsername(getUsername()); connectionFactory.setPassword(getPassword()); return connectionFactory; }