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
47 48 49 50 51 52 53 |
# File 'lib/rservicebus2/agent.rb', line 47 def check_for_reply(queue_name) @mq.subscribe(queue_name) body = @mq.pop @msg = YAML.load(body) @mq.ack @msg.msg end |
#get_agent(uri) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/rservicebus2/agent.rb', line 8 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/AbcSize,Metrics/MethodLength
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rservicebus2/agent.rb', line 26 def send_msg(, queue_name, return_address = nil) fail 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.set_remote_queue_name(parts[0]) msg.set_remote_host_name(parts[1]) q = 'transport-out' end serialized_object = YAML.dump(msg) @mq.send(q, serialized_object) end |