Class: VertxAmqpClient::AmqpClient

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_client.rb

Overview

AMQP Client entry point. Use this interface to create an instance of AmqpClient and connect to a broker and server.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)

23
24
25
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_client.rb', line 23

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

+ (::VertxAmqpClient::AmqpClient) create(options) + (::VertxAmqpClient::AmqpClient) create(vertx, options)

Creates a new instance of VertxAmqpClient::AmqpClient with the given Vert.x instance and the given options.

Overloads:

  • + (::VertxAmqpClient::AmqpClient) create(options)

    Parameters:

    • options (Hash)
      the AMQP client options, may be null falling back to the default configuration
  • + (::VertxAmqpClient::AmqpClient) create(vertx, options)

    Parameters:

    • vertx (::Vertx::Vertx)
      the vert.x instance, must not be null
    • options (Hash)
      the AMQP options, may be @null falling back to the default configuration

Returns:

Raises:

  • (ArgumentError)

45
46
47
48
49
50
51
52
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_client.rb', line 45

def self.create(param_1=nil,param_2=nil)
  if param_1.class == Hash && !block_given? && param_2 == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxAmqp::AmqpClient.java_method(:create, [Java::IoVertxAmqp::AmqpClientOptions.java_class]).call(Java::IoVertxAmqp::AmqpClientOptions.new(::Vertx::Util::Utils.to_json_object(param_1))),::VertxAmqpClient::AmqpClient)
  elsif param_1.class.method_defined?(:j_del) && param_2.class == Hash && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxAmqp::AmqpClient.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxAmqp::AmqpClientOptions.java_class]).call(param_1.j_del,Java::IoVertxAmqp::AmqpClientOptions.new(::Vertx::Util::Utils.to_json_object(param_2))),::VertxAmqpClient::AmqpClient)
  end
  raise ArgumentError, "Invalid arguments when calling create(#{param_1},#{param_2})"
end

+ (Object) j_api_type


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

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class


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

def self.j_class
  Java::IoVertxAmqp::AmqpClient.java_class
end

+ (Object) unwrap(obj)


29
30
31
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_client.rb', line 29

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

+ (Object) wrap(obj)


26
27
28
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_client.rb', line 26

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

Instance Method Details

- (void) close { ... }

This method returns an undefined value.

Closes the client. The client must always be closed once not needed anymore.

Yields:

  • the close handler notified when the operation completes. It can be null.

Raises:

  • (ArgumentError)

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

def close
  if block_given?
    return @j_del.java_method(:close, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling close()"
end

- (self) connect { ... }

Connects to the AMQP broker or router. The location is specified in the Hash as well as the potential credential required.

Yields:

  • handler that will process the result, giving either the connection or failure cause. Must not be null.

Returns:

  • (self)

Raises:

  • (ArgumentError)

57
58
59
60
61
62
63
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-client/amqp_client.rb', line 57

def connect
  if block_given?
    @j_del.java_method(:connect, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAmqpClient::AmqpConnection) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling connect()"
end

- (self) createReceiver(address, completionHandler) { ... } - (self) createReceiver(address, messageHandler, completionHandler) { ... } - (self) createReceiver(address, receiverOptions, messageHandler, completionHandler) { ... }

Creates a receiver used to consumer messages from the given address. This method avoids having to connect explicitly. You can retrieve the connection using VertxAmqpClient::AmqpReceiver#connection.

Overloads:

  • - (self) createReceiver(address, completionHandler) { ... }

    Parameters:

    • address (String)
      The source address to attach the consumer to, must not be null

    Yields:

    • the handler called with the receiver. The receiver has been opened.
  • - (self) createReceiver(address, messageHandler, completionHandler) { ... }

    Parameters:

    • address (String)
      The source address to attach the consumer to, must not be null
    • messageHandler (Proc)
      The message handler, must not be null

    Yields:

    • the handler called with the receiver that has been opened. Note that the messageHandler can be called before the completionHandler if messages are awaiting delivery.
  • - (self) createReceiver(address, receiverOptions, messageHandler, completionHandler) { ... }

    Parameters:

    • address (String)
      The source address to attach the consumer to.
    • receiverOptions (Hash)
      The options for this receiver.
    • messageHandler (Proc)
      The message handler, must not be null

    Yields:

    • The handler called with the receiver, once opened. Note that the messageHandler can be called before the completionHandler if messages are awaiting delivery.

Returns:

  • (self)

Raises:

  • (ArgumentError)

89
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-amqp-client/amqp_client.rb', line 89

def create_receiver(param_1=nil,param_2=nil,param_3=nil)
  if param_1.class == String && block_given? && param_2 == nil && param_3 == nil
    @j_del.java_method(:createReceiver, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAmqpClient::AmqpReceiver) : nil) }))
    return self
  elsif param_1.class == String && param_2.class == Proc && block_given? && param_3 == nil
    @j_del.java_method(:createReceiver, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1,(Proc.new { |event| param_2.call(::Vertx::Util::Utils.safe_create(event,::VertxAmqpClient::AmqpMessage)) }),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAmqpClient::AmqpReceiver) : nil) }))
    return self
  elsif param_1.class == String && param_2.class == Hash && param_3.class == Proc && block_given?
    @j_del.java_method(:createReceiver, [Java::java.lang.String.java_class,Java::IoVertxAmqp::AmqpReceiverOptions.java_class,Java::IoVertxCore::Handler.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1,Java::IoVertxAmqp::AmqpReceiverOptions.new(::Vertx::Util::Utils.to_json_object(param_2)),(Proc.new { |event| param_3.call(::Vertx::Util::Utils.safe_create(event,::VertxAmqpClient::AmqpMessage)) }),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAmqpClient::AmqpReceiver) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling create_receiver(#{param_1},#{param_2},#{param_3})"
end

- (self) create_sender(address = nil, options = nil) { ... }

Creates a sender used to send messages to the given address. The address must be set.

Parameters:

  • address (String) (defaults to: nil)
    The target address to attach to, must not be null
  • options (Hash) (defaults to: nil)
    The options for this sender.

Yields:

  • The handler called with the sender, once opened

Returns:

  • (self)

Raises:

  • (ArgumentError)

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-amqp-client/amqp_client.rb', line 107

def create_sender(address=nil,options=nil)
  if address.class == String && block_given? && options == nil
    @j_del.java_method(:createSender, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(address,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAmqpClient::AmqpSender) : nil) }))
    return self
  elsif address.class == String && options.class == Hash && block_given?
    @j_del.java_method(:createSender, [Java::java.lang.String.java_class,Java::IoVertxAmqp::AmqpSenderOptions.java_class,Java::IoVertxCore::Handler.java_class]).call(address,Java::IoVertxAmqp::AmqpSenderOptions.new(::Vertx::Util::Utils.to_json_object(options)),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAmqpClient::AmqpSender) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling create_sender(#{address},#{options})"
end