use of org.apache.activemq.artemis.api.core.ActiveMQIOErrorException in project activemq-artemis by apache.
the class ServerSessionImpl method send.
@Override
public synchronized RoutingStatus send(Transaction tx, Message msg, final boolean direct, boolean noAutoCreateQueue) throws Exception {
final Message message;
if ((msg.getEncodeSize() > storageManager.getMaxRecordSize()) && !msg.isLargeMessage()) {
message = messageToLargeMessage(msg);
} else {
message = msg;
}
if (server.hasBrokerPlugins()) {
server.callBrokerPlugins(plugin -> plugin.beforeSend(this, tx, message, direct, noAutoCreateQueue));
}
// If the protocol doesn't support flow control, we have no choice other than fail the communication
if (!this.getRemotingConnection().isSupportsFlowControl() && pagingManager.isDiskFull()) {
ActiveMQIOErrorException exception = ActiveMQMessageBundle.BUNDLE.diskBeyondLimit();
this.getRemotingConnection().fail(exception);
throw exception;
}
final RoutingStatus result;
// case the id header already generated.
if (!message.isLargeMessage()) {
long id = storageManager.generateID();
// This will re-encode the message
message.setMessageID(id);
}
SimpleString address = message.getAddressSimpleString();
if (defaultAddress == null && address != null) {
defaultAddress = address;
}
if (address == null) {
// We don't want to force a re-encode when the message gets sent to the consumer
message.setAddress(defaultAddress);
}
if (logger.isTraceEnabled()) {
logger.trace("send(message=" + message + ", direct=" + direct + ") being called");
}
if (message.getAddress() == null) {
// This could happen with some tests that are ignoring messages
throw ActiveMQMessageBundle.BUNDLE.noAddress();
}
if (message.getAddressSimpleString().equals(managementAddress)) {
// It's a management message
result = handleManagementMessage(tx, message, direct);
} else {
result = doSend(tx, message, address, direct, noAutoCreateQueue);
}
if (server.hasBrokerPlugins()) {
server.callBrokerPlugins(plugin -> plugin.afterSend(this, tx, message, direct, noAutoCreateQueue, result));
}
return result;
}
use of org.apache.activemq.artemis.api.core.ActiveMQIOErrorException in project activemq-artemis by apache.
the class LargeServerMessageImpl method getBodySize.
private long getBodySize() throws ActiveMQException {
try {
if (bodySize < 0) {
if (file != null) {
bodySize = file.size();
} else {
SequentialFile tmpFile = createFile();
bodySize = tmpFile.size();
tmpFile.close();
}
}
return bodySize;
} catch (Exception e) {
ActiveMQIOErrorException errorException = new ActiveMQIOErrorException();
errorException.initCause(e);
throw errorException;
}
}
use of org.apache.activemq.artemis.api.core.ActiveMQIOErrorException in project activemq-artemis by apache.
the class ServerSessionPacketHandler method onSessionSend.
private void onSessionSend(Packet packet) {
this.storageManager.setContext(session.getSessionContext());
try {
Packet response = null;
boolean requiresResponse = false;
try {
final SessionSendMessage message = (SessionSendMessage) packet;
requiresResponse = message.isRequiresResponse();
this.session.send(EmbedMessageUtil.extractEmbedded(message.getMessage()), this.direct);
if (requiresResponse) {
response = new NullResponseMessage();
}
} catch (ActiveMQIOErrorException e) {
response = onActiveMQIOErrorExceptionWhileHandlePacket(e, requiresResponse, response, this.session);
} catch (ActiveMQXAException e) {
response = onActiveMQXAExceptionWhileHandlePacket(e, requiresResponse, response);
} catch (ActiveMQQueueMaxConsumerLimitReached e) {
response = onActiveMQQueueMaxConsumerLimitReachedWhileHandlePacket(e, requiresResponse, response);
} catch (ActiveMQException e) {
response = onActiveMQExceptionWhileHandlePacket(e, requiresResponse, response);
} catch (Throwable t) {
response = onCatchThrowableWhileHandlePacket(t, requiresResponse, response, this.session);
}
sendResponse(packet, response, false, false);
} finally {
this.storageManager.clearContext();
}
}
use of org.apache.activemq.artemis.api.core.ActiveMQIOErrorException in project activemq-artemis by apache.
the class ServerSessionPacketHandler method onSessionConsumerFlowCredit.
private void onSessionConsumerFlowCredit(Packet packet) {
this.storageManager.setContext(session.getSessionContext());
try {
Packet response = null;
boolean requiresResponse = false;
try {
SessionConsumerFlowCreditMessage message = (SessionConsumerFlowCreditMessage) packet;
session.receiveConsumerCredits(message.getConsumerID(), message.getCredits());
} catch (ActiveMQIOErrorException e) {
response = onActiveMQIOErrorExceptionWhileHandlePacket(e, requiresResponse, response, this.session);
} catch (ActiveMQXAException e) {
response = onActiveMQXAExceptionWhileHandlePacket(e, requiresResponse, response);
} catch (ActiveMQQueueMaxConsumerLimitReached e) {
response = onActiveMQQueueMaxConsumerLimitReachedWhileHandlePacket(e, requiresResponse, response);
} catch (ActiveMQException e) {
response = onActiveMQExceptionWhileHandlePacket(e, requiresResponse, response);
} catch (Throwable t) {
response = onCatchThrowableWhileHandlePacket(t, requiresResponse, response, this.session);
}
sendResponse(packet, response, false, false);
} finally {
this.storageManager.clearContext();
}
}
use of org.apache.activemq.artemis.api.core.ActiveMQIOErrorException in project activemq-artemis by apache.
the class JournalImplTestUnit method testVersionCheck.
@Test
public void testVersionCheck() throws Exception {
setup(10, 10 * 1024, true);
createJournal();
startJournal();
load();
stopJournal();
fileFactory.start();
List<String> files = fileFactory.listFiles(fileExtension);
for (String fileStr : files) {
SequentialFile file = fileFactory.createSequentialFile(fileStr);
ByteBuffer buffer = fileFactory.newBuffer(JournalImpl.SIZE_HEADER);
for (int i = 0; i < JournalImpl.SIZE_HEADER; i++) {
buffer.put(Byte.MAX_VALUE);
}
buffer.rewind();
file.open();
file.position(0);
file.writeDirect(buffer, sync);
file.close();
}
fileFactory.stop();
startJournal();
boolean exceptionHappened = false;
try {
load();
} catch (ActiveMQIOErrorException ioe) {
exceptionHappened = true;
} catch (ActiveMQException e) {
Assert.fail("invalid exception type:" + e.getType());
}
Assert.assertTrue("Exception was expected", exceptionHappened);
stopJournal();
}
Aggregations