Class List Method List File List

# Class: VertxAmqpClient::AmqpSender

Inherits:
  Object
  - Object
  - VertxAmqpClient::AmqpSender
  show all
Includes:
  Vertx::WriteStream
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_sender.rb

## Overview

AMQP Sender interface used to send messages.

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

- - (String) address
  The configured address.
- - (void) close { ... }
  Closes the sender.
- - (::VertxAmqpClient::AmqpConnection) connection
  Gets the connection having created the sender.
- - (self) drain_handler { ... }
  Set a drain handler on the stream.
- - (void) end(data = nil) { ... }
  Same as but with an handler called when the operation completes.
- - (self) exception_handler { ... }
- - (self) send(message = nil)
  Sends an AMQP message.
- - (self) send_with_ack(message = nil) { ... }
  Sends an AMQP message and waits for an acknowledgement.
- - (self) set_write_queue_max_size(maxSize = nil)
- - (self) write(data = nil) { ... }
- - (true, false) write_queue_full?
  This will return true if there are more bytes in the write queue than the value set using #set_write_queue_max_size.

## Class Method Details

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

Returns:

- (`Boolean`)

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

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

### + (`Object`) j_api_type

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

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

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

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

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

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

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

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

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

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

## Instance Method Details

### - (`String`) address

Returns the configured address.

Returns:

- (`String`) —
  the configured address.

Raises:

- (`ArgumentError`)

    138
    139
    140
    141
    142
    143
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_sender.rb', line 138

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

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

This method returns an undefined value.

Closes the sender.

Yields:

- called when the sender has been closed, must not be `null`

Raises:

- (`ArgumentError`)

    131
    132
    133
    134
    135
    136
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_sender.rb', line 131

    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

### - (`::VertxAmqpClient::AmqpConnection`) connection

Gets the connection having created the sender. Cannot be `null`

Returns:

- (`::VertxAmqpClient::AmqpConnection`) —
  the connection having created the sender.

Raises:

- (`ArgumentError`)

    146
    147
    148
    149
    150
    151
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_sender.rb', line 146

    def connection
      if !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:connection, []).call(),::VertxAmqpClient::AmqpConnection)
      end
      raise ArgumentError, "Invalid arguments when calling connection()"
    end

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

Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue is ready to accept buffers again. See for an example of this being used.

The stream implementation defines when the drain handler, for example it could be when the queue size has been reduced to `maxSize / 2`.

Yields:

- the handler

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

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

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

### - (`void`) end(data = nil) { ... }

This method returns an undefined value.

Same as but with an `handler` called when the operation completes

Parameters:

- data (`::VertxAmqpClient::AmqpMessage`) (defaults to: `nil`)

Yields:

Raises:

- (`ArgumentError`)

    40
    41
    42
    43
    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_sender.rb', line 40

    def end(data=nil)
      if !block_given? && data == nil
        return @j_del.java_method(:end, []).call()
      elsif block_given? && data == nil
        return @j_del.java_method(:end, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
      elsif data.class.method_defined?(:j_del) && !block_given?
        return @j_del.java_method(:end, [Java::IoVertxAmqp::AmqpMessage.java_class]).call(data.j_del)
      elsif data.class.method_defined?(:j_del) && block_given?
        return @j_del.java_method(:end, [Java::IoVertxAmqp::AmqpMessage.java_class,Java::IoVertxCore::Handler.java_class]).call(data.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
      end
      raise ArgumentError, "Invalid arguments when calling end(#{data})"
    end

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

Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

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

    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

### - (`self`) send(message = nil)

Sends an AMQP message. The destination the configured sender address or the address configured in the message.

Parameters:

- message (`::VertxAmqpClient::AmqpMessage`) (defaults to: `nil`) —
  the message, must not be `null`

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

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

    def send(message=nil)
      if message.class.method_defined?(:j_del) && !block_given?
        @j_del.java_method(:send, [Java::IoVertxAmqp::AmqpMessage.java_class]).call(message.j_del)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling send(#{message})"
    end

### - (`self`) send_with_ack(message = nil) { ... }

Sends an AMQP message and waits for an acknowledgement. The acknowledgement handler is called with an marked as failed if the message has been rejected or re-routed. If the message has been accepted, the handler is called with a success.

Parameters:

- message (`::VertxAmqpClient::AmqpMessage`) (defaults to: `nil`) —
  the message, must not be `null`

Yields:

- the acknowledgement handler, must not be `null`

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    121
    122
    123
    124
    125
    126
    127
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_sender.rb', line 121

    def send_with_ack(message=nil)
      if message.class.method_defined?(:j_del) && block_given?
        @j_del.java_method(:sendWithAck, [Java::IoVertxAmqp::AmqpMessage.java_class,Java::IoVertxCore::Handler.java_class]).call(message.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling send_with_ack(#{message})"
    end

### - (`self`) set_write_queue_max_size(maxSize = nil)

Parameters:

- maxSize (`Fixnum`) (defaults to: `nil`)

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    98
    99
    100
    101
    102
    103
    104
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_sender.rb', line 98

    def set_write_queue_max_size(maxSize=nil)
      if maxSize.class == Fixnum && !block_given?
        @j_del.java_method(:setWriteQueueMaxSize, [Java::int.java_class]).call(maxSize)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling set_write_queue_max_size(#{maxSize})"
    end

### - (`self`) write(data = nil) { ... }

Parameters:

- data (`::VertxAmqpClient::AmqpMessage`) (defaults to: `nil`)

Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

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

    def write(data=nil)
      if data.class.method_defined?(:j_del) && !block_given?
        @j_del.java_method(:write, [Java::IoVertxAmqp::AmqpMessage.java_class]).call(data.j_del)
        return self
      elsif data.class.method_defined?(:j_del) && block_given?
        @j_del.java_method(:write, [Java::IoVertxAmqp::AmqpMessage.java_class,Java::IoVertxCore::Handler.java_class]).call(data.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling write(#{data})"
    end

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

This will return `true` if there are more bytes in the write queue than the value set using #set_write_queue_max_size

Returns:

- (`true`, `false`) —
  true if write queue is full

Raises:

- (`ArgumentError`)

    54
    55
    56
    57
    58
    59
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_sender.rb', line 54

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