Module: Ap4r::StoreAndForward
- Included in:
- TestSaf
- Defined in:
- lib/ap4r/store_and_forward.rb
Overview
This StoreAndForward
provides at-least-once QoS level which guarantees not to lose any message.
Example:
include StoreAndFoward
name = "queue.test.sample"
= "hogehoge"
= {}
sm = StoreMessages.store(name, , )
forward_by_queue_info(sm.id, {:queue_name => name,
:queue_message => , :queue_headers => })
Constant Summary collapse
- DRUBY_HOST =
TODO: constant or class variable, whick is better? 2007/05/02 by shino
ENV['AP4R_DRUBY_HOST'] || 'localhost'
- DRUBY_PORT =
ENV['AP4R_DRUBY_PORT'] || '6438'
- DRUBY_URI =
"druby://#{DRUBY_HOST}:#{DRUBY_PORT}"
Instance Method Summary collapse
-
#__ap4r_forward_by_queue_info(stored_message_id, queue_info, options) ⇒ Object
(also: #forward_by_queue_info)
This method needs information about stored message, such as putting queue’s name, message, options, as aruments.
-
#__ap4r_forward_by_stored_message_id(stored_message_id, options) ⇒ Object
(also: #forward_by_stored_message_id)
This method does’t need information about stored message.
-
#__ap4r_queue_put(queue_name, queue_message, queue_headers) ⇒ Object
(also: #queue_put)
Puts a message into queue.
Instance Method Details
#__ap4r_forward_by_queue_info(stored_message_id, queue_info, options) ⇒ Object Also known as: forward_by_queue_info
This method needs information about stored message, such as putting queue’s name, message, options, as aruments. And those values stucked queue_info hash and following keys are necessary.
-
:queue_name
-
:queue_message
-
:queue_headers
As :queue_headers, some options are supported. See the reliable-msg docuememt for more details.
And this method’s options is now :delete_mode only. See the StoreMessage rdoc for more details.
48 49 50 51 |
# File 'lib/ap4r/store_and_forward.rb', line 48 def __ap4r_forward_by_queue_info(, queue_info, ) __ap4r_queue_put(queue_info[:queue_name], queue_info[:queue_message], queue_info[:queue_headers]) StoredMessage.destroy_if_exists(, ) end |
#__ap4r_forward_by_stored_message_id(stored_message_id, options) ⇒ Object Also known as: forward_by_stored_message_id
This method does’t need information about stored message. All that is required is stored_message_id. Find target record by stored_message_id, make queue information, such as queue name, message, options, for putting into queue. Now under implementation.
And this method’s options is now :delete_mode only. See the StoreMessage rdoc for more details.
64 65 66 67 68 69 70 71 |
# File 'lib/ap4r/store_and_forward.rb', line 64 def (, ) raise "not implemented" # TODO: Find record and make queue info , 2006/10/13 kato-k queue_name = nil = nil queue_headers = nil __ap4r_forward_by_queue_info(queue_name, , queue_headers) end |
#__ap4r_queue_put(queue_name, queue_message, queue_headers) ⇒ Object Also known as: queue_put
Puts a message into queue. As queue_headers, some options are supported. See the reliable-msg docuememt for more details.
78 79 80 81 |
# File 'lib/ap4r/store_and_forward.rb', line 78 def __ap4r_queue_put(queue_name, , queue_headers) q = ReliableMsg::Queue.new(queue_name, :drb_uri => @@drb_uri || DRUBY_URI) q.put(, queue_headers) end |