Example usage for com.rabbitmq.client ConnectionFactory DEFAULT_PASS

List of usage examples for com.rabbitmq.client ConnectionFactory DEFAULT_PASS

Introduction

In this page you can find the example usage for com.rabbitmq.client ConnectionFactory DEFAULT_PASS.

Prototype

String DEFAULT_PASS

To view the source code for com.rabbitmq.client ConnectionFactory DEFAULT_PASS.

Click Source Link

Document

Default password

Usage

From source file:amqp.AmqpEventSource.java

License:Apache License

public static SourceFactory.SourceBuilder builder() {
    return new SourceFactory.SourceBuilder() {
        @Override//  ww w  . j a va2 s  . co  m
        public EventSource build(String... args) {
            return build(null, args);
        }

        @Override
        public EventSource build(Context ctx, String... args) {
            if (args.length < 1 || args.length > 13) {
                throw new IllegalArgumentException("amqp(exchangeName=\"exchangeName\" " + "[,host=\"host\"] "
                        + "[,port=port] " + "[,virtualHost=\"virtualHost\"] " + "[,userName=\"user\"] "
                        + "[,password=\"password\"] " + "[,exchangeType=\"direct\"] "
                        + "[,durableExchange=false] " + "[,queueName=\"queueName\"] " + "[,durableQueue=false] "
                        + "[,exclusiveQueue=false] " + "[,autoDeleteQueue=false] "
                        + "[,bindings=\"binding1,binding2,bindingN\"] " + "[,useMessageTimestamp=false])");
            }

            CommandLineParser parser = new CommandLineParser(args);

            String host = parser.getOptionValue("host", ConnectionFactory.DEFAULT_HOST);
            int port = parser.getOptionValue("port", ConnectionFactory.DEFAULT_AMQP_PORT);
            String virtualHost = parser.getOptionValue("virtualHost", ConnectionFactory.DEFAULT_VHOST);
            String userName = parser.getOptionValue("userName", ConnectionFactory.DEFAULT_USER);
            String password = parser.getOptionValue("password", ConnectionFactory.DEFAULT_PASS);
            String exchangeName = parser.getOptionValue("exchangeName");
            String exchangeType = parser.getOptionValue("exchangeType", AmqpConsumer.DEFAULT_EXCHANGE_TYPE);
            boolean durableExchange = parser.getOptionValue("durableExchange", true);
            String queueName = parser.getOptionValue("queueName");
            boolean durableQueue = parser.getOptionValue("durableQueue", false);
            boolean exclusiveQueue = parser.getOptionValue("exclusiveQueue", false);
            boolean autoDeleteQueue = parser.getOptionValue("autoDeleteQueue", false);
            String[] bindings = parser.getOptionValues("bindings");
            boolean useMessageTimestamp = parser.getOptionValue("useMessageTimestamp", false);

            // exchange name is the only required parameter
            if (exchangeName == null) {
                throw new IllegalArgumentException("exchangeName must be set for AMQP source");
            }

            return new AmqpEventSource(host, port, virtualHost, userName, password, exchangeName, exchangeType,
                    durableExchange, queueName, durableQueue, exclusiveQueue, autoDeleteQueue,
                    useMessageTimestamp, bindings);
        }
    };
}

From source file:org.apache.flume.rabbitmq.source.RabbitMQSource.java

License:Apache License

@Override
public void configure(Context context) {
    hosts = context.getString(HOSTNAME, ConnectionFactory.DEFAULT_HOST);

    port = context.getInteger(PORT, ConnectionFactory.DEFAULT_AMQP_PORT);
    virtualHost = context.getString(VIRTUAL_HOST, ConnectionFactory.DEFAULT_VHOST);

    userName = context.getString(USERNAME, ConnectionFactory.DEFAULT_USER);

    password = context.getString(PASSWORD, ConnectionFactory.DEFAULT_PASS);

    connectionTimeout = context.getInteger(CONNECTION_TIMEOUT, ConnectionFactory.DEFAULT_CONNECTION_TIMEOUT);
    requestedHeartbeat = context.getInteger(REQUESTED_HEARTBEAT, ConnectionFactory.DEFAULT_HEARTBEAT);
    requestedChannelMax = context.getInteger(REQUESTED_CHANNEL_MAX, ConnectionFactory.DEFAULT_CHANNEL_MAX);
    requestedFrameMax = context.getInteger(REQUESTED_FRAMEL_MAX, ConnectionFactory.DEFAULT_FRAME_MAX);

    connectionFactory = new RabbitMQConnectionFactory.Builder().addHosts(hosts).setPort(port)
            .setVirtualHost(virtualHost).setUserName(userName).setPassword(password)
            .setConnectionTimeOut(connectionTimeout).setRequestedHeartbeat(requestedHeartbeat)
            .setRequestedChannelMax(requestedChannelMax).setRequestedFrameMax(requestedFrameMax).build();

    exchangeName = context.getString(EXCHANGE_NAME, StringUtils.EMPTY);
    queueName = context.getString(QUEUE_NAME, StringUtils.EMPTY);
    Preconditions.checkArgument(StringUtils.isNotEmpty(exchangeName) || StringUtils.isNotEmpty(queueName),
            "Atleast exchange name or queue name must be defined.");

    topics = StringUtils.split(context.getString(TOPICS, StringUtils.EMPTY), ",");

    String queueParams = context.getString(QUEUE_PARAMETERS, StringUtils.EMPTY);
    queueParameters = initializeQueueParameters(queueParams);

    batchSize = context.getInteger(BATCH_SIZE, DEFAULT_BATCH_SIZE);
}

From source file:org.apache.flume.RabbitMQUtil.java

License:Apache License

public static ConnectionFactory getFactory(Context context) {
    Preconditions.checkArgument(context != null, "context cannot be null.");
    ConnectionFactory factory = new ConnectionFactory();

    String hostname = context.getString("hostname");
    Preconditions.checkArgument(hostname != null, "No hostname specified.");
    factory.setHost(hostname);/*from   ww w.  j  av a2s  .  c om*/

    int port = context.getInteger(RabbitMQConstants.CONFIG_PORT, -1);

    if (-1 != port) {
        factory.setPort(port);
    }

    String username = context.getString(RabbitMQConstants.CONFIG_USERNAME);

    if (null == username) {
        factory.setUsername(ConnectionFactory.DEFAULT_USER);
    } else {
        factory.setUsername(username);
    }

    String password = context.getString(RabbitMQConstants.CONFIG_PASSWORD);

    if (null == password) {
        factory.setPassword(ConnectionFactory.DEFAULT_PASS);
    } else {
        factory.setPassword(password);
    }

    String virtualHost = context.getString(RabbitMQConstants.CONFIG_VIRTUALHOST);

    if (null != virtualHost) {
        factory.setVirtualHost(virtualHost);
    }

    int connectionTimeout = context.getInteger(RabbitMQConstants.CONFIG_CONNECTIONTIMEOUT, -1);

    if (connectionTimeout > -1) {
        factory.setConnectionTimeout(connectionTimeout);
    }

    //        boolean useSSL = context.getBoolean("usessl", false);
    //        if(useSSL){
    //            factory.useSslProtocol();
    //        }

    return factory;
}

From source file:org.thingsboard.rule.engine.rabbitmq.TbRabbitMqNodeConfiguration.java

License:Apache License

@Override
public TbRabbitMqNodeConfiguration defaultConfiguration() {
    TbRabbitMqNodeConfiguration configuration = new TbRabbitMqNodeConfiguration();
    configuration.setExchangeNamePattern("");
    configuration.setRoutingKeyPattern("");
    configuration.setMessageProperties(null);
    configuration.setHost(ConnectionFactory.DEFAULT_HOST);
    configuration.setPort(ConnectionFactory.DEFAULT_AMQP_PORT);
    configuration.setVirtualHost(ConnectionFactory.DEFAULT_VHOST);
    configuration.setUsername(ConnectionFactory.DEFAULT_USER);
    configuration.setPassword(ConnectionFactory.DEFAULT_PASS);
    configuration.setAutomaticRecoveryEnabled(false);
    configuration.setConnectionTimeout(ConnectionFactory.DEFAULT_CONNECTION_TIMEOUT);
    configuration.setHandshakeTimeout(ConnectionFactory.DEFAULT_HANDSHAKE_TIMEOUT);
    configuration.setClientProperties(Collections.emptyMap());
    return configuration;
}

From source file:org.voltdb.exportclient.RabbitMQExportClient.java

License:Open Source License

@Override
public void configure(Properties config) throws Exception {
    final String brokerHost = config.getProperty("broker.host");
    final String amqpUri = config.getProperty("amqp.uri");
    if (brokerHost == null && amqpUri == null) {
        throw new IllegalArgumentException("One of \"broker.host\" and \"amqp.uri\" must not be null");
    }//from  w  w w  .j  ava2  s .c o m

    final int brokerPort = Integer
            .parseInt(config.getProperty("broker.port", String.valueOf(ConnectionFactory.DEFAULT_AMQP_PORT)));
    final String username = config.getProperty("username", ConnectionFactory.DEFAULT_USER);
    final String password = config.getProperty("password", ConnectionFactory.DEFAULT_PASS);
    final String vhost = config.getProperty("virtual.host", ConnectionFactory.DEFAULT_VHOST);
    m_exchangeName = config.getProperty("exchange.name", "");

    final String routingKeySuffix = config.getProperty("routing.key.suffix");
    if (routingKeySuffix != null) {
        StringTokenizer tokens = new StringTokenizer(routingKeySuffix, ",");
        while (tokens.hasMoreTokens()) {
            String[] parts = tokens.nextToken().split("\\.");
            if (parts.length == 2) {
                m_routingKeyColumns.put(parts[0].toLowerCase().trim(), parts[1].trim());
            }
        }
    }

    m_skipInternal = Boolean.parseBoolean(config.getProperty("skipinternals", "false"));

    if (Boolean.parseBoolean(config.getProperty("queue.durable", "true"))) {
        m_channelProperties = MessageProperties.PERSISTENT_TEXT_PLAIN;
    }

    m_connFactory = new ConnectionFactory();
    // Set the URI first, if other things are set, they'll overwrite the corresponding
    // parts in the URI.
    if (amqpUri != null) {
        m_connFactory.setUri(amqpUri);
    }
    m_connFactory.setHost(brokerHost);
    m_connFactory.setPort(brokerPort);
    m_connFactory.setUsername(username);
    m_connFactory.setPassword(password);
    m_connFactory.setVirtualHost(vhost);

    final TimeZone tz = TimeZone.getTimeZone(config.getProperty("timezone", VoltDB.GMT_TIMEZONE.getID()));

    m_binaryEncoding = ExportDecoderBase.BinaryEncoding
            .valueOf(config.getProperty("binaryencoding", "HEX").trim().toUpperCase());

    m_ODBCDateformat = new ThreadLocal<SimpleDateFormat>() {
        @Override
        protected SimpleDateFormat initialValue() {
            SimpleDateFormat sdf = new SimpleDateFormat(Constants.ODBC_DATE_FORMAT_STRING);
            sdf.setTimeZone(tz);
            return sdf;
        }
    };

    slogger.info("Configured RabbitMQ export client");
}

From source file:org.voltdb.exportclient.TestRabbitMQExportClient.java

License:Open Source License

/**
 * Make sure we use sane defaults for optional config options.
 *//*from   ww  w.j a  v a  2 s .c  o  m*/
@Test
public void testDefaultConfig() throws Exception {
    final RabbitMQExportClient dut = new RabbitMQExportClient();
    final Properties config = new Properties();
    config.setProperty("broker.host", "fakehost");
    dut.configure(config);
    assertEquals("fakehost", dut.m_connFactory.getHost());
    assertEquals(ConnectionFactory.DEFAULT_AMQP_PORT, dut.m_connFactory.getPort());
    assertEquals(ConnectionFactory.DEFAULT_USER, dut.m_connFactory.getUsername());
    assertEquals(ConnectionFactory.DEFAULT_PASS, dut.m_connFactory.getPassword());
    assertEquals(ConnectionFactory.DEFAULT_VHOST, dut.m_connFactory.getVirtualHost());
    assertEquals("", dut.m_exchangeName);
    assertTrue(dut.m_routingKeyColumns.isEmpty());
    assertFalse(dut.m_skipInternal);
    assertEquals(MessageProperties.PERSISTENT_TEXT_PLAIN, dut.m_channelProperties);
    assertEquals(ExportDecoderBase.BinaryEncoding.HEX, dut.m_binaryEncoding);
    assertEquals(TimeZone.getTimeZone(VoltDB.GMT_TIMEZONE.getID()), dut.m_ODBCDateformat.get().getTimeZone());
}

From source file:ox.softeng.burst.service.message.RabbitMessageService.java

public RabbitMessageService(EntityManagerFactory emf, Properties properties)
        throws IOException, TimeoutException {

    exchange = properties.getProperty("rabbitmq.exchange");
    queue = properties.getProperty("rabbitmq.queue");
    entityManagerFactory = emf;/*from   ww w.jav a2 s  .com*/
    consumerCount = Utils.convertToInteger("message.service.thread.size",
            properties.getProperty("message.service.consumer.size"), 1);

    String host = properties.getProperty("rabbitmq.host");
    String username = properties.getProperty("rabbitmq.user", ConnectionFactory.DEFAULT_USER);
    String password = properties.getProperty("rabbitmq.password", ConnectionFactory.DEFAULT_PASS);
    Integer port = Utils.convertToInteger("rabbitmq.port", properties.getProperty("rabbitmq.port"),
            ConnectionFactory.DEFAULT_AMQP_PORT);

    ConnectionFactory factory = new ConnectionFactory();
    factory.setUsername(username);
    factory.setPassword(password);
    factory.setPort(port);
    factory.setHost(host);
    factory.setAutomaticRecoveryEnabled(true);
    factory.setThreadFactory(new NamedThreadFactory("consumer"));

    connection = factory.newConnection();

    logger.info("Creating new RabbitMQ Service using: \n" + "  host: {}:{}\n" + "  user: {}\n"
            + "  exchange: {}\n" + "  queue: {}", host, port, username, exchange, queue);
}

From source file:ox.softeng.burst.services.BurstService.java

License:Open Source License

public BurstService(Properties properties) {

    logger.info("Starting application version {}", System.getProperty("applicationVersion"));

    // Output env version from potential dockerfile environment
    if (System.getenv("BURST_VERSION") != null)
        logger.info("Docker container build version {}", System.getenv("BURST_VERSION"));

    String user = (String) properties.get("hibernate.connection.user");
    String url = (String) properties.get("hibernate.connection.url");
    String password = (String) properties.get("hibernate.connection.password");

    logger.info("Migrating database using: \n" + "  url: {}" + "  user: {}" + "  password: ****", url, user);
    migrateDatabase(url, user, password);
    entityManagerFactory = Persistence.createEntityManagerFactory("ox.softeng.burst", properties);

    String rabbitMQHost = properties.getProperty("rabbitmq.host");
    String rabbitMQExchange = properties.getProperty("rabbitmq.exchange");
    String rabbitMQQueue = properties.getProperty("rabbitmq.queue");
    String rabbitPortStr = properties.getProperty("rabbitmq.port");
    String rabbitUser = properties.getProperty("rabbitmq.user", ConnectionFactory.DEFAULT_USER);
    String rabbitPassword = properties.getProperty("rabbitmq.password", ConnectionFactory.DEFAULT_PASS);

    Integer rabbitPort = ConnectionFactory.DEFAULT_AMQP_PORT;

    try {/*from  w w  w. ja  v  a2 s .  co  m*/
        rabbitPort = Integer.parseInt(rabbitPortStr);
    } catch (NumberFormatException ignored) {
        logger.warn("Configuration supplied rabbit port '{}' is not numerical, using default value {}",
                rabbitPortStr, rabbitPort);
    }

    logger.info(
            "Creating new RabbitMQ Service using: \n" + "  host: {}:{}\n" + "  user: {}:{}\n"
                    + "  exchange: {}\n" + "  queue: {}",
            rabbitMQHost, rabbitPort, rabbitUser, rabbitPassword, rabbitMQExchange, rabbitMQQueue);
    try {
        rabbitReceiver = new RabbitService(rabbitMQHost, rabbitPort, rabbitUser, rabbitPassword,
                rabbitMQExchange, rabbitMQQueue, entityManagerFactory);
    } catch (IOException | TimeoutException e) {
        logger.error("Cannot create RabbitMQ service: " + e.getMessage(), e);
        System.exit(1);
    } catch (JAXBException e) {
        logger.error("Cannot create JAXB unmarshaller for messages: " + e.getMessage(), e);
        System.exit(1);
    }

    logger.info("Creating new report scheduler");
    reportScheduler = new ReportScheduler(entityManagerFactory, properties);
    scheduleFrequency = Integer
            .parseInt(properties.getProperty("report.schedule.frequency", SCHEDULE_FREQUENCY.toString()));

    logger.info("Creating new executor with thread pool size {}", THREAD_POOL_SIZE);
    executor = Executors.newScheduledThreadPool(THREAD_POOL_SIZE);
}

From source file:ox.softeng.gel.filereceive.FileReceive.java

private static Options defineMainOptions() {
    Options options = new Options();
    options.addOption(Option.builder("c").longOpt("config").argName("FILE").hasArg().required()
            .desc("The config file defining the monitor config").build());
    options.addOption(Option.builder("r").longOpt("rabbitmq-server").argName("RABBITMQ_HOST").hasArg()
            .required().desc("Hostname for the RabbitMQ server").build());
    options.addOption(Option.builder("p").longOpt("rabbitmq-port").argName("RABBITMQ_PORT").hasArg()
            .desc("[Optional] Port for the RabbitMQ server, default is " + ConnectionFactory.DEFAULT_AMQP_PORT)
            .type(Number.class).build());
    options.addOption(Option.builder("u").longOpt("rabbitmq-user").argName("RABBITMQ_USER").hasArg()
            .desc("[Optional] User for the RabbitMQ server, default is " + ConnectionFactory.DEFAULT_USER)
            .build());/*from   w w w.j a  v  a  2 s  .  co m*/
    options.addOption(Option.builder("w").longOpt("rabbitmq-password").argName("RABBITMQ_PASSWORD").hasArg()
            .desc("[Optional] Password for the RabbitMQ server, default is " + ConnectionFactory.DEFAULT_PASS)
            .build());
    options.addOption(Option.builder("e").longOpt("exchange").argName("EXCHANGE").hasArg().required()
            .desc("Exchange on the RabbitMQ server to send files to.\n"
                    + "Queues for the folders are designated in the config file")
            .build());
    options.addOption(Option.builder("b").longOpt("burst-binding").argName("BURST").hasArg().required()
            .desc("Binding key for the BuRST queue at the named exchange").build());
    options.addOption(Option.builder("t").longOpt("refresh-time").argName("TIME").hasArg().required()
            .desc("Refresh time for monitoring in seconds").type(Number.class).build());
    return options;
}

From source file:ox.softeng.gel.filereceive.FileReceive.java

public static void main(String[] args) {

    if (hasSimpleOptions(args))
        System.exit(0);/*from   ww  w .ja  va  2  s  .  c  o  m*/

    try {
        // parse the command line arguments
        CommandLine line = parser.parse(defineMainOptions(), args);

        long start = System.currentTimeMillis();

        try {
            FileReceive fr = new FileReceive(line.getOptionValue('c'), line.getOptionValue('r'),
                    (Integer) line.getParsedOptionValue("p"),
                    line.getOptionValue('u', ConnectionFactory.DEFAULT_USER),
                    line.getOptionValue('w', ConnectionFactory.DEFAULT_PASS), line.getOptionValue('e'),
                    line.getOptionValue('b'), (Long) line.getParsedOptionValue("t"));
            fr.startMonitors();

            logger.info("File receiver started in {}ms", System.currentTimeMillis() - start);
        } catch (JAXBException ex) {
            logger.error("Could not create file receiver because of JAXBException: {}",
                    ex.getLinkedException().getMessage());
        } catch (IOException | TimeoutException ex) {
            logger.error("Could not create file receiver because: {}", ex.getMessage());
            ex.printStackTrace();
        }
    } catch (ParseException exp) {
        logger.error("Could not start file-receiver because of ParseException: " + exp.getMessage());
        help();
    }
}