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)


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

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)


81
82
83
84
85
86
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/message_consumer.rb', line 81

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)


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


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

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-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/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

- (self) fetch(amount = nil)

Parameters:

  • amount (Fixnum) (defaults to: nil)

Returns:

  • (self)

Raises:

  • (ArgumentError)


64
65
66
67
68
69
70
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/message_consumer.rb', line 64

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)


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

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-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/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-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/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)


88
89
90
91
92
93
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/message_consumer.rb', line 88

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-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/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. 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)


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

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)


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

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