List of usage examples for com.rabbitmq.client ConnectionFactory DEFAULT_AMQP_PORT
int DEFAULT_AMQP_PORT
To view the source code for com.rabbitmq.client ConnectionFactory DEFAULT_AMQP_PORT.
Click Source Link
From source file:org.voltdb.exportclient.TestRabbitMQExportClient.java
License:Open Source License
/** * Make sure we use sane defaults for optional config options. *//*w w w.j ava 2 s. co 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;/*w ww .jav a2 s. c om*/ 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 {/* www . j a v a 2 s . c o 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
public FileReceive(String configFilename, String rabbitMqHost, Integer rabbitMqPort, String username, String password, String exchangeName, String burstQueue, Long refreshTime) throws JAXBException, IOException, TimeoutException { logger.info("Starting application version {}", System.getProperty("applicationVersion")); // Output env version from potential dockerfile environment if (System.getenv("FILE_RECEIVER_VERSION") != null) logger.info("Docker container build version {}", System.getenv("FILE_RECEIVER_VERSION")); Integer port = rabbitMqPort != null ? rabbitMqPort : ConnectionFactory.DEFAULT_AMQP_PORT; logger.info(//from ww w . j a va 2 s . c o m "Using:\n" + " - Config file: {}\n" + " - RabbitMQ Server Host: {}:{}\n" + " - RabbitMQ User: {}:****\n" + " - Exchange Name: {}\n" + " - BuRST Queue Binding: {}\n" + " - Refresh Time: {} seconds", configFilename, rabbitMqHost, port, username, exchangeName, burstQueue, refreshTime); this.refreshTime = refreshTime; this.exchangeName = exchangeName; this.burstQueue = burstQueue; factory = new ConnectionFactory(); factory.setHost(rabbitMqHost); factory.setPort(port); factory.setUsername(username); factory.setPassword(password); factory.setAutomaticRecoveryEnabled(true); config = loadConfig(configFilename); }
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 www . jav a 2 s. com 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; }