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
  @return The address the handler was registered with.
- - (::Vertx::ReadStream) body_stream
  @return 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
  @return the maximum number of messages that can be buffered when this stream is paused.
- - (self) handler { ... }
- - (self) pause
- - (true, false) registered?
  @return 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

@return The address the handler was registered with.

Returns:

- (`String`)

Raises:

- (`ArgumentError`)

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

    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

@return a read stream for the body of the message stream.

Returns:

- (`::Vertx::ReadStream`)

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

    116
    117
    118
    119
    120
    121
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/message_consumer.rb', line 116

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

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

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

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

    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

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

Returns:

- (`Fixnum`)

Raises:

- (`ArgumentError`)

    107
    108
    109
    110
    111
    112
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/message_consumer.rb', line 107

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

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

    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)) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling handler()"
    end

### - (`self`) pause

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

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

    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?

@return true if the current consumer is registered

Returns:

- (`true`, `false`)

Raises:

- (`ArgumentError`)

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

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

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

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

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

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

    125
    126
    127
    128
    129
    130
    131
    132
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/message_consumer.rb', line 125

    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