Class: RServiceBus::Agent
- Inherits:
-
Object
- Object
- RServiceBus::Agent
- Defined in:
- lib/rservicebus/Agent.rb
Overview
A means for a stand-alone process to interact with the bus, without being a full rservicebus application
Instance Method Summary collapse
-
#checkForReply(queueName) ⇒ Object
Gives an agent the means to receive a reply.
- #getAgent(uri) ⇒ Object
-
#initialize ⇒ Agent
constructor
A new instance of Agent.
-
#sendMsg(messageObj, queueName, returnAddress = nil) ⇒ Object
Put a msg on the bus.
Constructor Details
Instance Method Details
#checkForReply(queueName) ⇒ Object
Gives an agent the means to receive a reply
51 52 53 54 55 56 57 |
# File 'lib/rservicebus/Agent.rb', line 51 def checkForReply( queueName ) @mq.subscribe( queueName ) body = @mq.pop @msg = YAML::load(body) @mq.ack return @msg.msg end |
#getAgent(uri) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/rservicebus/Agent.rb', line 12 def getAgent( uri ) ENV['RSBMQ'] = uri.to_s RServiceBus.rlog '*** Agent.getAgent has been deprecated. Set the environment variable, RSBMQ, and simply create the class' return Agent.new end |
#sendMsg(messageObj, queueName, returnAddress = nil) ⇒ Object
Put a msg on the bus
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rservicebus/Agent.rb', line 28 def sendMsg(, queueName, returnAddress=nil) raise QueueNotFoundForMsg.new( .class.name ) if queueName.nil? msg = RServiceBus::Message.new( , returnAddress ) if queueName.index('@').nil? then q = queueName else parts = queueName.split('@') msg.setRemoteQueueName( parts[0] ) msg.setRemoteHostName( parts[1] ) q = 'transport-out' end serialized_object = YAML::dump(msg) @mq.send( q, serialized_object ) end |