Sha256: a19f25b9a8b28b618d0a080c681bf7f3c8a7d430f0e1769251afa30e82d9b338

Contents?: true

Size: 751 Bytes

Versions: 19

Compression:

Stored size: 751 Bytes

Contents

$: << 'lib'

require 'hot_bunnies'

import java.util.concurrent.Executors


connection = HotBunnies.connect(:host => 'localhost')
channel = connection.create_channel
channel.prefetch = 10

exchange = channel.exchange('test', :type => :direct)

queue = channel.queue('hello.world')
queue.bind(exchange, :routing_key => 'xyz')
queue.purge

thread_pool = Executors.new_fixed_thread_pool(3)

subscription = queue.subscribe(:ack => true)
subscription.each(:blocking => false, :executor => thread_pool) do |headers, msg|
  puts msg
  headers.ack
end

100.times do |i|
  exchange.publish("hello world! #{i}", :routing_key => 'xyz')
end

thread_pool.shutdown_now
subscription.cancel

puts "ALMOST ALL DONE!"

at_exit do
  channel.close
  connection.close
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
hot_bunnies-1.5.0-java examples/non_blocking_subscription_with_executor.rb
hot_bunnies-1.4.0-java examples/non_blocking_subscription_with_executor.rb
hot_bunnies-1.4.0.pre4-java examples/non_blocking_subscription_with_executor.rb
hot_bunnies-1.4.0.pre3-java examples/non_blocking_subscription_with_executor.rb
hot_bunnies-1.4.0.pre2-java examples/non_blocking_subscription_with_executor.rb
hot_bunnies-1.4.0.pre1-java examples/non_blocking_subscription_with_executor.rb
hot_bunnies-1.3.8-java examples/non_blocking_subscription_with_executor.rb
hot_bunnies-1.3.7-java examples/non_blocking_subscription_with_executor.rb
hot_bunnies-1.3.6-java examples/non_blocking_subscription_with_executor.rb
hot_bunnies-1.3.5-java examples/non_blocking_subscription_with_executor.rb
hot_bunnies-1.3.4-java examples/non_blocking_subscription_with_executor.rb
hot_bunnies-1.3.3-java examples/non_blocking_subscription_with_executor.rb
hot_bunnies-1.3.2-java examples/non_blocking_subscription_with_executor.rb
hot_bunnies-1.3.1-java examples/non_blocking_subscription_with_executor.rb
hot_bunnies-1.2.2-java examples/non_blocking_subscription_with_executor.rb
hot_bunnies-1.2.1-java examples/non_blocking_subscription_with_executor.rb
hot_bunnies-1.2.0-java examples/non_blocking_subscription_with_executor.rb
hot_bunnies-1.1.3-java examples/non_blocking_subscription_with_executor.rb
hot_bunnies-1.1.2-java examples/non_blocking_subscription_with_executor.rb