Class List Method List File List

# Class: VertxAmqpClient::AmqpClient

Inherits:
  Object
  - Object
  - VertxAmqpClient::AmqpClient
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_client.rb

## Overview

AMQP Client entry point. Use this interface to create an instance of AmqpClient and connect to a broker and server.

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (::VertxAmqpClient::AmqpClient) create(param_1 = nil, param_2 = nil)
  Creates a new instance of AmqpClient with the given Vert.x instance and the given options.
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (void) close { ... }
  Closes the client.
- - (self) connect { ... }
  Connects to the AMQP broker or router.
- - (self) create_receiver(address = nil, receiverOptions = nil) { ... }
  Creates a receiver used to consumer messages from the given address.
- - (self) create_sender(address = nil, options = nil) { ... }
  Creates a sender used to send messages to the given address.

## Class Method Details

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

    22
    23
    24
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_client.rb', line 22

    def @@j_api_type.accept?(obj)
      obj.class == AmqpClient
    end

### + (`::VertxAmqpClient::AmqpClient`) create(options) + (`::VertxAmqpClient::AmqpClient`) create(vertx, options)

Creates a new instance of VertxAmqpClient::AmqpClient with the given Vert.x instance and the given options.

Overloads:

- + (`::VertxAmqpClient::AmqpClient`) create(options)

  Parameters:

  - options (`Hash`) —
    the AMQP client options, may be `null` falling back to the default configuration
- + (`::VertxAmqpClient::AmqpClient`) create(vertx, options)

  Parameters:

  - vertx (`::Vertx::Vertx`) —
    the vert.x instance, must not be `null`
  - options (`Hash`) —
    the AMQP options, may be @null falling back to the default configuration

Returns:

- (`::VertxAmqpClient::AmqpClient`) —
  the AMQP client instance

Raises:

- (`ArgumentError`)

    44
    45
    46
    47
    48
    49
    50
    51
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_client.rb', line 44

    def self.create(param_1=nil,param_2=nil)
      if param_1.class == Hash && !block_given? && param_2 == nil
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxAmqp::AmqpClient.java_method(:create, [Java::IoVertxAmqp::AmqpClientOptions.java_class]).call(Java::IoVertxAmqp::AmqpClientOptions.new(::Vertx::Util::Utils.to_json_object(param_1))),::VertxAmqpClient::AmqpClient)
      elsif param_1.class.method_defined?(:j_del) && param_2.class == Hash && !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxAmqp::AmqpClient.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxAmqp::AmqpClientOptions.java_class]).call(param_1.j_del,Java::IoVertxAmqp::AmqpClientOptions.new(::Vertx::Util::Utils.to_json_object(param_2))),::VertxAmqpClient::AmqpClient)
      end
      raise ArgumentError, "Invalid arguments when calling create(#{param_1},#{param_2})"
    end

### + (`Object`) j_api_type

    31
    32
    33
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_client.rb', line 31

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

    34
    35
    36
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_client.rb', line 34

    def self.j_class
      Java::IoVertxAmqp::AmqpClient.java_class
    end

### + (`Object`) unwrap(obj)

    28
    29
    30
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_client.rb', line 28

    def @@j_api_type.unwrap(obj)
      obj.j_del
    end

### + (`Object`) wrap(obj)

    25
    26
    27
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_client.rb', line 25

    def @@j_api_type.wrap(obj)
      AmqpClient.new(obj)
    end

## Instance Method Details

### - (`void`) close { ... }

This method returns an undefined value.

Closes the client. The client must always be closed once not needed anymore.

Yields:

- the close handler notified when the operation completes. It can be `null`.

Raises:

- (`ArgumentError`)

    67
    68
    69
    70
    71
    72
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_client.rb', line 67

    def close
      if block_given?
        return @j_del.java_method(:close, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
      end
      raise ArgumentError, "Invalid arguments when calling close()"
    end

### - (`self`) connect { ... }

Connects to the AMQP broker or router. The location is specified in the Hash as well as the potential credential required.

Yields:

- handler that will process the result, giving either the connection or failure cause. Must not be `null`.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    56
    57
    58
    59
    60
    61
    62
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_client.rb', line 56

    def connect
      if block_given?
        @j_del.java_method(:connect, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAmqpClient::AmqpConnection) : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling connect()"
    end

### - (`self`) create_receiver(address = nil, receiverOptions = nil) { ... }

Creates a receiver used to consumer messages from the given address. This method avoids having to connect explicitly. You can retrieve the connection using VertxAmqpClient::AmqpReceiver#connection.

Parameters:

- address (`String`) (defaults to: `nil`) —
  The source address to attach the consumer to.
- receiverOptions (`Hash`) (defaults to: `nil`) —
  The options for this receiver.

Yields:

- The handler called with the receiver, once opened. Note that the `messageHandler` can be called before the `completionHandler` if messages are awaiting delivery.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_client.rb', line 79

    def create_receiver(address=nil,receiverOptions=nil)
      if address.class == String && block_given? && receiverOptions == nil
        @j_del.java_method(:createReceiver, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(address,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAmqpClient::AmqpReceiver) : nil) }))
        return self
      elsif address.class == String && receiverOptions.class == Hash && block_given?
        @j_del.java_method(:createReceiver, [Java::java.lang.String.java_class,Java::IoVertxAmqp::AmqpReceiverOptions.java_class,Java::IoVertxCore::Handler.java_class]).call(address,Java::IoVertxAmqp::AmqpReceiverOptions.new(::Vertx::Util::Utils.to_json_object(receiverOptions)),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAmqpClient::AmqpReceiver) : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling create_receiver(#{address},#{receiverOptions})"
    end

### - (`self`) create_sender(address = nil, options = nil) { ... }

Creates a sender used to send messages to the given address. The address must be set.

Parameters:

- address (`String`) (defaults to: `nil`) —
  The target address to attach to, must not be `null`
- options (`Hash`) (defaults to: `nil`) —
  The options for this sender.

Yields:

- The handler called with the sender, once opened

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_client.rb', line 94

    def create_sender(address=nil,options=nil)
      if address.class == String && block_given? && options == nil
        @j_del.java_method(:createSender, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(address,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAmqpClient::AmqpSender) : nil) }))
        return self
      elsif address.class == String && options.class == Hash && block_given?
        @j_del.java_method(:createSender, [Java::java.lang.String.java_class,Java::IoVertxAmqp::AmqpSenderOptions.java_class,Java::IoVertxCore::Handler.java_class]).call(address,Java::IoVertxAmqp::AmqpSenderOptions.new(::Vertx::Util::Utils.to_json_object(options)),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAmqpClient::AmqpSender) : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling create_sender(#{address},#{options})"
    end