Class | WMQ::QueueManager |
In: |
ext/wmq.c
ext/lib/wmq_temp.rb |
Parent: | Object |
Connect to the queue manager, then disconnect once the supplied code block completes
Parameters:
WMQ::QueueManager.connect( # WebSphere MQ Equivalents: :q_mgr_name => 'queue_manager name', :exception_on_error => true, # n/a :connect_options => WMQ::MQCNO_FASTBATH_BINDING # MQCNO.Options :trace_level => 0, # n/a # Common client connection parameters :channel_name => 'svrconn channel name', # MQCD.ChannelName :connection_name => 'localhost(1414)', # MQCD.ConnectionName :transport_type => WMQ::MQXPT_TCP, # MQCD.TransportType # Advanced client connections parameters :max_msg_length => 65535, # MQCD.MaxMsgLength :security_exit => 'Name of security exit', # MQCD.SecurityExit :send_exit => 'Name of send exit', # MQCD.SendExit :receive_exit => 'Name of receive exit', # MQCD.ReceiveExit :security_user_data => 'Security exit User data', # MQCD.SecurityUserData :send_user_data => 'Send exit user data', # MQCD.SendUserData :receive_user_data => 'Receive exit user data', # MQCD.ReceiveUserData :heartbeat_interval => 1, # MQCD.HeartbeatInterval :remote_security_id => 'Remote Security id', # MQCD.RemoteSecurityId :ssl_cipher_spec => 'SSL Cipher Spec', # MQCD.SSLCipherSpec :keep_alive_interval=> -1, # MQCD.KeepAliveInterval :mode_name => 'LU6.2 Mode Name', # MQCD.ModeName :tp_name => 'LU6.2 Transaction pgm name', # MQCD.TpName :user_identifier => 'LU 6.2 Userid', # MQCD.UserIdentifier :password => 'LU6.2 Password', # MQCD.Password :long_remote_user_id=> 'Long remote user identifier', # MQCD.LongRemoteUserId (Ptr, Length) :ssl_peer_name => 'SSL Peer name', # MQCD.SSLPeerName (Ptr, Length) # SSL Options :key_repository => '/var/mqm/qmgrs/.../key', # MQSCO.KeyRepository :crypto_hardware => 'GSK_ACCELERATOR_NCIPHER_NF_ON', # MQSCO.CryptoHardware )
Optional Parameters
- Server connections will connect to the default queue manager - Client connections will connect to whatever queue manager is found at the host and port number as specified by the connection_name
Determines whether WMQ::WMQExceptions are thrown whenever an error occurs during a WebSphere MQ operation (connect, put, get, etc..) Default: true
WMQ::MQCNO_STANDARD_BINDING WMQ::MQCNO_FASTPATH_BINDING WMQ::MQCNO_SHARED_BINDING WMQ::MQCNO_ISOLATED_BINDING WMQ::MQCNO_ACCOUNTING_MQI_ENABLED WMQ::MQCNO_ACCOUNTING_MQI_DISABLED WMQ::MQCNO_ACCOUNTING_Q_ENABLED WMQ::MQCNO_ACCOUNTING_Q_DISABLED WMQ::MQCNO_NONE
:connect_options=>WMQ::MQCNO_FASTPATH_BINDING | WMQ::MQCNO_ACCOUNTING_MQI_ENABLED
Default: WMQ::MQCNO_NONE
Common Client Connection Parameters (Client connections only)
'mymachine.domain.com(1414)' '192.168.0.1(1417)'
'SYSTEM.DEF.SVRCONN'
WMQ::MQXPT_LOCAL WMQ::MQXPT_LU62 WMQ::MQXPT_TCP WMQ::MQXPT_NETBIOS WMQ::MQXPT_SPX WMQ::MQXPT_DECNET WMQ::MQXPT_UDP
WMQ::MQXPT_TCP
For the Advanced Client Connection parameters, please see the WebSphere MQ documentation
Note:
Local Server Connection Example:
require 'wmq/wmq' WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr| qmgr.put(:q_name=>'TEST.QUEUE', :data => 'Hello World') end
Client Connection Example:
require 'wmq/wmq_client' WMQ::QueueManager.connect( :channel_name => 'SYSTEM.DEF.SVRCONN', :transport_type => WMQ::MQXPT_TCP, :connection_name => 'localhost(1414)' ) do |qmgr| qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:input) do |queue| message = WMQ::Message.new if queue.get(:message => message) puts "Data Received: #{message.data}" else puts 'No message available' end end end
Parameters:
Note:
Todo:
Open the specified queue, then close it once the supplied code block has completed
Parameters:
Example:
require 'wmq/wmq_client' WMQ::QueueManager.connect(:q_mgr_name=>'REID', :connection_name=>'localhost(1414)') do |qmgr| qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue| queue.put(:data => 'Hello World') end end
Backout the current unit of work for this QueueManager instance
Since the last commit or rollback any messages put to a queue under synchpoint will be removed and any messages retrieved under synchpoint from any queues will be returned
Note:
Returns:
comp_code and reason_code are also updated. reason will return a text description of the reason_code
Throws:
Advanced WebSphere MQ Use:
Begin a unit of work between this QueueManager instance and another resource such as a Database
Starts a new unit of work under which put and get can be called with with the parameter :sync => true
Returns:
comp_code and reason_code are also updated. reason will return a text description of the reason_code
Throws:
Commit the current unit of work for this QueueManager instance
Note:
Returns:
comp_code and reason_code are also updated. reason will return a text description of the reason_code
Throws:
Return the completion code for the last MQ operation
Returns => FixNum
Before working with any queues, it is necessary to connect to the queue manager.
Returns:
comp_code and reason_code are also updated. reason will return a text description of the reason_code
Throws:
Returns whether this QueueManager instance is currently connected to a WebSphere MQ queue manager
Returns:
Disconnect from this QueueManager instance
Returns:
comp_code and reason_code are also updated. reason will return a text description of the reason_code
Throws:
Returns whether this QueueManager instance is set to throw a WMQ::WMQException whenever an MQ operation fails
Returns:
Note:
Execute an Administration command against the local queue manager
Parameters:
For all MQ Admin commands, just drop the MQAI_ off the front and convert the command name to lower case.
For the hundreds of parameters, a similiar technique is followed. Remove the prefixes: MQCA_, MQIA_, etc.. and convert to lowercase
Example
WMQ::QueueManager.connect do |qmgr| result = qmgr.execute( :command => :inquire_q, :q_name => 'MY.LOCAL.QUEUE', :q_type => WMQ::MQQT_LOCAL, :current_q_depth => nil ) # OR, we can replace the method name execute with the MQAI command: result = qmgr.inquire_q( :q_name => 'MY.LOCAL.QUEUE', :q_type => WMQ::MQQT_LOCAL, :current_q_depth => nil )
Complete Example:
require 'wmq/wmq' require 'wmq/wmq_const_admin' WMQ::QueueManager.connect(:q_mgr_name=>'REID', :connection_name=>'localhost(1414)') do |qmgr| qmgr.reset_q_stats(:q_name=>'*').each {|item| p item } end
Some one line examples
qmgr.inquire_q(:q_name=>'TEST*').each {|item| p item } qmgr.inquire_q(:q_name=>'TEST*', :q_type=>WMQ::MQQT_LOCAL, :current_q_depth=>nil).each {|item| p item } qmgr.inquire_process(:process_name=>'*').each {|item| p item } qmgr.ping_q_mgr.each {|item| p item } qmgr.refresh_security.each {|item| p item } qmgr.inquire_q_status(:q_name=>'TEST*', :q_status_type=>:q_status, :q_status_attrs=>:process_id).each {|item| p item } qmgr.start_channel_listener.each {|item| p item } qmgr.inquire_channel_status(:channel_name=>'*').each {|item| p item }
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
Open the specified queue, then close it once the supplied code block has completed
Parameters:
Example:
require 'wmq/wmq_client' WMQ::QueueManager.connect(:q_mgr_name=>'REID', :connection_name=>'localhost(1414)') do |qmgr| qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue| queue.put(:data => 'Hello World') end end
Put a message to the queue without having to first open the queue Recommended for reply queues that change frequently
Summary of parameters and their WebSphere MQ equivalents
queue.get( # WebSphere MQ Equivalents: :q_name => 'Queue Name', # MQOD.ObjectName :q_name => { queue_manager=>'QMGR_name', # MQOD.ObjectQMgrName q_name =>'q_name'} :message => my_message, # n/a : Instance of Message :data => "Hello World", # n/a : Data to send :sync => false, # MQGMO_SYNCPOINT :new_id => true, # MQPMO_NEW_MSG_ID & MQPMO_NEW_CORREL_ID :new_msg_id => true, # MQPMO_NEW_MSG_ID :new_correl_id => true, # MQPMO_NEW_CORREL_ID :fail_if_quiescing => true, # MQOO_FAIL_IF_QUIESCING :options => WMQ::MQPMO_FAIL_IF_QUIESCING # MQPMO_* )
Mandatory Parameters
OR
It is not possible to get messages from a queue on a queue manager other than the currently connected queue manager
Optional Parameters
Default: false
Default: false
Default: false
Default: false
Default: true Equivalent to: MQGMO_FAIL_IF_QUIESCING
WMQ::MQPMO_NO_SYNCPOINT WMQ::MQPMO_LOGICAL_ORDER WMQ::MQPMO_NO_CONTEXT WMQ::MQPMO_DEFAULT_CONTEXT WMQ::MQPMO_PASS_IDENTITY_CONTEXT WMQ::MQPMO_PASS_ALL_CONTEXT WMQ::MQPMO_SET_IDENTITY_CONTEXT WMQ::MQPMO_SET_ALL_CONTEXT WMQ::MQPMO_ALTERNATE_USER_AUTHORITY WMQ::MQPMO_RESOLVE_LOCAL_Q WMQ::MQPMO_NONE
Default: WMQ::MQPMO_NONE
Returns:
comp_code and reason_code are also updated. reason will return a text description of the reason_code
Throws:
Put a message to the Dead Letter Queue
If an error occurs when processing a datagram message it is necessary to move the message to the dead letter queue. I.e. An error message cannot be sent back to the sender because the original message was not a request message. I.e. msg_type != WMQ::MQMT_REQUEST All existing message data, message descriptor and message headers are retained.
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 messages. No reply for Datagrams - Set the message type to Reply when replying to a request message - Reply with: - Remaining Expiry (Ideally deduct any processing time since get) - Same priority as received message - Same persistence as received message - Adhere to the Report options supplied for message 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 message originally received * All the other parameters are the same as QueueManager#put
Returns a textual representation of the reason_code for the last MQ operation
Returns => String
Note
Return the reason code for the last MQ operation
Returns => FixNum
Note