Class List Method List File List

# Class: Vertx::MessageConsumer

Inherits:
  Object
  - Object
  - Vertx::MessageConsumer
  show all
Includes:
  ReadStream
Defined in:
  /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/message_consumer.rb

## Overview

An event bus consumer object representing a stream of message to an EventBus address that can be read from.

The EventBus#consumer or EventBus#local_consumer creates a new consumer, the returned consumer is not yet registered against the event bus. Registration is effective after the #handler method is invoked.

The consumer is unregistered from the event bus using the #unregister method or by calling the #handler with a null value..

## Instance Method Summary (collapse)

- - (String) address
  The address the handler was registered with.
- - (::Vertx::ReadStream) body_stream
  A read stream for the body of the message stream.
- - (void) completion_handler { ... }
  Optional method which can be called to indicate when the registration has been propagated across the cluster.
- - (self) end_handler { ... }
- - (self) exception_handler { ... }
- - (Fixnum) get_max_buffered_messages
  The maximum number of messages that can be buffered when this stream is paused.
- - (self) handler { ... }
- - (self) pause
- - (true, false) registered?
  True if the current consumer is registered.
- - (self) resume
- - (::Vertx::MessageConsumer) set_max_buffered_messages(maxBufferedMessages = nil)
  Set the number of messages this registration will buffer when this stream is paused.
- - (void) unregister { ... }
  Unregisters the handler which created this registration.

## Instance Method Details

### - (`String`) address

Returns The address the handler was registered with.

Returns:

- (`String`) —
  The address the handler was registered with.

Raises:

- (`ArgumentError`)

    86
    87
    88
    89
    90
    91
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/message_consumer.rb', line 86

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

### - (`::Vertx::ReadStream`) body_stream

Returns a read stream for the body of the message stream.

Returns:

- (`::Vertx::ReadStream`) —
  a read stream for the body of the message stream.

Raises:

- (`ArgumentError`)

    72
    73
    74
    75
    76
    77
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/message_consumer.rb', line 72

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

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

This method returns an undefined value.

Optional method which can be called to indicate when the registration has been propagated across the cluster.

Yields:

- the completion handler

Raises:

- (`ArgumentError`)

    113
    114
    115
    116
    117
    118
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/message_consumer.rb', line 113

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

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

Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    64
    65
    66
    67
    68
    69
    70
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/message_consumer.rb', line 64

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

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

Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    30
    31
    32
    33
    34
    35
    36
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/message_consumer.rb', line 30

    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

### - (`Fixnum`) get_max_buffered_messages

Returns the maximum number of messages that can be buffered when this stream is paused

Returns:

- (`Fixnum`) —
  the maximum number of messages that can be buffered when this stream is paused

Raises:

- (`ArgumentError`)

    104
    105
    106
    107
    108
    109
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/message_consumer.rb', line 104

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

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

Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    39
    40
    41
    42
    43
    44
    45
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/message_consumer.rb', line 39

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

### - (`self`) pause

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    47
    48
    49
    50
    51
    52
    53
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/message_consumer.rb', line 47

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

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

Returns true if the current consumer is registered

Returns:

- (`true`, `false`) —
  true if the current consumer is registered

Raises:

- (`ArgumentError`)

    79
    80
    81
    82
    83
    84
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/message_consumer.rb', line 79

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

### - (`self`) resume

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    55
    56
    57
    58
    59
    60
    61
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/message_consumer.rb', line 55

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

### - (`::Vertx::MessageConsumer`) set_max_buffered_messages(maxBufferedMessages = nil)

Set the number of messages this registration will buffer when this stream is paused. The default value is `1000`. When a new value is set, buffered messages may be discarded to reach the new value.

Parameters:

- maxBufferedMessages (`Fixnum`) (defaults to: `nil`) —
  the maximum number of messages that can be buffered

Returns:

- (`::Vertx::MessageConsumer`) —
  this registration

Raises:

- (`ArgumentError`)

    97
    98
    99
    100
    101
    102
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/message_consumer.rb', line 97

    def set_max_buffered_messages(maxBufferedMessages=nil)
      if maxBufferedMessages.class == Fixnum && !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:setMaxBufferedMessages, [Java::int.java_class]).call(maxBufferedMessages),::Vertx::MessageConsumer, nil)
      end
      raise ArgumentError, "Invalid arguments when calling set_max_buffered_messages(#{maxBufferedMessages})"
    end

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

This method returns an undefined value.

Unregisters the handler which created this registration

Yields:

- the handler called when the unregister is done. For example in a cluster when all nodes of the event bus have been unregistered.

Raises:

- (`ArgumentError`)

    122
    123
    124
    125
    126
    127
    128
    129
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/message_consumer.rb', line 122

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