ext/wmq_queue_manager.c in rubywmq-2.0.2 vs ext/wmq_queue_manager.c in rubywmq-2.1.0
- old
+ new
@@ -1,21 +1,5 @@
-/*
- * Copyright 2006 J. Reid Morrison
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
#include "wmq.h"
static ID ID_open;
static ID ID_call;
static ID ID_new;
@@ -48,10 +32,11 @@
static ID ID_remote_security_id;
static ID ID_ssl_cipher_spec;
static ID ID_ssl_peer_name;
static ID ID_keep_alive_interval;
static ID ID_crypto_hardware;
+static ID ID_use_system_connection_data;
/* MQSCO ID's */
static ID ID_key_repository;
/* Admin ID's */
@@ -72,30 +57,31 @@
ID_trace_level = rb_intern("trace_level");
ID_descriptor = rb_intern("descriptor");
ID_message = rb_intern("message");
/* MQCD ID's */
- ID_channel_name = rb_intern("channel_name");
- ID_transport_type = rb_intern("transport_type");
- ID_mode_name = rb_intern("mode_name");
- ID_tp_name = rb_intern("tp_name");
- ID_security_exit = rb_intern("security_exit");
- ID_send_exit = rb_intern("send_exit");
- ID_receive_exit = rb_intern("receive_exit");
- ID_max_msg_length = rb_intern("max_msg_length");
- ID_security_user_data = rb_intern("security_user_data");
- ID_send_user_data = rb_intern("send_user_data");
- ID_receive_user_data = rb_intern("receive_user_data");
- ID_user_identifier = rb_intern("user_identifier");
- ID_password = rb_intern("password");
- ID_connection_name = rb_intern("connection_name");
- ID_heartbeat_interval = rb_intern("heartbeat_interval");
- ID_long_remote_user_id = rb_intern("long_remote_user_id");
- ID_remote_security_id = rb_intern("remote_security_id");
- ID_ssl_cipher_spec = rb_intern("ssl_cipher_spec");
- ID_ssl_peer_name = rb_intern("ssl_peer_name");
- ID_keep_alive_interval = rb_intern("keep_alive_interval");
+ ID_channel_name = rb_intern("channel_name");
+ ID_transport_type = rb_intern("transport_type");
+ ID_mode_name = rb_intern("mode_name");
+ ID_tp_name = rb_intern("tp_name");
+ ID_security_exit = rb_intern("security_exit");
+ ID_send_exit = rb_intern("send_exit");
+ ID_receive_exit = rb_intern("receive_exit");
+ ID_max_msg_length = rb_intern("max_msg_length");
+ ID_security_user_data = rb_intern("security_user_data");
+ ID_send_user_data = rb_intern("send_user_data");
+ ID_receive_user_data = rb_intern("receive_user_data");
+ ID_user_identifier = rb_intern("user_identifier");
+ ID_password = rb_intern("password");
+ ID_connection_name = rb_intern("connection_name");
+ ID_heartbeat_interval = rb_intern("heartbeat_interval");
+ ID_long_remote_user_id = rb_intern("long_remote_user_id");
+ ID_remote_security_id = rb_intern("remote_security_id");
+ ID_ssl_cipher_spec = rb_intern("ssl_cipher_spec");
+ ID_ssl_peer_name = rb_intern("ssl_peer_name");
+ ID_keep_alive_interval = rb_intern("keep_alive_interval");
+ ID_use_system_connection_data = rb_intern("use_system_connection_data");
/* MQSCO ID's */
ID_key_repository = rb_intern("key_repository");
ID_crypto_hardware = rb_intern("crypto_hardware");
@@ -241,16 +227,31 @@
/*
* All Client connection parameters are ignored if connection_name is missing
*/
#ifdef MQCNO_VERSION_2
- if(!NIL_P(rb_hash_aref(hash, ID2SYM(ID_connection_name))))
+ int use_system_connection_data = (rb_hash_aref(hash, ID2SYM(ID_use_system_connection_data)) == Qtrue) ? 1 : 0;
+
+ if(!NIL_P(rb_hash_aref(hash, ID2SYM(ID_connection_name))) || use_system_connection_data)
{
PMQCD pmqcd = &pqm->client_conn; /* Process MQCD */
pqm->is_client_conn = 1; /* Set to Client connection */
- WMQ_HASH2MQCHARS(hash,connection_name, pmqcd->ConnectionName)
+ if(use_system_connection_data)
+ {
+ /*
+ * Use system defined connection data rather than explicitly providing a
+ * connection name. This is used with CCDT, the MQSERVER ENV var or the
+ * mqclient.ini file
+ */
+ pqm->connect_options.ClientConnPtr = NULL;
+ }
+ else
+ {
+ WMQ_HASH2MQCHARS(hash,connection_name, pmqcd->ConnectionName)
+ }
+
WMQ_HASH2MQLONG (hash,transport_type, pmqcd->TransportType)
WMQ_HASH2MQCHARS(hash,mode_name, pmqcd->ModeName)
WMQ_HASH2MQCHARS(hash,tp_name, pmqcd->TpName)
WMQ_HASH2MQCHARS(hash,security_exit, pmqcd->SecurityExit)
WMQ_HASH2MQCHARS(hash,send_exit, pmqcd->SendExit)
@@ -382,11 +383,11 @@
* comp_code and reason_code are also updated.
* reason will return a text description of the reason_code
*
* Throws:
* * WMQ::WMQException if comp_code != MQCC_OK
- * * Except if :exception_on_error => false was supplied as a parameter
+ * * Except if exception_on_error: false was supplied as a parameter
* to QueueManager.new
*/
VALUE QueueManager_connect(VALUE self)
{
VALUE name;
@@ -457,11 +458,11 @@
* comp_code and reason_code are also updated.
* reason will return a text description of the reason_code
*
* Throws:
* * WMQ::WMQException if comp_code != MQCC_OK
- * * Except if :exception_on_error => false was supplied as a parameter
+ * * Except if exception_on_error: false was supplied as a parameter
* to QueueManager.new
*/
VALUE QueueManager_disconnect(VALUE self)
{
PQUEUE_MANAGER pqm;
@@ -507,22 +508,22 @@
/*
* Commit the current unit of work for this QueueManager instance
*
* Note:
* * commit will have no effect if all put and get operations were performed
- * without specifying :sync => true
+ * without specifying sync: true
*
* Returns:
* * true : On Success
* * false: On Failure
*
* comp_code and reason_code are also updated.
* reason will return a text description of the reason_code
*
* Throws:
* * WMQ::WMQException if comp_code != MQCC_OK
- * * Except if :exception_on_error => false was supplied as a parameter
+ * * Except if exception_on_error: false was supplied as a parameter
* to QueueManager.new
*/
VALUE QueueManager_commit(VALUE self)
{
PQUEUE_MANAGER pqm;
@@ -559,22 +560,22 @@
* under synchpoint will be removed and any messages retrieved
* under synchpoint from any queues will be returned
*
* Note:
* * backout will have no effect if all put and get operations were performed
- * without specifying :sync => true
+ * without specifying sync: true
*
* Returns:
* * true : On Success
* * false: On Failure
*
* comp_code and reason_code are also updated.
* reason will return a text description of the reason_code
*
* Throws:
* * WMQ::WMQException if comp_code != MQCC_OK
- * * Except if :exception_on_error => false was supplied as a parameter
+ * * Except if exception_on_error: false was supplied as a parameter
* to QueueManager.new
*/
VALUE QueueManager_backout(VALUE self)
{
PQUEUE_MANAGER pqm;
@@ -609,22 +610,22 @@
*
* 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
+ * with the parameter sync: true
*
* Returns:
* * true : On Success
* * false: On Failure
*
* comp_code and reason_code are also updated.
* reason will return a text description of the reason_code
*
* Throws:
* * WMQ::WMQException if comp_code != MQCC_OK
- * * Except if :exception_on_error => false was supplied as a parameter
+ * * Except if exception_on_error: false was supplied as a parameter
* to QueueManager.new
*/
VALUE QueueManager_begin(VALUE self)
{
PQUEUE_MANAGER pqm;
@@ -663,21 +664,21 @@
*
* * parameters: a Hash consisting of one or more of the following parameters
*
* 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_*
+ * 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
* * :q_name => String
* * Name of the existing WebSphere MQ local queue, model queue or remote queue to open
@@ -749,11 +750,11 @@
* queue managers without having to resort to the 'immediate'
* shutdown option.
*
* * :options => Fixnum (Advanced MQ Use only)
* * Numeric field containing any of the MQ Put message options or'd together
- * * E.g. :options => WMQ::MQPMO_PASS_IDENTITY_CONTEXT | WMQ::MQPMO_ALTERNATE_USER_AUTHORITY
+ * * E.g. options: WMQ::MQPMO_PASS_IDENTITY_CONTEXT | WMQ::MQPMO_ALTERNATE_USER_AUTHORITY
* * Note: If :options is supplied, it is applied first, then the above parameters are
* applied afterwards.
* * One or more of the following values:
* WMQ::MQPMO_NO_SYNCPOINT
* WMQ::MQPMO_LOGICAL_ORDER
@@ -776,11 +777,11 @@
* comp_code and reason_code are also updated.
* reason will return a text description of the reason_code
*
* Throws:
* * WMQ::WMQException if comp_code == MQCC_FAILED
- * * Except if :exception_on_error => false was supplied as a parameter
+ * * Except if exception_on_error: false was supplied as a parameter
* to QueueManager.new
*/
VALUE QueueManager_put(VALUE self, VALUE hash)
{
MQLONG BufferLength; /* Length of the message in Buffer */
@@ -999,13 +1000,13 @@
* since it is supplied automatically by this method
*
* 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')
+ * 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
*/
VALUE QueueManager_open_queue(int argc, VALUE *argv, VALUE self)
{
@@ -1067,47 +1068,47 @@
*
* Parameters:
* * Since the number of parameters can vary dramatically, all parameters are passed by name in a hash
* * Summary of parameters and their WebSphere MQ equivalents:
* 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
+ * 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
+ * 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
+ * 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)
+ * 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
+ * key_repository: '/var/mqm/qmgrs/.../key', # MQSCO.KeyRepository
+ * crypto_hardware: 'GSK_ACCELERATOR_NCIPHER_NF_ON', # MQSCO.CryptoHardware
* )
*
* Optional Parameters
- * * :q_mgr_name => String
+ * * q_mgr_name: String
* * Name of the existing WebSphere MQ Queue Manager to connect to
*
* * Default:
* - Server connections will connect to the default queue manager
* - Client connections will connect to whatever queue
@@ -1169,10 +1170,16 @@
* WMQ::MQXPT_UDP
*
* * Default Value:
* WMQ::MQXPT_TCP
*
+ * * :use_system_connection_data => Boolean
+ * * Used when you want to initialise a client connection, but you want
+ * * to obtain the connection_name and channel_name from one of the system
+ * * configuration methods. These being: mqclient.ini file, MQSERVER ENV
+ * * variable or CCDT.
+ *
* For the Advanced Client Connection parameters, please see the WebSphere MQ documentation
*
* Note:
* * If an exception is not caught in the code block, the current unit of work is
* automatically backed out, before disconnecting from the queue manager.
@@ -1186,17 +1193,17 @@
*
* 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|
+ * 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)
+ * if queue.get(message: message)
* puts "Data Received: #{message.data}"
* else
* puts 'No message available'
* end
* end
@@ -1323,44 +1330,44 @@
* * E.g. MQCA_Q_NAME becomes :q_name
*
* 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
+ * 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
+ * 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 }
+ * 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*').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_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.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.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 }
+ * qmgr.inquire_channel_status(channel_name: '*').each {|item| p item }
*/
VALUE QueueManager_execute(VALUE self, VALUE hash)
{
#ifdef MQHB_UNUSABLE_HBAG
VALUE val;