From 2e7de65c2d2a899b7d2e4149c36023aecb802d71 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Fri, 16 Nov 2012 22:24:01 -0500 Subject: [PATCH] Switching to Ruby-style methods and setters --- sylvilagus/jruby/lib/sylvilagus/ch02/hello_world.rb | 10 +++++----- .../jruby/lib/sylvilagus/ch02/hello_world_consumer.rb | 6 +++--- .../jruby/lib/sylvilagus/ch02/hello_world_producer.rb | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sylvilagus/jruby/lib/sylvilagus/ch02/hello_world.rb b/sylvilagus/jruby/lib/sylvilagus/ch02/hello_world.rb index d706c35..506258c 100644 --- a/sylvilagus/jruby/lib/sylvilagus/ch02/hello_world.rb +++ b/sylvilagus/jruby/lib/sylvilagus/ch02/hello_world.rb @@ -8,11 +8,11 @@ module Sylvilagus::Ch02::HelloWorld module ClassMethods def with_hello_world_conn(&block) factory = ConnectionFactory.new - factory.setUri('amqp://guest:guest@localhost:5672') - conn = factory.newConnection - channel = conn.createChannel - channel.exchangeDeclare('hello-exchange', 'direct', true) - channel.queueDeclare('hello-queue', false, false, false, nil) + factory.uri = 'amqp://guest:guest@localhost:5672' + conn = factory.new_connection + channel = conn.create_channel + channel.exchange_declare('hello-exchange', 'direct', true) + channel.queue_declare('hello-queue', false, false, false, nil) block.call(conn, channel) ensure diff --git a/sylvilagus/jruby/lib/sylvilagus/ch02/hello_world_consumer.rb b/sylvilagus/jruby/lib/sylvilagus/ch02/hello_world_consumer.rb index a30d8d5..6eaf54d 100644 --- a/sylvilagus/jruby/lib/sylvilagus/ch02/hello_world_consumer.rb +++ b/sylvilagus/jruby/lib/sylvilagus/ch02/hello_world_consumer.rb @@ -9,7 +9,7 @@ class Sylvilagus::Ch02::HelloWorldConsumer < DefaultConsumer def main with_hello_world_conn do |conn,channel| - channel.basicConsume('hello-queue', false, new(channel)) + channel.basic_consume('hello-queue', false, new(channel)) loop do sleep 3 puts "Still waiting..." @@ -19,10 +19,10 @@ class Sylvilagus::Ch02::HelloWorldConsumer < DefaultConsumer end def handleDelivery(consumer_tag, envelope, properties, body) - delivery_tag = envelope.getDeliveryTag + delivery_tag = envelope.get_delivery_tag body_string = RubyString.bytes_to_string(body) puts "Consumed #{body_string.inspect}" - getChannel.basicAck(delivery_tag, false) + get_channel.basic_ack(delivery_tag, false) end end diff --git a/sylvilagus/jruby/lib/sylvilagus/ch02/hello_world_producer.rb b/sylvilagus/jruby/lib/sylvilagus/ch02/hello_world_producer.rb index ad2bc3b..66c4610 100644 --- a/sylvilagus/jruby/lib/sylvilagus/ch02/hello_world_producer.rb +++ b/sylvilagus/jruby/lib/sylvilagus/ch02/hello_world_producer.rb @@ -7,7 +7,7 @@ class Sylvilagus::Ch02::HelloWorldProducer def main message = ARGV.first || 'snorg' with_hello_world_conn do |conn,channel| - channel.basicPublish('hello-exchange', 'hola', nil, message.to_java_bytes) + channel.basic_publish('hello-exchange', 'hola', nil, message.to_java_bytes) puts "Published #{message.inspect}" end end