Class: JSparrow::Interactors::Client
- Inherits:
-
Object
- Object
- JSparrow::Interactors::Client
- Defined in:
- lib/interaction/client.rb
Overview
Client to send and receive messages to/from the JMS provider.
Instance Method Summary collapse
-
#initialize(connection) ⇒ Client
constructor
A new instance of Client.
- #is_started? ⇒ Boolean
- #is_stoped? ⇒ Boolean
- #queue(queue_name) ⇒ Object
- #queue_enabled?(queue_name) ⇒ Boolean
- #queue_receiver(queue_name) ⇒ Object
- #queue_sender(queue_name) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #topic(topic_name) ⇒ Object
- #topic_enabled?(topic_name) ⇒ Boolean
- #topic_receiver(topic_name) ⇒ Object
- #topic_sender(topic_name) ⇒ Object
Constructor Details
#initialize(connection) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/interaction/client.rb', line 10 def initialize(connection) @connection = connection @connection_factories = {} @queues = {} @queue_senders = {} @queue_receivers = {} @topics = {} @topic_senders = {} @topic_receivers = {} end |
Instance Method Details
#is_started? ⇒ Boolean
22 23 24 |
# File 'lib/interaction/client.rb', line 22 def is_started? @connection.is_opened? end |
#is_stoped? ⇒ Boolean
32 33 34 |
# File 'lib/interaction/client.rb', line 32 def is_stoped? @connection.is_closed? end |
#queue(queue_name) ⇒ Object
44 45 46 47 48 |
# File 'lib/interaction/client.rb', line 44 def queue(queue_name) raise NameError, "Queue '#{queue_name}' does not exist." unless queue_enabled?(queue_name) @queues[queue_name] end |
#queue_enabled?(queue_name) ⇒ Boolean
40 41 42 |
# File 'lib/interaction/client.rb', line 40 def queue_enabled?(queue_name) @connection.configuration.enabled_queues.include?(queue_name) end |
#queue_receiver(queue_name) ⇒ Object
55 56 57 58 |
# File 'lib/interaction/client.rb', line 55 def queue_receiver(queue_name) @queue_receivers[queue_name] ||= Messaging::Receiver.new(queue_connection_factory, queue(queue_name)) end |
#queue_sender(queue_name) ⇒ Object
50 51 52 53 |
# File 'lib/interaction/client.rb', line 50 def queue_sender(queue_name) @queue_senders[queue_name] ||= Messaging::Sender.new(queue_connection_factory, queue(queue_name)) end |
#start ⇒ Object
26 27 28 29 30 |
# File 'lib/interaction/client.rb', line 26 def start @connection.open @connection_factories, @queues, @topics = lookup_resources end |
#stop ⇒ Object
36 37 38 |
# File 'lib/interaction/client.rb', line 36 def stop @connection.close end |
#topic(topic_name) ⇒ Object
64 65 66 67 68 |
# File 'lib/interaction/client.rb', line 64 def topic(topic_name) raise NameError, "Topic '#{topic_name}' does not exist." unless topic_enabled?(topic_name) @topics[topic_name] end |
#topic_enabled?(topic_name) ⇒ Boolean
60 61 62 |
# File 'lib/interaction/client.rb', line 60 def topic_enabled?(topic_name) @connection.configuration.enabled_topics.include?(topic_name) end |