Example usage for com.rabbitmq.client ConnectionFactory DEFAULT_HEARTBEAT

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

Introduction

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

Prototype

int DEFAULT_HEARTBEAT

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

Click Source Link

Document

Default heart-beat interval; 60 seconds

Usage

From source file:com.nxttxn.vramel.components.rabbitMQ.RabbitMQComponentTest.java

License:Apache License

@Test
public void testDefaultProperties() throws Exception {
    RabbitMQEndpoint endpoint = createEndpoint(new HashMap<String, Object>());

    assertEquals(14, endpoint.getPortNumber());
    assertEquals(10, endpoint.getThreadPoolSize());
    assertEquals(true, endpoint.isAutoAck());
    assertEquals(true, endpoint.isAutoDelete());
    assertEquals(true, endpoint.isDurable());
    assertEquals("direct", endpoint.getExchangeType());
    assertEquals(ConnectionFactory.DEFAULT_CONNECTION_TIMEOUT, endpoint.getConnectionTimeout());
    assertEquals(ConnectionFactory.DEFAULT_CHANNEL_MAX, endpoint.getRequestedChannelMax());
    assertEquals(ConnectionFactory.DEFAULT_FRAME_MAX, endpoint.getRequestedFrameMax());
    assertEquals(ConnectionFactory.DEFAULT_HEARTBEAT, endpoint.getRequestedHeartbeat());
    assertNull(endpoint.getConnectionFactory());
}

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.graylog2.inputs.transports.AmqpTransport.java

License:Open Source License

@Override
public void doLaunch(MessageInput input) throws MisfireException {
    int heartbeatTimeout = ConnectionFactory.DEFAULT_HEARTBEAT;
    if (configuration.intIsSet(CK_HEARTBEAT_TIMEOUT)) {
        heartbeatTimeout = configuration.getInt(CK_HEARTBEAT_TIMEOUT);
        if (heartbeatTimeout < 0) {
            LOG.warn("AMQP heartbeat interval must not be negative ({}), using default timeout ({}).",
                    heartbeatTimeout, ConnectionFactory.DEFAULT_HEARTBEAT);
            heartbeatTimeout = ConnectionFactory.DEFAULT_HEARTBEAT;
        }/*from  w  w w.j a  va2 s  .  c o  m*/
    }
    consumer = new AmqpConsumer(configuration.getString(CK_HOSTNAME), configuration.getInt(CK_PORT),
            configuration.getString(CK_VHOST), configuration.getString(CK_USERNAME),
            configuration.getString(CK_PASSWORD), configuration.getInt(CK_PREFETCH),
            configuration.getString(CK_QUEUE), configuration.getString(CK_EXCHANGE),
            configuration.getString(CK_ROUTING_KEY), configuration.getInt(CK_PARALLEL_QUEUES),
            configuration.getBoolean(CK_TLS), configuration.getBoolean(CK_REQUEUE_INVALID_MESSAGES),
            heartbeatTimeout, input, scheduler, this);
    eventBus.register(this);
    try {
        consumer.run();
    } catch (IOException e) {
        eventBus.unregister(this);
        throw new MisfireException("Could not launch AMQP consumer.", e);
    }
}