use of jakarta.jms.InvalidClientIDException in project openmq by eclipse-ee4j.
the class JMSBridge method openConnection.
public static Connection openConnection(Object cf, int maximumAttempts, long attemptInterval, String username, String password, String logstr, Object caller, EventListener l, Logger logger, boolean doReconnect) throws Exception {
if (l.hasEventOccurred()) {
throw new JMSException("" + l.occurredEvent());
}
int maxAttempts = maximumAttempts;
Connection conn = null;
int attempts = 0;
Exception ee = null;
int invalidClientIDExceptionCnt = 0;
do {
if (Thread.currentThread().isInterrupted()) {
throw new InterruptedException(_jbr.getKString(_jbr.X_OPENCONNECTION_INTERRUPTED, cf.toString(), caller.toString()));
}
if (attempts > 0 && attemptInterval > 0) {
Thread.sleep(attemptInterval);
}
try {
String[] param = { (username == null ? "" : "[" + username + "]"), cf.toString(), caller.toString() };
if (cf instanceof XAConnectionFactory) {
logger.log(Level.INFO, _jbr.getString(_jbr.I_CREATING_XA_CONN, param));
if (username == null) {
conn = ((XAConnectionFactory) cf).createXAConnection();
} else {
conn = ((XAConnectionFactory) cf).createXAConnection(username, password);
}
} else {
logger.log(Level.INFO, _jbr.getString(_jbr.I_CREATING_CONN, param));
if (username == null) {
conn = ((ConnectionFactory) cf).createConnection();
} else {
conn = ((ConnectionFactory) cf).createConnection(username, password);
}
}
return conn;
} catch (JMSException e) {
attempts++;
ee = e;
Exception le = e.getLinkedException();
if (e instanceof InvalidClientIDException) {
invalidClientIDExceptionCnt++;
}
if (e instanceof JMSSecurityException || le instanceof JMSSecurityException || (e instanceof InvalidClientIDException && invalidClientIDExceptionCnt > 1)) {
String[] eparam = { logstr, caller.toString(), attempts + "(" + attemptInterval + ")" };
_logger.log(Level.SEVERE, _jbr.getKString(_jbr.W_EXCEPTION_CREATING_CONN, eparam), e);
throw e;
}
String[] eparam = { logstr, caller.toString(), attempts + "(" + attemptInterval + "): " + e.getMessage() + (le == null ? "" : " - " + le.getMessage()) };
_logger.log(Level.WARNING, _jbr.getKString(_jbr.W_EXCEPTION_CREATING_CONN, eparam));
if (!doReconnect && (maxAttempts > 1 || maxAttempts < 0)) {
throw new ProviderConnectException("Failed to connect to " + cf + ": " + e.getMessage() + (le == null ? "" : " - " + le.getMessage()));
}
}
} while ((maxAttempts < 0 || attempts < maxAttempts) && !l.hasEventOccurred());
if (l.hasEventOccurred()) {
throw new JMSException("" + l.occurredEvent());
}
throw ee;
}
use of jakarta.jms.InvalidClientIDException in project openmq by eclipse-ee4j.
the class ConnectionAdapter method _setClientIDForContext.
/**
* Set clientID to the specified value, bypassing any checks as to whether calling setClientID is allowed at this time
*/
@Override
public void _setClientIDForContext(String clientID) {
_loggerJC.entering(_className, "_setClientIDForContext()", clientID);
checkClosed2();
try {
xac._setClientID(clientID);
} catch (InvalidClientIDException ice) {
throw new MQInvalidClientIDRuntimeException(ice);
} catch (JMSException e) {
throw new MQRuntimeException(e);
}
}
Aggregations