Example usage for com.rabbitmq.client ConnectionFactory useNio

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

Introduction

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

Prototype

public void useNio() 

Source Link

Document

Use non-blocking IO (NIO) for communication with the server.

Usage

From source file:com.navercorp.pinpoint.plugin.jdk7.rabbitmq.RabbitMQClient_5_x_IT.java

License:Apache License

@Test
public void testPush_nio() throws Exception {
    ConnectionFactory connectionFactory = getConnectionFactory();
    connectionFactory.setAutomaticRecoveryEnabled(false);
    connectionFactory.useNio();

    testRunner.runPushTest();//w w  w.j ava 2 s .c  om
}

From source file:com.navercorp.pinpoint.plugin.jdk7.rabbitmq.RabbitMQClient_5_x_IT.java

License:Apache License

@Test
public void testPush_nio_autorecovery() throws Exception {
    ConnectionFactory connectionFactory = getConnectionFactory();
    connectionFactory.setAutomaticRecoveryEnabled(true);
    connectionFactory.useNio();

    testRunner.runPushTest();//from   w w  w  .  ja v a 2 s.  c  om
}

From source file:com.navercorp.pinpoint.plugin.jdk7.rabbitmq.RabbitMQClient_5_x_IT.java

License:Apache License

@Test
public void testPull_nio() throws Exception {
    ConnectionFactory connectionFactory = getConnectionFactory();
    connectionFactory.setAutomaticRecoveryEnabled(false);
    connectionFactory.useNio();

    testRunner.runPullTest();//ww w.jav  a 2 s.  com
}

From source file:com.navercorp.pinpoint.plugin.jdk7.rabbitmq.RabbitMQClient_5_x_IT.java

License:Apache License

@Test
public void testPull_nio_autorecovery() throws Exception {
    ConnectionFactory connectionFactory = getConnectionFactory();
    connectionFactory.setAutomaticRecoveryEnabled(true);
    connectionFactory.useNio();

    testRunner.runPullTest();//from   w w  w.j  a  v a2s .co  m
}

From source file:org.apache.james.backend.rabbitmq.RabbitMQConnectionFactory.java

License:Apache License

private ConnectionFactory from(RabbitMQConfiguration rabbitMQConfiguration) {
    try {//from  w w w.  jav  a2 s .  co  m
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setUri(rabbitMQConfiguration.getUri());
        connectionFactory.useNio();
        return connectionFactory;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:reactor.rabbitmq.ConnectionRecoveryTests.java

License:Open Source License

@BeforeEach
public void init() throws Exception {
    ConnectionFactory connectionFactory = new ConnectionFactory();
    connectionFactory.useNio();
    connectionFactory.setNetworkRecoveryInterval(RECOVERY_INTERVAL);
    connection = connectionFactory.newConnection();
    Channel channel = connection.createChannel();
    String queueName = UUID.randomUUID().toString();
    queue = channel.queueDeclare(queueName, false, false, false, null).getQueue();
    channel.close();/*from   w  ww  . ja v  a 2  s . co m*/
    receiver = null;
    sender = null;
    connectionMono = Mono.just(connectionFactory.newConnection()).cache();
}

From source file:reactor.rabbitmq.docs.AdvancedFeatures.java

License:Open Source License

void connectionMono() {
    // tag::connection-mono[]
    ConnectionFactory connectionFactory = new ConnectionFactory(); // <1>
    connectionFactory.useNio();

    Sender sender = RabbitFlux.createSender(new SenderOptions()
            .connectionMono(Mono.fromCallable(() -> connectionFactory.newConnection("sender"))) // <2>
    );/*ww  w  .ja v a2  s.com*/
    Receiver receiver = RabbitFlux.createReceiver(new ReceiverOptions()
            .connectionMono(Mono.fromCallable(() -> connectionFactory.newConnection("receiver"))) // <3>
    );
    // end::connection-mono[]
}

From source file:reactor.rabbitmq.docs.AdvancedFeatures.java

License:Open Source License

void sharedConnection() {
    // tag::shared-connection[]
    ConnectionFactory connectionFactory = new ConnectionFactory(); // <1>
    connectionFactory.useNio();
    Mono<? extends Connection> connectionMono = Utils.singleConnectionMono( // <2>
            connectionFactory, cf -> cf.newConnection());

    Sender sender = RabbitFlux.createSender(new SenderOptions().connectionMono(connectionMono) // <3>
    );//from   w  w  w.j av a 2s .c  om
    Receiver receiver = RabbitFlux.createReceiver(new ReceiverOptions().connectionMono(connectionMono) // <4>
    );
    // end::shared-connection[]
}

From source file:reactor.rabbitmq.docs.ApiGuideReceiver.java

License:Open Source License

void optionsSimple() {
    // tag::options-simple[]
    ConnectionFactory connectionFactory = new ConnectionFactory();
    connectionFactory.useNio();

    ReceiverOptions receiverOptions = new ReceiverOptions().connectionFactory(connectionFactory) // <1>
            .connectionSubscriptionScheduler(Schedulers.elastic()); // <2>
    // end::options-simple[]
    // tag::inbound-flux[]
    Flux<Delivery> inboundFlux = RabbitFlux.createReceiver(receiverOptions).consumeNoAck("reactive.queue");
    // end::inbound-flux[]

    Receiver receiver = RabbitFlux.createReceiver();
    // tag::closing[]
    receiver.close();/*from   w ww.  j a v a2 s  . c o  m*/
    // end::closing[]
}

From source file:reactor.rabbitmq.docs.ApiGuideReceiver.java

License:Open Source License

void optionsConnectionSupplier() {
    ConnectionFactory connectionFactory = new ConnectionFactory();
    connectionFactory.useNio();
    // tag::options-connection-supplier[]
    SenderOptions senderOptions = new SenderOptions().connectionFactory(connectionFactory)
            .connectionSupplier(cf -> cf.newConnection( // <1>
                    new Address[] { new Address("192.168.0.1"), new Address("192.168.0.2") },
                    "reactive-sender"))
            .resourceManagementScheduler(Schedulers.elastic());
    // end::options-connection-supplier[]
}