Class: RServiceBus::MQ_Redis
Overview
Beanstalk client implementation.
Instance Attribute Summary
Attributes inherited from MQ
Instance Method Summary collapse
-
#ack ⇒ Object
“Commit” queue.
-
#connect(host, port) ⇒ Object
Connect to the broker.
-
#pop ⇒ Object
Get next msg from queue.
- #returnToQueue ⇒ Object
-
#send(queueName, msg) ⇒ Object
At least called in the Host rescue block, to ensure all network links are healthy.
-
#subscribe(queuename) ⇒ Object
Connect to the queue.
Methods inherited from MQ
Constructor Details
This class inherits a constructor from RServiceBus::MQ
Instance Method Details
#ack ⇒ Object
“Commit” queue
47 48 49 |
# File 'lib/rservicebus/MQ/Redis.rb', line 47 def ack @redis.lpop @queuename end |
#connect(host, port) ⇒ Object
Connect to the broker
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rservicebus/MQ/Redis.rb', line 12 def connect( host, port ) port ||= 6379 string = "#{host}:#{port}" begin @redis = Redis.new(:host => host, :port => port) rescue Exception => e puts e. puts 'Error connecting to Redis for mq' puts "Host string, #{string}" abort() end end |
#pop ⇒ Object
Get next msg from queue
34 35 36 37 38 39 40 41 |
# File 'lib/rservicebus/MQ/Redis.rb', line 34 def pop if @redis.llen( @queuename ) == 0 then sleep @timeout raise NoMsgToProcess.new end return @redis.lindex @queuename, 0 end |
#returnToQueue ⇒ Object
43 44 |
# File 'lib/rservicebus/MQ/Redis.rb', line 43 def returnToQueue end |
#send(queueName, msg) ⇒ Object
At least called in the Host rescue block, to ensure all network links are healthy
52 53 54 |
# File 'lib/rservicebus/MQ/Redis.rb', line 52 def send( queueName, msg ) @redis.rpush queueName, msg end |
#subscribe(queuename) ⇒ Object
Connect to the queue
29 30 31 |
# File 'lib/rservicebus/MQ/Redis.rb', line 29 def subscribe( queuename ) @queuename = queuename end |