Example usage for com.rabbitmq.client ConnectionFactory DEFAULT_AMQP_PORT

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

Introduction

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

Prototype

int DEFAULT_AMQP_PORT

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

Click Source Link

Document

The default non-ssl port

Usage

From source file:amqp.AmqpEventSource.java

License:Apache License

public static SourceFactory.SourceBuilder builder() {
    return new SourceFactory.SourceBuilder() {
        @Override//from w w w. jav a2s  . com
        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:com.adr.data.rabbitmq.RabbitServer.java

License:Apache License

public RabbitServer(String dataqueue, String queryqueue, DataLink datalink, QueryLink querylink) {
    this.host = ConnectionFactory.DEFAULT_HOST; // localhost
    this.port = ConnectionFactory.DEFAULT_AMQP_PORT; // 5672
    this.queryqueue = queryqueue;
    this.dataqueue = dataqueue;
    this.datalink = datalink;
    this.querylink = querylink;
}

From source file:io.druid.examples.rabbitmq.RabbitMQFirehoseFactoryTest.java

License:Apache License

@Test
public void testDefaultSerde() throws Exception {
    RabbitMQFirehoseConfig config = RabbitMQFirehoseConfig.makeDefaultConfig();

    JacksonifiedConnectionFactory connectionFactory = JacksonifiedConnectionFactory
            .makeDefaultConnectionFactory();

    RabbitMQFirehoseFactory factory = new RabbitMQFirehoseFactory(connectionFactory, config);

    byte[] bytes = mapper.writeValueAsBytes(factory);
    RabbitMQFirehoseFactory factory2 = mapper.readValue(bytes, RabbitMQFirehoseFactory.class);
    byte[] bytes2 = mapper.writeValueAsBytes(factory2);

    Assert.assertArrayEquals(bytes, bytes2);

    Assert.assertEquals(factory.getConfig(), factory2.getConfig());
    Assert.assertEquals(factory.getConnectionFactory(), factory2.getConnectionFactory());

    Assert.assertEquals(300, factory2.getConfig().getMaxDurationSeconds());

    Assert.assertEquals(ConnectionFactory.DEFAULT_HOST, factory2.getConnectionFactory().getHost());
    Assert.assertEquals(ConnectionFactory.DEFAULT_USER, factory2.getConnectionFactory().getUsername());
    Assert.assertEquals(ConnectionFactory.DEFAULT_AMQP_PORT, factory2.getConnectionFactory().getPort());
}

From source file:net.lshift.accent.ConnectionSmokeTest.java

License:Apache License

private static ControlledConnectionProxy createProxy(int port) throws IOException {
    ControlledConnectionProxy proxy = new ControlledConnectionProxy(port, "proxy", "localhost",
            ConnectionFactory.DEFAULT_AMQP_PORT, new BlockingCell<Exception>());
    proxy.start();/*from   ww w  .  java2  s  .  c  o m*/

    return proxy;
}

From source file:org.apache.druid.examples.rabbitmq.RabbitMQFirehoseFactoryTest.java

License:Apache License

@Test
public void testDefaultSerde() throws Exception {
    RabbitMQFirehoseConfig config = RabbitMQFirehoseConfig.makeDefaultConfig();

    JacksonifiedConnectionFactory connectionFactory = JacksonifiedConnectionFactory
            .makeDefaultConnectionFactory();

    RabbitMQFirehoseFactory factory = new RabbitMQFirehoseFactory(connectionFactory, config, null);

    byte[] bytes = mapper.writeValueAsBytes(factory);
    RabbitMQFirehoseFactory factory2 = mapper.readValue(bytes, RabbitMQFirehoseFactory.class);
    byte[] bytes2 = mapper.writeValueAsBytes(factory2);

    Assert.assertArrayEquals(bytes, bytes2);

    Assert.assertEquals(factory.getConfig(), factory2.getConfig());
    Assert.assertEquals(factory.getConnectionFactory(), factory2.getConnectionFactory());

    Assert.assertEquals(300, factory2.getConfig().getMaxDurationSeconds());

    Assert.assertEquals(ConnectionFactory.DEFAULT_HOST, factory2.getConnectionFactory().getHost());
    Assert.assertEquals(ConnectionFactory.DEFAULT_USER, factory2.getConnectionFactory().getUsername());
    Assert.assertEquals(ConnectionFactory.DEFAULT_AMQP_PORT, factory2.getConnectionFactory().getPort());
}

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.objectweb.joram.mom.dest.amqp.AmqpConnectionService.java

License:Open Source License

/**
 * Adds an AMQP server and starts a live connection with it, accessible via
 * the host and port provided. A server is uniquely identified by the given
 * name. Adding an existing server won't do anything.
 * //from ww w.  java  2  s.com
 * @param urls the amqp url list identifying the servers separate by space.
 * ex: amqp://user:pass@localhost:5672/?name=serv1 amqp://user:pass@localhost:5678/?name=serv2
 * serv1 and serv2 are the name identifying the server.
 */
public static void addServer(String urls) {
    if (logger.isLoggable(BasicLevel.DEBUG)) {
        logger.log(BasicLevel.DEBUG, "AmqpConnectionService.addServer(" + urls + ')');
    }

    StringTokenizer tk = new StringTokenizer(urls);
    while (tk.hasMoreTokens()) {
        URL url = null;
        try {
            url = new URL(null, tk.nextToken(), new MyURLStreamHandler());
        } catch (Exception e) {
            if (logger.isLoggable(BasicLevel.ERROR)) {
                logger.log(BasicLevel.ERROR, "AmqpConnectionService.addServer : Exception ", e);
            }
            continue;
        }
        String host = null;
        int port = -1;
        String name = "default";
        String userName = null;
        String userPass = null;

        String userInfo = url.getUserInfo();
        if (userInfo != null) {
            StringTokenizer token = new StringTokenizer(userInfo, ":");
            if (token.hasMoreTokens())
                userName = token.nextToken();
            if (token.hasMoreTokens())
                userPass = token.nextToken();
        }

        host = url.getHost();
        if (host == null)
            host = ConnectionFactory.DEFAULT_HOST;

        port = url.getPort();
        if (port < 0)
            port = ConnectionFactory.DEFAULT_AMQP_PORT;

        String query = url.getQuery();
        if (query != null) {
            int index = query.indexOf('=');
            if (index > 0)
                name = query.substring(index + 1, query.length());
        }

        if (logger.isLoggable(BasicLevel.DEBUG)) {
            logger.log(BasicLevel.DEBUG, "AmqpConnectionService.addServer(" + name + ", " + host + ", " + port
                    + ", " + userName + ')');
        }
        getInstance().addServer(name, host, port, userName, userPass);
    }
}

From source file:org.smartdeveloperhub.curator.connector.protocol.ValidationUtilTest.java

License:Apache License

@Test
public void testValidatePort$valid() {
    ValidationUtil.validatePort(ConnectionFactory.DEFAULT_AMQP_PORT);
}

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 www  . j a v a2 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");
}