Class: Vertx::MessageConsumer

Inherits:
Object
  • Object
show all
Includes:
ReadStream
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/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)

Instance Method Details

- (String) address

Returns The address the handler was registered with.

Returns:

  • (String)
    The address the handler was registered with.

Raises:

  • (ArgumentError)

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

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:

Raises:

  • (ArgumentError)

110
111
112
113
114
115
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/message_consumer.rb', line 110

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)

153
154
155
156
157
158
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/message_consumer.rb', line 153

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)

102
103
104
105
106
107
108
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/message_consumer.rb', line 102

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)

59
60
61
62
63
64
65
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/message_consumer.rb', line 59

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) fetch(amount = nil)

Parameters:

  • amount (Fixnum) (defaults to: nil)

Returns:

  • (self)

Raises:

  • (ArgumentError)

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

def fetch(amount=nil)
  if amount.class == Fixnum && !block_given?
    @j_del.java_method(:fetch, [Java::long.java_class]).call(amount)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling fetch(#{amount})"
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)

144
145
146
147
148
149
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/message_consumer.rb', line 144

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)

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

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)

76
77
78
79
80
81
82
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/message_consumer.rb', line 76

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

- (::Vertx::Pipe) pipe

Pause this stream and return a to transfer the elements of this stream to a destination .

The stream will be resumed when the pipe will be wired to a WriteStream.

Returns:

Raises:

  • (ArgumentError)

34
35
36
37
38
39
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/message_consumer.rb', line 34

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

- (void) pipe_to(dst = nil) { ... }

This method returns an undefined value.

Pipe this ReadStream to the WriteStream.

Elements emitted by this stream will be written to the write stream until this stream ends or fails.

Once this stream has ended or failed, the write stream will be ended and the handler will be called with the result.

Parameters:

Yields:

Raises:

  • (ArgumentError)

49
50
51
52
53
54
55
56
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/message_consumer.rb', line 49

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

- (true, false) registered?

Returns true if the current consumer is registered

Returns:

  • (true, false)
    true if the current consumer is registered

Raises:

  • (ArgumentError)

117
118
119
120
121
122
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/message_consumer.rb', line 117

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)

84
85
86
87
88
89
90
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/message_consumer.rb', line 84

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. The most recent messages will be kept.

Parameters:

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

Returns:

Raises:

  • (ArgumentError)

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

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)

162
163
164
165
166
167
168
169
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/message_consumer.rb', line 162

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