use of org.apache.activemq.artemis.core.server.RouteContextList in project activemq-artemis by apache.
the class RoutingContextImpl method addQueueWithAck.
@Override
public void addQueueWithAck(SimpleString address, Queue queue) {
addQueue(address, queue);
RouteContextList listing = getContextListing(address);
listing.addAckedQueue(queue);
}
use of org.apache.activemq.artemis.core.server.RouteContextList in project activemq-artemis by apache.
the class PostOfficeImpl method processRoute.
@Override
public void processRoute(final Message message, final RoutingContext context, final boolean direct) throws Exception {
final List<MessageReference> refs = new ArrayList<>();
Transaction tx = context.getTransaction();
Long deliveryTime = message.getScheduledDeliveryTime();
for (Map.Entry<SimpleString, RouteContextList> entry : context.getContexListing().entrySet()) {
PagingStore store = pagingManager.getPageStore(entry.getKey());
if (storageManager.addToPage(store, message, context.getTransaction(), entry.getValue())) {
if (message.isLargeMessage()) {
confirmLargeMessageSend(tx, message);
}
// We need to kick delivery so the Queues may check for the cursors case they are empty
schedulePageDelivery(tx, entry);
continue;
}
for (Queue queue : entry.getValue().getNonDurableQueues()) {
MessageReference reference = MessageReference.Factory.createReference(message, queue);
if (deliveryTime != null) {
reference.setScheduledDeliveryTime(deliveryTime);
}
refs.add(reference);
message.incrementRefCount();
}
Iterator<Queue> iter = entry.getValue().getDurableQueues().iterator();
while (iter.hasNext()) {
Queue queue = iter.next();
MessageReference reference = MessageReference.Factory.createReference(message, queue);
if (context.isAlreadyAcked(context.getAddress(message), queue)) {
reference.setAlreadyAcked();
if (tx != null) {
queue.acknowledge(tx, reference);
}
}
if (deliveryTime != null) {
reference.setScheduledDeliveryTime(deliveryTime);
}
refs.add(reference);
if (message.isDurable()) {
int durableRefCount = message.incrementDurableRefCount();
if (durableRefCount == 1) {
if (tx != null) {
storageManager.storeMessageTransactional(tx.getID(), message);
} else {
storageManager.storeMessage(message);
}
if (message.isLargeMessage()) {
confirmLargeMessageSend(tx, message);
}
}
if (tx != null) {
storageManager.storeReferenceTransactional(tx.getID(), queue.getID(), message.getMessageID());
tx.setContainsPersistent();
} else {
storageManager.storeReference(queue.getID(), message.getMessageID(), !iter.hasNext());
}
if (deliveryTime > 0) {
if (tx != null) {
storageManager.updateScheduledDeliveryTimeTransactional(tx.getID(), reference);
} else {
storageManager.updateScheduledDeliveryTime(reference);
}
}
}
message.incrementRefCount();
}
}
if (tx != null) {
tx.addOperation(new AddOperation(refs));
} else {
// This will use the same thread if there are no pending operations
// avoiding a context switch on this case
storageManager.afterCompleteOperations(new IOCallback() {
@Override
public void onError(final int errorCode, final String errorMessage) {
ActiveMQServerLogger.LOGGER.ioErrorAddingReferences(errorCode, errorMessage);
}
@Override
public void done() {
addReferences(refs, direct);
}
});
}
}
use of org.apache.activemq.artemis.core.server.RouteContextList in project activemq-artemis by apache.
the class RoutingContextImpl method getContextListing.
@Override
public RouteContextList getContextListing(SimpleString address) {
RouteContextList listing = map.get(address);
if (listing == null) {
listing = new ContextListing();
map.put(address, listing);
}
return listing;
}
use of org.apache.activemq.artemis.core.server.RouteContextList in project activemq-artemis by apache.
the class RoutingContextImpl method addQueue.
@Override
public void addQueue(final SimpleString address, final Queue queue) {
RouteContextList listing = getContextListing(address);
if (queue.isDurableMessage()) {
listing.getDurableQueues().add(queue);
} else {
listing.getNonDurableQueues().add(queue);
}
queueCount++;
}
Aggregations