use of org.apache.activemq.artemis.api.core.ActiveMQInterruptedException in project activemq-artemis by apache.
the class TimedBuffer method stop.
public void stop() {
enterCritical(CRITICAL_PATH_STOP);
Thread localTimer = null;
try {
// add critical analyzer here.... <<<<
synchronized (this) {
try {
if (!started) {
return;
}
flush();
bufferObserver = null;
timerRunnable.close();
spinLimiter.release();
if (logRates) {
logRatesTimerTask.cancel();
}
localTimer = timerThread;
timerThread = null;
} finally {
started = false;
}
}
if (localTimer != null) {
while (localTimer.isAlive()) {
try {
localTimer.join(1000);
if (localTimer.isAlive()) {
localTimer.interrupt();
}
} catch (InterruptedException e) {
throw new ActiveMQInterruptedException(e);
}
}
}
} finally {
leaveCritical(CRITICAL_PATH_STOP);
}
}
use of org.apache.activemq.artemis.api.core.ActiveMQInterruptedException in project activemq-artemis by apache.
the class ActiveMQMessageConsumer method getMessage.
private ActiveMQMessage getMessage(final long timeout, final boolean noWait) throws JMSException {
try {
ClientMessage coreMessage;
if (noWait) {
coreMessage = consumer.receiveImmediate();
} else {
coreMessage = consumer.receive(timeout);
}
ActiveMQMessage jmsMsg = null;
if (coreMessage != null) {
ClientSession coreSession = session.getCoreSession();
boolean needSession = ackMode == Session.CLIENT_ACKNOWLEDGE || ackMode == ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE || coreMessage.getType() == ActiveMQObjectMessage.TYPE;
jmsMsg = ActiveMQMessage.createMessage(coreMessage, needSession ? coreSession : null, options);
try {
jmsMsg.doBeforeReceive();
} catch (IndexOutOfBoundsException ioob) {
((ClientSessionInternal) session.getCoreSession()).markRollbackOnly();
// In case this exception happen you will need to know where it happened.
// it has been a bug here in the past, and this was used to debug it.
// nothing better than keep it for future investigations in case it happened again
IndexOutOfBoundsException newIOOB = new IndexOutOfBoundsException(ioob.getMessage() + "@" + jmsMsg.getCoreMessage());
newIOOB.initCause(ioob);
ActiveMQClientLogger.LOGGER.unableToGetMessage(newIOOB);
throw ioob;
}
// https://issues.jboss.org/browse/JBPAPP-6110
if (session.getAcknowledgeMode() == ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE) {
jmsMsg.setIndividualAcknowledge();
} else if (session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE) {
jmsMsg.setClientAcknowledge();
coreMessage.acknowledge();
} else {
coreMessage.acknowledge();
}
}
return jmsMsg;
} catch (ActiveMQException e) {
((ClientSessionInternal) session.getCoreSession()).markRollbackOnly();
throw JMSExceptionHelper.convertFromActiveMQException(e);
} catch (ActiveMQInterruptedException e) {
((ClientSessionInternal) session.getCoreSession()).markRollbackOnly();
throw JMSExceptionHelper.convertFromActiveMQException(e);
}
}
Aggregations