lib/rrj/janus/transactions/transaction.rb in ruby_rabbitmq_janus-1.2.2 vs lib/rrj/janus/transactions/transaction.rb in ruby_rabbitmq_janus-1.2.3.pre.53
- old
+ new
@@ -14,35 +14,36 @@
# @param [Fixnum] session
# Use a session identifier for created message
def initialize(session)
@rabbit = Rabbit::Connect.new
@session = session
- @publish = @exclusive = nil
+ @publisher = @exclusive = nil
rescue => error
raise Errors::JanusTransaction, error
end
private
- attr_reader :rabbit, :session, :response, :handle, :publish, :exclusive
+ attr_reader :rabbit, :session, :response, :handle, :publisher,
+ :exclusive
def choose_queue
chan = @rabbit.channel
- @publish = if @exclusive
- Tools::Log.instance.debug \
- 'Choose an queue Exclusive : ampq.gen-xxx'
- Rabbit::Publisher::PublishExclusive.new(chan, '')
- else
- Tools::Log.instance.debug \
- 'Choose an queue non Exclusive : to-janus'
- Rabbit::Publisher::PublishNonExclusive.new(chan)
- end
+ @publisher = if @exclusive
+ Tools::Log.instance.debug \
+ 'Choose an queue Exclusive : ampq.gen-xxx'
+ Rabbit::Publisher::PublishExclusive.new(chan, '')
+ else
+ Tools::Log.instance.debug \
+ 'Choose an queue non Exclusive : to-janus'
+ Rabbit::Publisher::PublishNonExclusive.new(chan)
+ end
end
def send_a_message
Tools::Log.instance.info 'Publish a message ...'
- publish = @publish.send_a_message(yield)
- Janus::Responses::Standard.new(read_response(publish))
+ response = read_response(@publisher.publish(yield))
+ Janus::Responses::Standard.new(response)
end
def read_response(publish)
if @exclusive
Tools::Log.instance.info '... and read a janus response'