Class: Vertx::Message

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/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 can be replied to using #reply.

If you want to notify the sender that processing failed, then #fail can be called.

Instance Method Summary (collapse)

Instance Method Details

- (String) address

The address the message was sent to

Returns:

  • (String)


60
61
62
63
64
65
66
67
68
69
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/message.rb', line 60

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

- (Object) body

The body of the message. Can be null.

Returns:

  • (Object)
    the body, or null.


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

def body
  if !block_given?
    if @cached_body != nil
      return @cached_body
    end
    return @cached_body = @j_arg_T.wrap(@j_del.java_method(:body, []).call())
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling body()"
  end
end

- (void) fail(failureCode, message)

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.

Parameters:

  • failureCode (Fixnum)
    A failure code to pass back to the sender
  • message (String)
    A message to pass back to the sender


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

def fail(*args)
  if args[0].class == Fixnum && args[1].class == String && !block_given?
    return @j_del.java_method(:fail, [Java::int.java_class,Java::java.lang.String.java_class]).call(args[0],args[1])
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling fail(#{args[0]},#{args[1]})"
  end
end

- (::Vertx::MultiMap) headers

Multi-map of message headers. Can be empty

Returns:



47
48
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.rb', line 47

def headers
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:headers, []).call(),::Vertx::MultiMap)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling headers()"
  end
end

- (void) reply(message) - (void) reply(message, options)

This method returns an undefined value.

Link #reply but allows you to specify delivery options for the reply.

Overloads:

  • - (void) reply(message)

    Parameters:

    • message (Object)
      the message to reply with.
  • - (void) reply(message, options)

    Parameters:

    • message (Object)
      the reply message
    • options (Hash{String => Object})
      the delivery options


90
91
92
93
94
95
96
97
98
99
100
101
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/message.rb', line 90

def reply(*args)
  if ::Vertx::Util::unknown_type.accept?(args[0]) && !block_given? && args[1] == nil
    return @j_del.java_method(:reply, [Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(args[0]))
  elsif ::Vertx::Util::unknown_type.accept?(args[0]) && args[1].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(args[0]),Java::IoVertxCoreEventbus::DeliveryOptions.new(::Vertx::Util::Utils.to_json_object(args[1])))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling reply(#{args[0]},#{args[1]})"
  end
end

- (String) replyAddress

The reply address. Can be null.

Returns:

  • (String)
    the reply address, or null, if message was sent without a reply handler.


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

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

- (void) replyAndRequest(message, replyHandler) { ... } - (void) replyAndRequest(message, options, replyHandler) { ... }

This method returns an undefined value.

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

Overloads:

  • - (void) replyAndRequest(message, replyHandler) { ... }

    Parameters:

    • message (Object)
      the message to reply with.

    Yields:

    • the reply handler for the reply.
  • - (void) replyAndRequest(message, options, replyHandler) { ... }

    Parameters:

    • 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


141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/message.rb', line 141

def reply_and_request(*args)
  if ::Vertx::Util::unknown_type.accept?(args[0]) && true && args[1] == nil
    if (block_given?)
      return @j_del.java_method(:replyAndRequest, [Java::java.lang.Object.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_object(args[0]),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)
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:replyAndRequest, [Java::java.lang.Object.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_object(args[0]),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 ::Vertx::Util::unknown_type.accept?(args[0]) && args[1].class == Hash && true
    if (block_given?)
      return @j_del.java_method(:replyAndRequest, [Java::java.lang.Object.java_class,Java::IoVertxCoreEventbus::DeliveryOptions.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_object(args[0]),Java::IoVertxCoreEventbus::DeliveryOptions.new(::Vertx::Util::Utils.to_json_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)
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:replyAndRequest, [Java::java.lang.Object.java_class,Java::IoVertxCoreEventbus::DeliveryOptions.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_object(args[0]),Java::IoVertxCoreEventbus::DeliveryOptions.new(::Vertx::Util::Utils.to_json_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
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling reply_and_request(#{args[0]},#{args[1]})"
  end
end

- (true, false) isSend

Signals if this message represents a send or publish event.

Returns:

  • (true, false)
    true if this is a send.


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

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