title: How to set stanza properties without a mqclient.ini file in a Java IBM MQ client?
body: <p>I am looking for a way to programmatically set client attributes inside an IBM MQ Java client application. I do realise IBM provides a way of <a href="https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_8.0.0/com.ibm.mq.con.doc/q016840_.htm" rel="nofollow noreferrer">configuring MQ Clients using a <code>mqclient.ini</code> file</a>, however due to the nature of deployment and distribution of the application I'm working on it is not possible to use such a file. Hence, I want to set a stanza attribute that would normally be defined in the ini file, inside the connetion configuration block of my code. </p>
  
  <p>Furthermore, I am aware that certain properties can be set as environment variables or Java command line arguments, but that would not be a viable workaround due to the same reasons mentioned above. </p>
  
  <p>In particular I'm interested in the setting the <code>KeepAlive</code> attribute in the TCP stanza to YES.
  So far I have attempted the following ways of achieving that using an <code>MQQueueConnectionFactory</code> : </p>
  
  <pre><code>connectionFactory.setStringProperty("KeepAlive", "YES");
  
  connectionFactory.setStringProperty("com.ibm.mq.cfg.TCP.KeepAlive", "YES");
  
  connectionFactory.setBooleanProperty("KeepAlive", true);
  
  connectionFactory.setBooleanProperty("com.ibm.mq.cfg.TCP.KeepAlive", true);
  </code></pre>
  
  <p>However, none of those have had any effect. </p>
  
  <p>For the record I am using IBM MQ classes for JMS version 8. </p>