Class: RServiceBus2::Agent
- Inherits:
-
Object
- Object
- RServiceBus2::Agent
- Defined in:
- lib/rservicebus2/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
-
#check_for_reply(queue_name) ⇒ Object
Gives an agent the means to receive a reply.
- #get_agent(uri) ⇒ Object
-
#initialize ⇒ Agent
constructor
A new instance of Agent.
-
#send_msg(message_obj, queue_name, return_address = nil) ⇒ Object
Put a msg on the bus.
Constructor Details
Instance Method Details
#check_for_reply(queue_name) ⇒ Object
Gives an agent the means to receive a reply
50 51 52 53 54 55 56 |
# File 'lib/rservicebus2/agent.rb', line 50 def check_for_reply(queue_name) @mq.subscribe(queue_name) body = @mq.pop @msg = RServiceBus2.safe_load(body) @mq.ack @msg.msg end |
#get_agent(uri) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/rservicebus2/agent.rb', line 10 def get_agent(uri) ENV['RSBMQ'] = uri.to_s RServiceBus2.rlog '*** Agent.getAgent has been deprecated. Set the environment variable, RSBMQ, and simply create the class' Agent.new end |
#send_msg(message_obj, queue_name, return_address = nil) ⇒ Object
Put a msg on the bus
rubocop:disable Metrics/MethodLength
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rservicebus2/agent.rb', line 28 def send_msg(, queue_name, return_address = nil) raise QueueNotFoundForMsg, .class.name if queue_name.nil? msg = RServiceBus2::Message.new(, return_address) if queue_name.index('@').nil? q = queue_name else parts = queueName.split('@') msg.remote_queue_name = parts[0] msg.remote_host_name = parts[1] q = 'transport-out' end serialized_object = YAML.dump(msg) @mq.send(q, serialized_object) end |