Class: Vertx::EventBus

Inherits:
Object
  • Object
show all
Includes:
Measured
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/event_bus.rb

Overview

A Vert.x event-bus is a light-weight distributed messaging system which allows different parts of your application, or different applications and services to communicate with each in a loosely coupled way.

An event-bus supports publish-subscribe messaging, point-to-point messaging and request-response messaging.

Message delivery is best-effort and messages can be lost if failure of all or part of the event bus occurs.

Please refer to the documentation for more information on the event bus.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


32
33
34
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/event_bus.rb', line 32

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

+ (Object) j_api_type



41
42
43
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/event_bus.rb', line 41

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



44
45
46
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/event_bus.rb', line 44

def self.j_class
  Java::IoVertxCoreEventbus::EventBus.java_class
end

+ (Object) unwrap(obj)



38
39
40
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/event_bus.rb', line 38

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

+ (Object) wrap(obj)



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

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

Instance Method Details

- (self) addInboundInterceptor(interceptor) { ... }

Add an interceptor that will be called whenever a message is received by Vert.x

Yields:

  • the interceptor

Returns:

  • (self)


221
222
223
224
225
226
227
228
229
230
231
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/event_bus.rb', line 221

def add_inbound_interceptor
  if true
    @j_del.java_method(:addInboundInterceptor, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::Vertx::DeliveryContext, nil)) unless !block_given? }))
    return self
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling add_inbound_interceptor()"
  end
end

- (self) addOutboundInterceptor(interceptor) { ... }

Add an interceptor that will be called whenever a message is sent from Vert.x

Yields:

  • the interceptor

Returns:

  • (self)


163
164
165
166
167
168
169
170
171
172
173
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/event_bus.rb', line 163

def add_outbound_interceptor
  if true
    @j_del.java_method(:addOutboundInterceptor, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::Vertx::DeliveryContext, nil)) unless !block_given? }))
    return self
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling add_outbound_interceptor()"
  end
end

- (::Vertx::MessageConsumer) consumer(address) - (::Vertx::MessageConsumer) consumer(address, handler) { ... }

Create a consumer and register it against the specified address.

Overloads:

  • - (::Vertx::MessageConsumer) consumer(address)

    Parameters:

    • address (String)
      the address that it will register it at
  • - (::Vertx::MessageConsumer) consumer(address, handler) { ... }

    Parameters:

    • address (String)
      the address that will register it at

    Yields:

    • the handler that will process the received messages

Returns:



239
240
241
242
243
244
245
246
247
248
249
250
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/event_bus.rb', line 239

def consumer(*args)
  if args[0].class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:consumer, [Java::java.lang.String.java_class]).call(args[0]),::Vertx::MessageConsumer, nil)
  elsif args[0].class == String && true
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:consumer, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],(Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::Vertx::Message, nil)) unless !block_given? })),::Vertx::MessageConsumer, nil)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling consumer(#{args[0]})"
  end
end

- (::Vertx::MessageConsumer) localConsumer(address) - (::Vertx::MessageConsumer) localConsumer(address, handler) { ... }

Like #consumer but the address won't be propagated across the cluster.

Overloads:

  • - (::Vertx::MessageConsumer) localConsumer(address)

    Parameters:

    • address (String)
      the address to register it at
  • - (::Vertx::MessageConsumer) localConsumer(address, handler) { ... }

    Parameters:

    • address (String)
      the address that will register it at

    Yields:

    • the handler that will process the received messages

Returns:



124
125
126
127
128
129
130
131
132
133
134
135
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/event_bus.rb', line 124

def local_consumer(*args)
  if args[0].class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:localConsumer, [Java::java.lang.String.java_class]).call(args[0]),::Vertx::MessageConsumer, nil)
  elsif args[0].class == String && true
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:localConsumer, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],(Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::Vertx::Message, nil)) unless !block_given? })),::Vertx::MessageConsumer, nil)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling local_consumer(#{args[0]})"
  end
end

- (true, false) isMetricsEnabled

Whether the metrics are enabled for this measured object

Returns:

  • (true, false)
    true if metrics are enabled


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

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

- (self) publish(address, message) - (self) publish(address, message, options)

Like #publish but specifying options that can be used to configure the delivery.

Overloads:

  • - (self) publish(address, message)

    Parameters:

    • address (String)
      the address to publish it to
    • message (Object)
      the message, may be null
  • - (self) publish(address, message, options)

    Parameters:

    • address (String)
      the address to publish it to
    • message (Object)
      the message, may be null
    • options (Hash{String => Object})
      the delivery options

Returns:

  • (self)


145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/event_bus.rb', line 145

def publish(*args)
  if args[0].class == String && ::Vertx::Util::unknown_type.accept?(args[1]) && !block_given? && args[2] == nil
    @j_del.java_method(:publish, [Java::java.lang.String.java_class,Java::java.lang.Object.java_class]).call(args[0],::Vertx::Util::Utils.to_object(args[1]))
    return self
  elsif args[0].class == String && ::Vertx::Util::unknown_type.accept?(args[1]) && args[2].class == Hash && !block_given?
    @j_del.java_method(:publish, [Java::java.lang.String.java_class,Java::java.lang.Object.java_class,Java::IoVertxCoreEventbus::DeliveryOptions.java_class]).call(args[0],::Vertx::Util::Utils.to_object(args[1]),Java::IoVertxCoreEventbus::DeliveryOptions.new(::Vertx::Util::Utils.to_json_object(args[2])))
    return self
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling publish(#{args[0]},#{args[1]},#{args[2]})"
  end
end

- (::Vertx::MessageProducer) publisher(address) - (::Vertx::MessageProducer) publisher(address, options)

Like #publisher but specifying delivery options that will be used for configuring the delivery of the message.

Overloads:

  • - (::Vertx::MessageProducer) publisher(address)

    Parameters:

    • address (String)
      The address to publish it to
  • - (::Vertx::MessageProducer) publisher(address, options)

    Parameters:

    • address (String)
      the address to publish it to
    • options (Hash{String => Object})
      the delivery options

Returns:



182
183
184
185
186
187
188
189
190
191
192
193
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/event_bus.rb', line 182

def publisher(*args)
  if args[0].class == String && !block_given? && args[1] == nil
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:publisher, [Java::java.lang.String.java_class]).call(args[0]),::Vertx::MessageProducer, nil)
  elsif args[0].class == String && args[1].class == Hash && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:publisher, [Java::java.lang.String.java_class,Java::IoVertxCoreEventbus::DeliveryOptions.java_class]).call(args[0],Java::IoVertxCoreEventbus::DeliveryOptions.new(::Vertx::Util::Utils.to_json_object(args[1]))),::Vertx::MessageProducer, nil)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling publisher(#{args[0]},#{args[1]})"
  end
end

- (self) removeInboundInterceptor(interceptor) { ... }

Remove an interceptor that was added by #add_inbound_interceptor

Yields:

  • the interceptor

Returns:

  • (self)


255
256
257
258
259
260
261
262
263
264
265
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/event_bus.rb', line 255

def remove_inbound_interceptor
  if true
    @j_del.java_method(:removeInboundInterceptor, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::Vertx::DeliveryContext, nil)) unless !block_given? }))
    return self
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling remove_inbound_interceptor()"
  end
end

- (self) removeOutboundInterceptor(interceptor) { ... }

Remove an interceptor that was added by #add_outbound_interceptor

Yields:

  • the interceptor

Returns:

  • (self)


270
271
272
273
274
275
276
277
278
279
280
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/event_bus.rb', line 270

def remove_outbound_interceptor
  if true
    @j_del.java_method(:removeOutboundInterceptor, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::Vertx::DeliveryContext, nil)) unless !block_given? }))
    return self
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling remove_outbound_interceptor()"
  end
end

- (self) request(address, message, replyHandler) { ... } - (self) request(address, message, options, replyHandler) { ... }

Like #request but specifying options that can be used to configure the delivery.

Overloads:

  • - (self) request(address, message, replyHandler) { ... }

    Parameters:

    • address (String)
      the address to send it to
    • message (Object)
      the message body, may be null

    Yields:

    • reply handler will be called when any reply from the recipient is received
  • - (self) request(address, message, options, replyHandler) { ... }

    Parameters:

    • address (String)
      the address to send it to
    • message (Object)
      the message body, may be null
    • options (Hash{String => Object})
      delivery options

    Yields:

    • reply handler will be called when any reply from the recipient is received

Returns:

  • (self)


71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/event_bus.rb', line 71

def request(*args)
  if args[0].class == String && ::Vertx::Util::unknown_type.accept?(args[1]) && true && args[2] == nil
    if (block_given?)
      @j_del.java_method(:request, [Java::java.lang.String.java_class,Java::java.lang.Object.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],::Vertx::Util::Utils.to_object(args[1]),block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Message, nil) : nil) } : promise)
      return self
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:request, [Java::java.lang.String.java_class,Java::java.lang.Object.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],::Vertx::Util::Utils.to_object(args[1]),block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Message, nil) : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::Vertx::Message.j_api_type)
    end
  elsif args[0].class == String && ::Vertx::Util::unknown_type.accept?(args[1]) && args[2].class == Hash && true
    if (block_given?)
      @j_del.java_method(:request, [Java::java.lang.String.java_class,Java::java.lang.Object.java_class,Java::IoVertxCoreEventbus::DeliveryOptions.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],::Vertx::Util::Utils.to_object(args[1]),Java::IoVertxCoreEventbus::DeliveryOptions.new(::Vertx::Util::Utils.to_json_object(args[2])),block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Message, nil) : nil) } : promise)
      return self
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:request, [Java::java.lang.String.java_class,Java::java.lang.Object.java_class,Java::IoVertxCoreEventbus::DeliveryOptions.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],::Vertx::Util::Utils.to_object(args[1]),Java::IoVertxCoreEventbus::DeliveryOptions.new(::Vertx::Util::Utils.to_json_object(args[2])),block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Message, nil) : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::Vertx::Message.j_api_type)
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling request(#{args[0]},#{args[1]},#{args[2]})"
  end
end

- (self) send(address, message) - (self) send(address, message, options)

Like #send but specifying options that can be used to configure the delivery.

Overloads:

  • - (self) send(address, message)

    Parameters:

    • address (String)
      the address to send it to
    • message (Object)
      the message, may be null
  • - (self) send(address, message, options)

    Parameters:

    • address (String)
      the address to send it to
    • message (Object)
      the message, may be null
    • options (Hash{String => Object})
      delivery options

Returns:

  • (self)


203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/event_bus.rb', line 203

def send(*args)
  if args[0].class == String && ::Vertx::Util::unknown_type.accept?(args[1]) && !block_given? && args[2] == nil
    @j_del.java_method(:send, [Java::java.lang.String.java_class,Java::java.lang.Object.java_class]).call(args[0],::Vertx::Util::Utils.to_object(args[1]))
    return self
  elsif args[0].class == String && ::Vertx::Util::unknown_type.accept?(args[1]) && args[2].class == Hash && !block_given?
    @j_del.java_method(:send, [Java::java.lang.String.java_class,Java::java.lang.Object.java_class,Java::IoVertxCoreEventbus::DeliveryOptions.java_class]).call(args[0],::Vertx::Util::Utils.to_object(args[1]),Java::IoVertxCoreEventbus::DeliveryOptions.new(::Vertx::Util::Utils.to_json_object(args[2])))
    return self
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling send(#{args[0]},#{args[1]},#{args[2]})"
  end
end

- (::Vertx::MessageProducer) sender(address) - (::Vertx::MessageProducer) sender(address, options)

Like #sender but specifying delivery options that will be used for configuring the delivery of the message.

Overloads:

  • - (::Vertx::MessageProducer) sender(address)

    Parameters:

    • address (String)
      the address to send it to
  • - (::Vertx::MessageProducer) sender(address, options)

    Parameters:

    • address (String)
      the address to send it to
    • options (Hash{String => Object})
      the delivery options

Returns:



105
106
107
108
109
110
111
112
113
114
115
116
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/event_bus.rb', line 105

def sender(*args)
  if args[0].class == String && !block_given? && args[1] == nil
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:sender, [Java::java.lang.String.java_class]).call(args[0]),::Vertx::MessageProducer, nil)
  elsif args[0].class == String && args[1].class == Hash && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:sender, [Java::java.lang.String.java_class,Java::IoVertxCoreEventbus::DeliveryOptions.java_class]).call(args[0],Java::IoVertxCoreEventbus::DeliveryOptions.new(::Vertx::Util::Utils.to_json_object(args[1]))),::Vertx::MessageProducer, nil)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling sender(#{args[0]},#{args[1]})"
  end
end