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(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.
- - (true, false) disconnected?
  Whether the connection has been disconnected.
- - (self) exception_handler { ... }
  Registers a handler called on disconnection.

## Class Method Details

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

Returns:

- (`Boolean`)

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

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

### + (`Object`) j_api_type

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

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

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

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

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

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

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

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

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

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

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

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

    104
    105
    106
    107
    108
    109
    110
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_connection.rb', line 104

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

    74
    75
    76
    77
    78
    79
    80
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_connection.rb', line 74

    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`) create_receiver(address = nil, receiverOptions = nil) { ... }

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

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

    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_connection.rb', line 59

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

    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_connection.rb', line 87

    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

### - (`true`, `false`) disconnected?

Returns whether the connection has been disconnected.

Returns:

- (`true`, `false`) —
  whether the connection has been disconnected.

Raises:

- (`ArgumentError`)

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

    def disconnected?
      if !block_given?
        return @j_del.java_method(:isDisconnected, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling disconnected?()"
    end

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

Registers a handler called on disconnection.

Yields:

- the exception handler.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

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

    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