private void validateClientID(ClientSession validateSession, String clientID) throws InvalidClientIDException { try { validateSession.addUniqueMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY, clientID); } catch (ActiveMQException e) { if (e.getType() == ActiveMQExceptionType.DUPLICATE_METADATA) { throw new InvalidClientIDException("clientID=" + clientID + " was already set into another connection"); } } }
@Override public void connectionFailed(ActiveMQException exception, boolean failedOver) { if (clusterConnection && exception.getType() == ActiveMQExceptionType.DISCONNECTED) { try { ServerLocatorImpl.this.start(startExecutor); } catch (Exception e) { // There isn't much to be done if this happens here ActiveMQClientLogger.LOGGER.errorStartingLocator(e); } } }
/** * @throws ActiveMQException */ private void checkException() throws ActiveMQException { // it's not needed to copy it as we never set it back to null // once the exception is set, the controller is pretty much useless if (handledException != null) { if (handledException instanceof ActiveMQException) { ActiveMQException nestedException; // This is just to be user friendly and give the user a proper exception trace, // instead to just where it was canceled. if (handledException instanceof ActiveMQLargeMessageInterruptedException) { nestedException = new ActiveMQLargeMessageInterruptedException(handledException.getMessage()); } else { nestedException = new ActiveMQException(((ActiveMQException) handledException).getType(), handledException.getMessage()); } nestedException.initCause(handledException); throw nestedException; } else { throw new ActiveMQException(ActiveMQExceptionType.LARGE_MESSAGE_ERROR_BODY, "Error on saving LargeMessageBufferImpl", handledException); } } }
@Override public void encodeRest(final ActiveMQBuffer buffer) { buffer.writeInt(exception.getType().getCode()); buffer.writeNullableString(exception.getMessage()); }
} catch (ActiveMQException e) { if (e.getType() == ActiveMQExceptionType.SESSION_CREATION_REJECTED) { ActiveMQClientLogger.LOGGER.retryCreateSessionSeverStarting(name); retry = true;
@Override public void fail(final ActiveMQException me, String scaleDownTargetNodeID) { synchronized (failLock) { if (destroyed) { return; } destroyed = true; } if (!(me instanceof ActiveMQRemoteDisconnectException)) { ActiveMQClientLogger.LOGGER.connectionFailureDetected(me.getMessage(), me.getType()); } try { transportConnection.forceClose(); } catch (Throwable e) { ActiveMQClientLogger.LOGGER.failedForceClose(e); } // Then call the listeners callFailureListeners(me, scaleDownTargetNodeID); callClosingListeners(); internalClose(); for (Channel channel : channels.values()) { channel.returnBlocking(me); } }
return createSessionContext(clientVersion, name, username, password, xa, autoCommitSends, autoCommitAcks, preAcknowledge, minLargeMessageSize, confirmationWindowSize); } catch (ActiveMQException e) { if (e.getType() != ActiveMQExceptionType.INCOMPATIBLE_CLIENT_SERVER_VERSIONS) { throw e; throw cause; if (cause.getType() == ActiveMQExceptionType.UNBLOCKED) {
if (e.getType() == ActiveMQExceptionType.NOT_CONNECTED) { attempts++;
public static JMSException convertFromActiveMQException(final ActiveMQException me) { JMSException je; switch (me.getType()) { case CONNECTION_TIMEDOUT: je = new JMSException(me.getMessage());
@Override public void connectionFailed(ActiveMQException exception, boolean failedOver) { if (clusterConnection && exception.getType() == ActiveMQExceptionType.DISCONNECTED) { try { ServerLocatorImpl.this.start(startExecutor); } catch (Exception e) { // There isn't much to be done if this happens here ActiveMQClientLogger.LOGGER.errorStartingLocator(e); } } }
@Override public void connectionFailed(ActiveMQException exception, boolean failedOver) { if (clusterConnection && exception.getType() == ActiveMQExceptionType.DISCONNECTED) { try { ServerLocatorImpl.this.start(startExecutor); } catch (Exception e) { // There isn't much to be done if this happens here ActiveMQClientLogger.LOGGER.errorStartingLocator(e); } } }
@Override public void connectionFailed(final ActiveMQException me, boolean failedOver) { if (me.getType() == ActiveMQExceptionType.DISCONNECTED) { if (ActiveMQXARecoveryLogger.LOGGER.isDebugEnabled()) { ActiveMQXARecoveryLogger.LOGGER.debug("being disconnected for server shutdown", me); } } else { ActiveMQXARecoveryLogger.LOGGER.xaRecoverConnectionError(me, csf); } close(); }
@Override public void encodeRest(final ActiveMQBuffer buffer) { buffer.writeInt(exception.getType().getCode()); buffer.writeNullableString(exception.getMessage()); }
protected static void expectActiveMQException(final String message, final ActiveMQExceptionType errorCode, final ActiveMQAction action) { try { action.run(); Assert.fail(message); } catch (Exception e) { Assert.assertTrue(e instanceof ActiveMQException); Assert.assertEquals(errorCode, ((ActiveMQException) e).getType()); } }
@Test public void testCreateConsumerNoQ() throws Exception { try { clientSession.createConsumer(queueName); Assert.fail("should throw exception"); } catch (ActiveMQNonExistentQueueException neqe) { //ok } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } }
@Test public void testProducerOnClosedSession() throws Exception { clientSession.close(); try { clientSession.createProducer(); Assert.fail("should throw exception"); } catch (ActiveMQObjectClosedException oce) { //ok } catch (ActiveMQException e) { fail("Invalid Exception type:" + e.getType()); } }