Package com.rabbitmq.client

Examples of com.rabbitmq.client.ConnectionFactory


 
  private final static String QUEUE_NAME = "hello";

  public static void main(String[] argv) throws Exception {
             
    ConnectionFactory factory = new ConnectionFactory();
    factory.setHost("localhost");
    Connection connection = factory.newConnection();
    Channel channel = connection.createChannel();

    channel.queueDeclare(QUEUE_NAME, false, false, false, null);
    String message = "Hello World!";
    channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
View Full Code Here


  public static void main(String[] argv) {
    Connection connection = null;
    Channel channel = null;
    try {
      ConnectionFactory factory = new ConnectionFactory();
      factory.setHost("localhost");
 
      connection = factory.newConnection();
      channel = connection.createChannel();

      channel.exchangeDeclare(EXCHANGE_NAME, "topic");
      String queueName = channel.queueDeclare().getQueue();
View Full Code Here

 
    private final static String QUEUE_NAME = "hello";

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

    ConnectionFactory factory = new ConnectionFactory();
    factory.setHost("localhost");
    Connection connection = factory.newConnection();
    Channel channel = connection.createChannel();

    channel.queueDeclare(QUEUE_NAME, false, false, false, null);
    System.out.println(" [*] Waiting for messages. To exit press CTRL+C");
   
View Full Code Here

      if (argv.length < 1){
        System.err.println("Usage: ReceiveLogsHeader queueName [headers]...");
        System.exit(1);
      }
   
      ConnectionFactory factory = new ConnectionFactory();
      factory.setHost("localhost");
 
      connection = factory.newConnection();
      channel = connection.createChannel();

      channel.exchangeDeclare(EXCHANGE_NAME, "headers");

      // The API requires a routing key, but in fact if you are using a header exchange the
View Full Code Here

  private static final String EXCHANGE_NAME = "logs";

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

    ConnectionFactory factory = new ConnectionFactory();
    factory.setHost("localhost");
    Connection connection = factory.newConnection();
    Channel channel = connection.createChannel();

    channel.exchangeDeclare(EXCHANGE_NAME, "fanout");
    String queueName = channel.queueDeclare().getQueue();
    channel.queueBind(queueName, EXCHANGE_NAME, "");
View Full Code Here

            int rateLimit = optArg("rateLimit", args, 1, SEND_RATE);
            int messageCount = optArg("messageCount", args, 2, LATENCY_MESSAGE_COUNT);
            boolean sendCompletion = optArg("sendCompletion", args, 3, false);
            int commitEvery = optArg("commitEvery", args, 4, -1);
            boolean sendLatencyInfo = optArg("sendLatencyInfo", args, 5, true);
            final Connection conn = new ConnectionFactory(){{setUri(uri);}}.newConnection();
            //if (commitEvery > 0) { conn.getSocket().setTcpNoDelay(true); }
            System.out.println("Channel 0 fully open.");
            new ProducerMain(conn, rateLimit, messageCount, sendCompletion, commitEvery, sendLatencyInfo).run();
        } catch (Exception e) {
            System.err.println("Main thread caught exception: " + e);
View Full Code Here

            String uri = strArg(cmd, 'h', "amqp://localhost");
      String exchangeType = strArg(cmd, 't', "direct");
      String exchange = strArg(cmd, 'e', null);
      String routingKey = strArg(cmd, 'k', null);

            ConnectionFactory connFactory = new ConnectionFactory();
            connFactory.setUri(uri);
            Connection conn = connFactory.newConnection();

            final Channel ch = conn.createChannel();

      if (exchange == null) {
    System.err.println("Please supply exchange name to send to (-e)");
View Full Code Here

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

class ChannelCreationPerformance {
    static Connection connect() throws Exception{
      return new ConnectionFactory()
          {{setRequestedChannelMax(CHANNEL_MAX);}}.newConnection();
    }
View Full Code Here

    public static void main(String[] args) {
        try {
            String uri = (args.length > 0) ? args[0] : "amqp://localhost";
            String queueName = (args.length > 1) ? args[1] : "SimpleQueue";

            ConnectionFactory connFactory = new ConnectionFactory();
            connFactory.setUri(uri);
            Connection conn = connFactory.newConnection();

            final Channel ch = conn.createChannel();

            ch.queueDeclare(queueName, false, false, false, null);
View Full Code Here

    private void parseSuccess(String uri, String user, String password,
                              String host, int port, String vhost)
        throws URISyntaxException, NoSuchAlgorithmException, KeyManagementException
    {
        ConnectionFactory cf = new ConnectionFactory();
        cf.setUri(uri);

        assertEquals(user, cf.getUsername());
        assertEquals(password, cf.getPassword());
        assertEquals(host, cf.getHost());
        assertEquals(port, cf.getPort());
        assertEquals(vhost, cf.getVirtualHost());
    }
View Full Code Here

TOP

Related Classes of com.rabbitmq.client.ConnectionFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.