Class: JSparrow::Connection::Client
- Inherits:
-
Object
- Object
- JSparrow::Connection::Client
- Defined in:
- lib/client.rb
Overview
Cliente JMS que possibilita a conexao com o servidor de aplicacoes Java EE que prove o servico JMS.
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.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/client.rb', line 12 def initialize(connection) @connection = connection # Conexoes, filas, topicos, senders e receivers que serao habilitados @connection_factories = {} @queues = {} @queue_senders = {} @queue_receivers = {} @topics = {} @topic_senders = {} @topic_receivers = {} end |
Instance Method Details
#is_started? ⇒ Boolean
25 26 27 |
# File 'lib/client.rb', line 25 def is_started? @connection.is_opened? end |
#is_stoped? ⇒ Boolean
35 36 37 |
# File 'lib/client.rb', line 35 def is_stoped? @connection.is_closed? end |
#queue(queue_name) ⇒ Object
47 48 49 50 51 |
# File 'lib/client.rb', line 47 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
43 44 45 |
# File 'lib/client.rb', line 43 def queue_enabled?(queue_name) @connection.configuration.enabled_queues.include?(queue_name) end |
#queue_receiver(queue_name) ⇒ Object
58 59 60 61 |
# File 'lib/client.rb', line 58 def queue_receiver(queue_name) @queue_receivers[queue_name] ||= Messaging::Receiver.new(queue_connection_factory, queue(queue_name)) end |
#queue_sender(queue_name) ⇒ Object
53 54 55 56 |
# File 'lib/client.rb', line 53 def queue_sender(queue_name) @queue_senders[queue_name] ||= Messaging::Sender.new(queue_connection_factory, queue(queue_name)) end |
#start ⇒ Object
29 30 31 32 33 |
# File 'lib/client.rb', line 29 def start @connection.open @connection_factories, @queues, @topics = lookup_resources end |
#stop ⇒ Object
39 40 41 |
# File 'lib/client.rb', line 39 def stop @connection.close end |
#topic(topic_name) ⇒ Object
67 68 69 70 71 |
# File 'lib/client.rb', line 67 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
63 64 65 |
# File 'lib/client.rb', line 63 def topic_enabled?(topic_name) @connection.configuration.enabled_topics.include?(topic_name) end |