Class: VertxAmqpBridge::AmqpBridge

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

Overview

Vert.x AMQP Bridge. Facilitates sending and receiving AMQP 1.0 messages.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


20
21
22
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-bridge/amqp_bridge.rb', line 20

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

+ (::VertxAmqpBridge::AmqpBridge) create(vertx = nil, options = nil)

Creates a Bridge with the given options.

Parameters:

  • vertx (::Vertx::Vertx) (defaults to: nil)
    the vertx instance to use
  • options (Hash) (defaults to: nil)
    the options

Returns:

Raises:

  • (ArgumentError)


39
40
41
42
43
44
45
46
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-bridge/amqp_bridge.rb', line 39

def self.create(vertx=nil,options=nil)
  if vertx.class.method_defined?(:j_del) && !block_given? && options == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxAmqpbridge::AmqpBridge.java_method(:create, [Java::IoVertxCore::Vertx.java_class]).call(vertx.j_del),::VertxAmqpBridge::AmqpBridge)
  elsif vertx.class.method_defined?(:j_del) && options.class == Hash && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxAmqpbridge::AmqpBridge.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxAmqpbridge::AmqpBridgeOptions.java_class]).call(vertx.j_del,Java::IoVertxAmqpbridge::AmqpBridgeOptions.new(::Vertx::Util::Utils.to_json_object(options))),::VertxAmqpBridge::AmqpBridge)
  end
  raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{options})"
end

+ (Object) j_api_type



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

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



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

def self.j_class
  Java::IoVertxAmqpbridge::AmqpBridge.java_class
end

+ (Object) unwrap(obj)



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

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

+ (Object) wrap(obj)



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

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

Instance Method Details

- (void) close { ... }

This method returns an undefined value.

Shuts the bridge down, closing the underlying connection.

Yields:

  • the result handler

Raises:

  • (ArgumentError)


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

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

- (::Vertx::MessageConsumer) create_consumer(amqpAddress = nil)

Creates a consumer on the given AMQP address. This method MUST be called from the bridge Context thread, as used in the result handler callback from the start methods. The bridge MUST be successfully started before the method is called.

Parameters:

  • amqpAddress (String) (defaults to: nil)
    the address to consume from

Returns:

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-bridge/amqp_bridge.rb', line 68

def create_consumer(amqpAddress=nil)
  if amqpAddress.class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:createConsumer, [Java::java.lang.String.java_class]).call(amqpAddress),::Vertx::MessageConsumer, nil)
  end
  raise ArgumentError, "Invalid arguments when calling create_consumer(#{amqpAddress})"
end

- (::Vertx::MessageProducer) create_producer(amqpAddress = nil)

Creates a producer to the given AMQP address. This method MUST be called from the bridge Context thread, as used in the result handler callback from the start methods. The bridge MUST be successfully started before the method is called.

Parameters:

  • amqpAddress (String) (defaults to: nil)
    the address to produce to

Returns:

Raises:

  • (ArgumentError)


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

def create_producer(amqpAddress=nil)
  if amqpAddress.class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:createProducer, [Java::java.lang.String.java_class]).call(amqpAddress),::Vertx::MessageProducer, nil)
  end
  raise ArgumentError, "Invalid arguments when calling create_producer(#{amqpAddress})"
end

- (void) end_handler { ... }

This method returns an undefined value.

Set an end handler. This will fire if the underlying connection is unexpectedly disconnected or remotely closed.

Yields:

  • the handler

Raises:

  • (ArgumentError)


98
99
100
101
102
103
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-bridge/amqp_bridge.rb', line 98

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

- (void) start(hostname = nil, port = nil, username = nil, password = nil) { ... }

This method returns an undefined value.

Starts the bridge, establishing the underlying connection.

Parameters:

  • hostname (String) (defaults to: nil)
    the host name to connect to
  • port (Fixnum) (defaults to: nil)
    the port to connect to
  • username (String) (defaults to: nil)
    the username
  • password (String) (defaults to: nil)
    the password

Yields:

  • the result handler

Raises:

  • (ArgumentError)


54
55
56
57
58
59
60
61
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-amqp-bridge/amqp_bridge.rb', line 54

def start(hostname=nil,port=nil,username=nil,password=nil)
  if hostname.class == String && port.class == Fixnum && block_given? && username == nil && password == nil
    return @j_del.java_method(:start, [Java::java.lang.String.java_class,Java::int.java_class,Java::IoVertxCore::Handler.java_class]).call(hostname,port,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAmqpBridge::AmqpBridge) : nil) }))
  elsif hostname.class == String && port.class == Fixnum && username.class == String && password.class == String && block_given?
    return @j_del.java_method(:start, [Java::java.lang.String.java_class,Java::int.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(hostname,port,username,password,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAmqpBridge::AmqpBridge) : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling start(#{hostname},#{port},#{username},#{password})"
end