validateJMSDestName(destName);
validateJMSDestType(destType);
int newDestType = JMSConstants.QUEUE;
JMSAdmin jmsAdmin = null;
boolean connected = false;
try {
/* Do not restrict the number of consumers, because in 4.1 MQ
* open MQ, there is no restriction on the number of consumers
* for a queue. In 4.0 PE there was a restriction of 2.
* Fixes issue : 6543199
*/
if (destType.equals(JMSAdminConstants.JMS_DEST_TYPE_QUEUE)) {
if (destProps == null) {
destProps = new Properties();
}
String maxConsumersProperty = IASJmsUtil.getMaxActiveConsumersProperty();
String maxConsumersAttribute = IASJmsUtil.getMaxActiveConsumersAttribute();
String maxConsumersValue = IASJmsUtil.getDefaultMaxActiveConsumers();
if (!destProps.containsKey(maxConsumersProperty) &&
!destProps.containsKey(maxConsumersAttribute) ) {
destProps.put(maxConsumersAttribute, maxConsumersValue);
}
}
// check and use JMX
Target target = getResourceTarget(tgtName);
if (JMSDestination.useJMX(target)) {
JMSDestination jmsd = new JMSDestination();
jmsd.createJMSDestination(destName, destType, destProps, tgtName);
return;
} else {
jmsAdmin = getJMSAdmin(tgtName);
jmsAdmin.connectToProvider();
connected = true;
if (destType.equals(JMSAdminConstants.JMS_DEST_TYPE_TOPIC)) {
newDestType = JMSConstants.TOPIC;
} else if (destType.equals(JMSAdminConstants.JMS_DEST_TYPE_QUEUE)) {
newDestType = JMSConstants.QUEUE;
}
jmsAdmin.createProviderDestination(destName, newDestType, destProps);
}
} catch (Exception e) {
handleException(e);
} finally {
if (connected) {
try {
jmsAdmin.disconnectFromProvider();
} catch (Exception ex) {
handleException(ex);
}
}
}