Class: WMQ::QueueManager
- Inherits:
-
Object
- Object
- WMQ::QueueManager
- Defined in:
- ext/wmq.c,
ext/lib/wmq_temp.rb
Class Method Summary collapse
Instance Method Summary collapse
- #access_queue ⇒ Object
- #backout ⇒ Object
- #begin ⇒ Object
- #commit ⇒ Object
- #comp_code ⇒ Object
- #connect ⇒ Object
- #connected? ⇒ Boolean
- #disconnect ⇒ Object
- #exception_on_error ⇒ Object
- #execute ⇒ Object
- #initialize ⇒ Object constructor
- #method_missing(name, *args) ⇒ Object
-
#mqsc(mqsc_text) ⇒ Object
Execute any MQSC command against the queue manager.
- #name ⇒ Object
- #open_queue ⇒ Object
- #put ⇒ Object
-
#put_to_dead_letter_q(parms) ⇒ Object
Put a message to the Dead Letter Queue.
-
#put_to_reply_q(parms) ⇒ Object
Put a reply message back to the sender.
- #reason ⇒ Object
- #reason_code ⇒ Object
Constructor Details
#initialize ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'ext/lib/wmq_temp.rb', line 23 def method_missing(name, *args) if args.size == 1 self.execute({:command=>name}.merge(args[0])) elsif args.size == 0 self.execute({:command=>name}) else raise("Invalid arguments supplied to QueueManager#:#{name}, args:#{args}") end end |
Class Method Details
.connect ⇒ Object
Instance Method Details
#access_queue ⇒ Object
#backout ⇒ Object
#begin ⇒ Object
#commit ⇒ Object
#comp_code ⇒ Object
#connect ⇒ Object
#connected? ⇒ Boolean
#disconnect ⇒ Object
#exception_on_error ⇒ Object
#execute ⇒ Object
#mqsc(mqsc_text) ⇒ Object
Execute any MQSC command against the queue manager
Example
require 'wmq/wmq'
require 'wmq/wmq_const_admin'
WMQ::QueueManager.connect(:q_mgr_name=>'REID', :connection_name=>'localhost(1414)') do |qmgr|
qmgr.mqsc('dis ql(*)').each {|item| p item }
end
41 42 43 |
# File 'ext/lib/wmq_temp.rb', line 41 def mqsc(mqsc_text) self.execute(:command=>:escape, :escape_type=>WMQ::MQET_MQSC, :escape_text=>mqsc_text).collect {|item| item[:escape_text] } end |
#name ⇒ Object
#open_queue ⇒ Object
#put ⇒ Object
#put_to_dead_letter_q(parms) ⇒ Object
Put a message to the Dead Letter Queue
If an error occurs when processing a datagram
it is necessary to move the to the dead letter queue.
I.e. An error cannot be sent back to the sender because
the original was not a request .
I.e. msg_type != WMQ::MQMT_REQUEST
All existing data, descriptor and headers
are retained.
114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'ext/lib/wmq_temp.rb', line 114 def put_to_dead_letter_q(parms) = parms[:message] ||= Message.new(:data=>parms[:data]) dlh = { :header_type =>:dead_letter_header, :reason =>parms.delete(:reason), :dest_q_name =>parms.delete(:q_name), :dest_q_mgr_name =>self.name} .headers.unshift(dlh) parms[:q_name]='SYSTEM.DEAD.LETTER.QUEUE' #TODO Should be obtained from QMGR config return self.put(parms) end |
#put_to_reply_q(parms) ⇒ Object
Put a reply message back to the sender
The :message is sent to the queue and queue manager specified in the
:reply_to_q and :reply_to_q_mgr propoerties of the :request_message.
The following rules are followed before sending the reply:
- Only send replies to Request . No reply for Datagrams
- Set the type to Reply when to a request
- Reply with:
- Remaining Expiry (Ideally deduct any processing time since get)
- Same priority as received
- Same persistence as received
- Adhere to the Report supplied for and correlation id's
in reply message
- All headers must be returned on reply messages
- This allows the calling application to store state information
in these headers
- Unless of course if the relevant header is input only and used
for completing the request
- In this case any remaining headers should be returned
to the caller
Parameters:
* :request_message The originally received
* All the other parameters are the same as QueueManager#put
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'ext/lib/wmq_temp.rb', line 71 def put_to_reply_q(parms) # Send replies only if message type is request if parms[:request_message].descriptor[:msg_type] == WMQ::MQMT_REQUEST request = parms.delete(:request_message) reply = parms[:message] ||= Message.new(:data=>parms[:data]) reply.descriptor[:msg_type] = WMQ::MQMT_REPLY reply.descriptor[:expiry] = request.descriptor[:expiry] reply.descriptor[:priority] = request.descriptor[:priority] reply.descriptor[:persistence]= request.descriptor[:persistence] reply.descriptor[:format] = request.descriptor[:format] # Set Correlation Id based on report options supplied if request.descriptor[:report] & WMQ::MQRO_PASS_CORREL_ID != 0 reply.descriptor[:correl_id] = request.descriptor[:correl_id] else reply.descriptor[:correl_id] = request.descriptor[:msg_id] end # Set Message Id based on report options supplied if request.descriptor[:report] & WMQ::MQRO_PASS_MSG_ID != 0 reply.descriptor[:msg_id] = request.descriptor[:msg_id] end parms[:q_name] = request.descriptor[:reply_to_q] parms[:q_mgr_name]= request.descriptor[:reply_to_q_mgr] return put(parms) else return false end end |