Example usage for com.rabbitmq.client Address Address

List of usage examples for com.rabbitmq.client Address Address

Introduction

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

Prototype

public Address(String host) 

Source Link

Document

Construct an address from a host.

Usage

From source file:com.flipkart.bifrost.framework.Connection.java

License:Apache License

/**
 * Start the connection. This will try to connect to the cluster hosts provided in the contructor.
 * Will throw an error in case of failure.
 * @throws BifrostException in case of connection failure.
 *///from   ww w.  j  a v a2  s.  c o m
public void start() throws BifrostException {
    ConnectionFactory connectionFactory = new ConnectionFactory();
    Address brokers[] = new Address[hosts.size()];
    int i = 0;
    for (String member : hosts) {
        brokers[i++] = new Address(member);
    }
    connectionFactory.setUsername(username);
    connectionFactory.setPassword(password);
    connectionFactory.setAutomaticRecoveryEnabled(true);
    connectionFactory.setTopologyRecoveryEnabled(true);
    try {
        connection = connectionFactory.newConnection(brokers);
    } catch (IOException e) {
        throw new BifrostException(BifrostException.ErrorCode.IO_ERROR, "Could not connect", e);
    }
}

From source file:com.shopwiki.roger.example.ExampleRpcServer_Simple.java

License:Apache License

public static void main(String[] args) throws Exception {

    RequestHandler<Request, Response> handler = new RequestHandler<Request, Response>() {
        @Override//from w  w  w  . jav a  2 s .  com
        public TypeReference<Request> getRequestType() {
            return new TypeReference<Request>() {
            };
        }

        @Override
        public Response handleRequest(Request request) throws Exception {
            return new Response("Hello " + request.name + "!");
        }
    };

    RabbitConnector connector = new RabbitConnector(new Address("localhost"));

    BasicWorkerFactory factory = new BasicWorkerFactory(connector, 2);
    factory.addHandler("HelloWorld", handler);

    RpcServer server = new RpcServer(factory, "RpcExample_");
    server.start();
}

From source file:it.jugtorino.one.msvc.way.rabbit.geoip.reference.client.RpcClientExample.java

License:Open Source License

private static Channel setupRabbitMQ() throws IOException, TimeoutException {
    ConnectionFactory factory = new ConnectionFactory();
    Connection connection = factory.newConnection(Collections.singletonList(new Address("localhost")));
    Channel channel = connection.createChannel();
    channel.queueDeclare("geoip_service_v1", false, false, false, null);
    return channel;
}

From source file:it.jugtorino.one.msvc.way.rabbit.geoip.reference.service.Main.java

License:Open Source License

private static Channel setupRabbitMQ() throws IOException, TimeoutException {
    ConnectionFactory factory = new ConnectionFactory();
    Connection connection = factory.newConnection(Arrays.asList(new Address("localhost")));
    Channel channel = connection.createChannel();
    channel.queueDeclare("geoip_service_v1", false, false, false, null);
    return channel;
}

From source file:it.jugtorino.one.msvc.way.rabbit.reference.webapp.GeoIPResource.java

License:Open Source License

public GeoIPResource() throws Exception {
    ConnectionFactory factory = new ConnectionFactory();
    Connection connection = factory.newConnection(Collections.singletonList(new Address("localhost")));
    Channel channel = connection.createChannel();
    channel.queueDeclare("geoip_service_v1", false, false, false, null);

    client = new RpcClient(channel, "geoip_service_v1");
    client.startConsuming();// w w  w  . j  a  v a 2 s.  c o m
}

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

License:Open Source License

void optionsConnectionSupplier() {
    ConnectionFactory connectionFactory = new ConnectionFactory();
    connectionFactory.useNio();/*from www .  j  a v a  2 s.  c o m*/
    // 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[]
}

From source file:zipkin2.reporter.beans.RabbitMQSenderFactoryBeanTest.java

License:Apache License

@Test
public void addresses() {
    context = new XmlBeans(
            "" + "<bean id=\"sender\" class=\"zipkin2.reporter.beans.RabbitMQSenderFactoryBean\">\n"
                    + "  <property name=\"addresses\" value=\"localhost\"/>\n" + "</bean>");

    assertThat(context.getBean("sender", RabbitMQSender.class)).extracting("addresses")
            .containsExactly(Arrays.asList(new Address("localhost")));
}