Example usage for com.rabbitmq.client ConnectionFactory DEFAULT_USER

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

Introduction

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

Prototype

String DEFAULT_USER

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

Click Source Link

Document

Default user name

Usage

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 ww  .j a va 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);//  ww w  .  j ava2  s  .c om

    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();
    }
}