use of org.apache.activemq.artemis.core.server.LargeServerMessage in project activemq-artemis by apache.
the class ServerSessionImpl method messageToLargeMessage.
private LargeServerMessage messageToLargeMessage(Message message) throws Exception {
ICoreMessage coreMessage = message.toCore();
LargeServerMessage lsm = getStorageManager().createLargeMessage(storageManager.generateID(), coreMessage);
ActiveMQBuffer buffer = coreMessage.getReadOnlyBodyBuffer();
byte[] body = new byte[buffer.readableBytes()];
buffer.readBytes(body);
lsm.addBytes(body);
lsm.releaseResources();
lsm.putLongProperty(Message.HDR_LARGE_BODY_SIZE, body.length);
return lsm;
}
use of org.apache.activemq.artemis.core.server.LargeServerMessage in project activemq-artemis by apache.
the class ServerConsumerImpl method handle.
@Override
public HandleStatus handle(final MessageReference ref) throws Exception {
if (callback != null && !callback.hasCredits(this) || availableCredits != null && availableCredits.get() <= 0) {
if (logger.isDebugEnabled()) {
logger.debug(this + " is busy for the lack of credits. Current credits = " + availableCredits + " Can't receive reference " + ref);
}
return HandleStatus.BUSY;
}
synchronized (lock) {
// TCP-flow control has to be done first than everything else otherwise we may lose notifications
if (!callback.isWritable(this, protocolContext) || !started || transferring) {
return HandleStatus.BUSY;
}
// This has to be checked inside the lock as the set to null is done inside the lock
if (largeMessageDeliverer != null) {
if (logger.isDebugEnabled()) {
logger.debug(this + " is busy delivering large message " + largeMessageDeliverer + ", can't deliver reference " + ref);
}
return HandleStatus.BUSY;
}
final Message message = ref.getMessage();
if (!message.acceptsConsumer(sequentialID())) {
return HandleStatus.NO_MATCH;
}
if (filter != null && !filter.match(message)) {
if (logger.isTraceEnabled()) {
logger.trace("Reference " + ref + " is a noMatch on consumer " + this);
}
return HandleStatus.NO_MATCH;
}
if (logger.isTraceEnabled()) {
logger.trace("ServerConsumerImpl::" + this + " Handling reference " + ref);
}
if (!browseOnly) {
if (!preAcknowledge) {
deliveringRefs.add(ref);
}
ref.handled();
ref.setConsumerId(this.id);
ref.incrementDeliveryCount();
// the updateDeliveryCountAfterCancel would still be updated after c
if (strictUpdateDeliveryCount && !ref.isPaged()) {
if (ref.getMessage().isDurable() && ref.getQueue().isDurableMessage() && !ref.getQueue().isInternalQueue() && !ref.isPaged()) {
storageManager.updateDeliveryCount(ref);
}
}
if (preAcknowledge) {
if (message.isLargeMessage()) {
// we must hold one reference, or the file will be deleted before it could be delivered
((LargeServerMessage) message).incrementDelayDeletionCount();
}
// With pre-ack, we ack *before* sending to the client
ref.getQueue().acknowledge(ref);
acks++;
}
if (message.isLargeMessage() && this.supportLargeMessage) {
largeMessageDeliverer = new LargeMessageDeliverer((LargeServerMessage) message, ref);
}
}
lockDelivery.readLock().lock();
return HandleStatus.HANDLED;
}
}
Aggregations