Class List Method List File List

# Class: VertxAmqpClient::AmqpConnection

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

## Overview

Once connected to the broker or router, you get a connection. This connection is automatically opened.

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (self) close { ... }
  Closes the AMQP connection, i.e.
- - (self) create_anonymous_sender { ... }
  Creates an anonymous sender.
- - (self) create_dynamic_receiver { ... }
  Creates a dynamic receiver.
- - (self) create_receiver(param_1 = nil, param_2 = nil, param_3 = 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.
- - (self) exception_handler { ... }
  Registers a handler called on disconnection.

## Class Method Details

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

Returns:

- (`Boolean`)

    20
    21
    22
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_connection.rb', line 20

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

### + (`Object`) j_api_type

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

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

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

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

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

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

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

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

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

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

## Instance Method Details

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

Closes the AMQP connection, i.e. allows the Close frame to be emitted.

Yields:

- the close handler notified when the connection is closed. May be `null`.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    48
    49
    50
    51
    52
    53
    54
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_connection.rb', line 48

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

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

Creates an anonymous sender.

Unlike "regular" sender, this sender is not associated to a specific address, and each message sent must provide an address. This method can be used in request-reply scenarios where you create a sender to send the reply, but you don't know the address, as the reply address is passed into the message you are going to receive.

Yields:

- The handler called with the created sender, once opened

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    124
    125
    126
    127
    128
    129
    130
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_connection.rb', line 124

    def create_anonymous_sender
      if block_given?
        @j_del.java_method(:createAnonymousSender, [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::AmqpSender) : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling create_anonymous_sender()"
    end

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

Creates a dynamic receiver. The address is provided by the broker and is available in the `completionHandler`, using the VertxAmqpClient::AmqpReceiver#address method. this method is useful for request-reply to generate a unique reply address.

Yields:

- the completion handler, called when the receiver has been created and opened.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

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

    def create_dynamic_receiver
      if block_given?
        @j_del.java_method(:createDynamicReceiver, [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::AmqpReceiver) : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling create_dynamic_receiver()"
    end

### - (`self`) createReceiver(address, completionHandler) { ... } - (`self`) createReceiver(address, messageHandler, completionHandler) { ... } - (`self`) createReceiver(address, receiverOptions, completionHandler) { ... } - (`self`) createReceiver(address, receiverOptions, messageHandler, completionHandler) { ... }

Creates a receiver used to consumer messages from the given address.

Overloads:

- - (`self`) createReceiver(address, completionHandler) { ... }

  Parameters:

  - address (`String`) —
    The source address to attach the consumer to, must not be `null`

  Yields:

  - the handler called with the receiver. The receiver has been opened.
- - (`self`) createReceiver(address, messageHandler, completionHandler) { ... }

  Parameters:

  - address (`String`) —
    The source address to attach the consumer to, must not be `null`
  - messageHandler (`Proc`) —
    The message handler, must not be `null`

  Yields:

  - the handler called with the receiver that has been opened. Note that the `messageHandler` can be called before the `completionHandler` if messages are awaiting delivery.
- - (`self`) createReceiver(address, receiverOptions, completionHandler) { ... }

  Parameters:

  - address (`String`) —
    The source address to attach the consumer to.
  - receiverOptions (`Hash`) —
    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.
- - (`self`) createReceiver(address, receiverOptions, messageHandler, completionHandler) { ... }

  Parameters:

  - address (`String`) —
    The source address to attach the consumer to.
  - receiverOptions (`Hash`) —
    The options for this receiver.
  - messageHandler (`Proc`) —
    The message handler, must not be `null`

  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`)

    73
    74
    75
    76
    77
    78
    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_connection.rb', line 73

    def create_receiver(param_1=nil,param_2=nil,param_3=nil)
      if param_1.class == String && block_given? && param_2 == nil && param_3 == nil
        @j_del.java_method(:createReceiver, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAmqpClient::AmqpReceiver) : nil) }))
        return self
      elsif param_1.class == String && param_2.class == Proc && block_given? && param_3 == nil
        @j_del.java_method(:createReceiver, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1,(Proc.new { |event| param_2.call(::Vertx::Util::Utils.safe_create(event,::VertxAmqpClient::AmqpMessage)) }),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAmqpClient::AmqpReceiver) : nil) }))
        return self
      elsif param_1.class == String && param_2.class == Hash && block_given? && param_3 == nil
        @j_del.java_method(:createReceiver, [Java::java.lang.String.java_class,Java::IoVertxAmqp::AmqpReceiverOptions.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1,Java::IoVertxAmqp::AmqpReceiverOptions.new(::Vertx::Util::Utils.to_json_object(param_2)),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAmqpClient::AmqpReceiver) : nil) }))
        return self
      elsif param_1.class == String && param_2.class == Hash && param_3.class == Proc && block_given?
        @j_del.java_method(:createReceiver, [Java::java.lang.String.java_class,Java::IoVertxAmqp::AmqpReceiverOptions.java_class,Java::IoVertxCore::Handler.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1,Java::IoVertxAmqp::AmqpReceiverOptions.new(::Vertx::Util::Utils.to_json_object(param_2)),(Proc.new { |event| param_3.call(::Vertx::Util::Utils.safe_create(event,::VertxAmqpClient::AmqpMessage)) }),(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(#{param_1},#{param_2},#{param_3})"
    end

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

Creates a sender used to send messages to the given address. The address must be set. For anonymous sender, check #create_anonymous_sender.

Parameters:

- address (`String`) (defaults to: `nil`) —
  The target address to attach to, allowed to be `null` if the `options` configures the sender to be attached to a dynamic address (provided by the broker).
- options (`Hash`) (defaults to: `nil`) —
  The AMQP sender options

Yields:

- The handler called with the sender, once opened

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_connection.rb', line 107

    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

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

Registers a handler called on disconnection.

Yields:

- the exception handler.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    38
    39
    40
    41
    42
    43
    44
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_connection.rb', line 38

    def exception_handler
      if block_given?
        @j_del.java_method(:exceptionHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_throwable(event)) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling exception_handler()"
    end