Class: VertxRabbitmq::RabbitMQConsumer

Inherits:
Object
  • Object
show all
Includes:
Vertx::ReadStream
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-rabbitmq/rabbit_mq_consumer.rb

Overview

A stream of messages from a rabbitmq queue.

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-rabbitmq/rabbit_mq_consumer.rb', line 20

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

+ (Object) j_api_type


29
30
31
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-rabbitmq/rabbit_mq_consumer.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-rabbitmq/rabbit_mq_consumer.rb', line 32

def self.j_class
  Java::IoVertxRabbitmq::RabbitMQConsumer.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-rabbitmq/rabbit_mq_consumer.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-rabbitmq/rabbit_mq_consumer.rb', line 23

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

Instance Method Details

- (void) cancel { ... }

This method returns an undefined value.

Stop message consumption from a queue.

The operation is asynchronous. When consumption will be stopped, you can by notified via #end_handler

Yields:

  • contains information about operation status: success/fail.

Raises:

  • (ArgumentError)

110
111
112
113
114
115
116
117
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-rabbitmq/rabbit_mq_consumer.rb', line 110

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

- (String) consumer_tag

Returns a consumer tag

Returns:

  • (String)
    a consumer tag

Raises:

  • (ArgumentError)

99
100
101
102
103
104
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-rabbitmq/rabbit_mq_consumer.rb', line 99

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

- (self) end_handler { ... }

Set an end handler. Once the stream has canceled successfully, the handler will be called.

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)

91
92
93
94
95
96
97
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-rabbitmq/rabbit_mq_consumer.rb', line 91

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

- (self) exception_handler { ... }

Set an exception handler on the read stream.

Yields:

  • the exception handler

Returns:

  • (self)

Raises:

  • (ArgumentError)

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

def exception_handler
  if block_given?
    @j_del.java_method(:exceptionHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_throwable(event)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling exception_handler()"
end

- (self) fetch(amount = nil)

Fetch the specified amount of elements. If the ReadStream has been paused, reading will recommence with the specified amount of items, otherwise the specified amount will be added to the current stream demand.

Parameters:

  • amount (Fixnum) (defaults to: nil)

Returns:

  • (self)

Raises:

  • (ArgumentError)

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

def fetch(amount=nil)
  if amount.class == Fixnum && !block_given?
    @j_del.java_method(:fetch, [Java::long.java_class]).call(amount)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling fetch(#{amount})"
end

- (self) handler { ... }

Set a message handler. As message appear in a queue, the handler will be called with the message.

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)

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

def handler
  if block_given?
    @j_del.java_method(:handler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxRabbitmq::RabbitMQMessage)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling handler()"
end

- (self) pause

Pause the stream of incoming messages from queue.

The messages will continue to arrive, but they will be stored in a internal queue. If the queue size would exceed the limit provided by , then incoming messages will be discarded.

Returns:

  • (self)

Raises:

  • (ArgumentError)

72
73
74
75
76
77
78
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-rabbitmq/rabbit_mq_consumer.rb', line 72

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

- (true, false) paused?

Returns is the stream paused?

Returns:

  • (true, false)
    is the stream paused?

Raises:

  • (ArgumentError)

119
120
121
122
123
124
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-rabbitmq/rabbit_mq_consumer.rb', line 119

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

- (self) resume

Resume reading from a queue. Flushes internal queue.

Returns:

  • (self)

Raises:

  • (ArgumentError)

81
82
83
84
85
86
87
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-rabbitmq/rabbit_mq_consumer.rb', line 81

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