Class: Vertx::Message
- Inherits:
-
Object
- Object
- Vertx::Message
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/message.rb
Overview
Represents a message that is received from the event bus in a handler.
Messages have a #body, which can be null, and also #headers, which can be empty.
If the message was sent specifying a reply handler it will also have a #reply_address. In that case the message can be replied to using that reply address, or, more simply by just using #reply.
If you want to notify the sender that processing failed, then #fail can be called.
Instance Method Summary (collapse)
-
- (String) address
The address the message was sent to.
-
- (Object) body
The body of the message.
-
- (void) fail(failureCode = nil, message = nil)
Signal to the sender that processing of this message failed.
-
- (::Vertx::MultiMap) headers
Multi-map of message headers.
-
- (void) reply(message = nil, options = nil) { ... }
The same as reply(R message, DeliveryOptions) but you can specify handler for the reply - i.e.
-
- (String) reply_address
The reply address.
Instance Method Details
- (String) address
The address the message was sent to
26 27 28 29 30 31 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/message.rb', line 26 def address if !block_given? return @j_del.java_method(:address, []).call() end raise ArgumentError, "Invalid arguments when calling address()" end |
- (Object) body
The body of the message. Can be null.
42 43 44 45 46 47 48 49 50 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/message.rb', line 42 def body if !block_given? if @cached_body != nil return @cached_body end return @cached_body = ::Vertx::Util::Utils.from_object(@j_del.java_method(:body, []).call()) end raise ArgumentError, "Invalid arguments when calling body()" end |
- (void) fail(failureCode = nil, message = nil)
This method returns an undefined value.
Signal to the sender that processing of this message failed.If the message was sent specifying a result handler the handler will be called with a failure corresponding to the failure code and message specified here.
84 85 86 87 88 89 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/message.rb', line 84 def fail(failureCode=nil,=nil) if failureCode.class == Fixnum && .class == String && !block_given? return @j_del.java_method(:fail, [Java::int.java_class,Java::java.lang.String.java_class]).call(failureCode,) end raise ArgumentError, "Invalid arguments when calling fail(failureCode,message)" end |
- (::Vertx::MultiMap) headers
Multi-map of message headers. Can be empty
34 35 36 37 38 39 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/message.rb', line 34 def headers if !block_given? return ::Vertx::MultiMap.new(@j_del.java_method(:headers, []).call()) end raise ArgumentError, "Invalid arguments when calling headers()" end |
- (void) reply(message = nil, options = nil) { ... }
This method returns an undefined value.
The same asreply(R message, DeliveryOptions)
but you can specify handler for the reply - i.e.
to receive the reply to the reply.
65 66 67 68 69 70 71 72 73 74 75 76 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/message.rb', line 65 def reply(=nil,=nil) if (.class == String || .class == Hash || .class == Array || .class == NilClass || .class == TrueClass || .class == FalseClass || .class == Fixnum || .class == Float) && !block_given? && == nil return @j_del.java_method(:reply, [Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object()) elsif (.class == String || .class == Hash || .class == Array || .class == NilClass || .class == TrueClass || .class == FalseClass || .class == Fixnum || .class == Float) && block_given? && == nil return @j_del.java_method(:reply, [Java::java.lang.Object.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_object(),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Message.new(ar.result) : nil) })) elsif (.class == String || .class == Hash || .class == Array || .class == NilClass || .class == TrueClass || .class == FalseClass || .class == Fixnum || .class == Float) && .class == Hash && !block_given? return @j_del.java_method(:reply, [Java::java.lang.Object.java_class,Java::IoVertxCoreEventbus::DeliveryOptions.java_class]).call(::Vertx::Util::Utils.to_object(),Java::IoVertxCoreEventbus::DeliveryOptions.new(::Vertx::Util::Utils.to_json_object())) elsif (.class == String || .class == Hash || .class == Array || .class == NilClass || .class == TrueClass || .class == FalseClass || .class == Fixnum || .class == Float) && .class == Hash && block_given? return @j_del.java_method(:reply, [Java::java.lang.Object.java_class,Java::IoVertxCoreEventbus::DeliveryOptions.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_object(),Java::IoVertxCoreEventbus::DeliveryOptions.new(::Vertx::Util::Utils.to_json_object()),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Message.new(ar.result) : nil) })) end raise ArgumentError, "Invalid arguments when calling reply(message,options)" end |
- (String) reply_address
The reply address. Can be null.
53 54 55 56 57 58 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/message.rb', line 53 def reply_address if !block_given? return @j_del.java_method(:replyAddress, []).call() end raise ArgumentError, "Invalid arguments when calling reply_address()" end |