use of org.apache.activemq.artemis.core.server.Queue in project activemq-artemis by apache.
the class PostOfficeImpl method schedulePageDelivery.
/**
* This will kick a delivery async on the queue, so the queue may have a chance to depage messages
*
* @param tx
* @param entry
*/
private void schedulePageDelivery(Transaction tx, Map.Entry<SimpleString, RouteContextList> entry) {
if (tx != null) {
PageDelivery delivery = (PageDelivery) tx.getProperty(TransactionPropertyIndexes.PAGE_DELIVERY);
if (delivery == null) {
delivery = new PageDelivery();
tx.putProperty(TransactionPropertyIndexes.PAGE_DELIVERY, delivery);
tx.addOperation(delivery);
}
delivery.addQueues(entry.getValue().getDurableQueues());
delivery.addQueues(entry.getValue().getNonDurableQueues());
} else {
List<Queue> durableQueues = entry.getValue().getDurableQueues();
List<Queue> nonDurableQueues = entry.getValue().getNonDurableQueues();
final List<Queue> queues = new ArrayList<>(durableQueues.size() + nonDurableQueues.size());
queues.addAll(durableQueues);
queues.addAll(nonDurableQueues);
storageManager.afterCompleteOperations(new IOCallback() {
@Override
public void onError(int errorCode, String errorMessage) {
}
@Override
public void done() {
for (Queue queue : queues) {
// in case of paging, we need to kick asynchronous delivery to try delivering
queue.deliverAsync();
}
}
});
}
}
use of org.apache.activemq.artemis.core.server.Queue in project activemq-artemis by apache.
the class PostOfficeImpl method removeBinding.
@Override
public synchronized Binding removeBinding(final SimpleString uniqueName, Transaction tx, boolean deleteData) throws Exception {
if (server.hasBrokerPlugins()) {
server.callBrokerPlugins(plugin -> plugin.beforeRemoveBinding(uniqueName, tx, deleteData));
}
addressSettingsRepository.clearCache();
Binding binding = addressManager.removeBinding(uniqueName, tx);
if (binding == null) {
throw new ActiveMQNonExistentQueueException();
}
if (deleteData && addressManager.getBindingsForRoutingAddress(binding.getAddress()) == null) {
pagingManager.deletePageStore(binding.getAddress());
deleteDuplicateCache(binding.getAddress());
}
if (binding.getType() == BindingType.LOCAL_QUEUE) {
Queue queue = (Queue) binding.getBindable();
managementService.unregisterQueue(uniqueName, binding.getAddress(), queue.getRoutingType());
} else if (binding.getType() == BindingType.DIVERT) {
managementService.unregisterDivert(uniqueName, binding.getAddress());
}
if (binding.getType() != BindingType.DIVERT) {
TypedProperties props = new TypedProperties();
props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, binding.getAddress());
props.putSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME, binding.getClusterName());
props.putSimpleStringProperty(ManagementHelper.HDR_ROUTING_NAME, binding.getRoutingName());
props.putIntProperty(ManagementHelper.HDR_DISTANCE, binding.getDistance());
props.putLongProperty(ManagementHelper.HDR_BINDING_ID, binding.getID());
if (binding.getFilter() == null) {
props.putSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING, null);
} else {
props.putSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING, binding.getFilter().getFilterString());
}
managementService.sendNotification(new Notification(null, CoreNotificationType.BINDING_REMOVED, props));
}
binding.close();
if (server.hasBrokerPlugins()) {
server.callBrokerPlugins(plugin -> plugin.afterRemoveBinding(binding, tx, deleteData));
}
return binding;
}
use of org.apache.activemq.artemis.core.server.Queue in project activemq-artemis by apache.
the class PostOfficeImpl method updateQueue.
@Override
public QueueBinding updateQueue(SimpleString name, RoutingType routingType, Integer maxConsumers, Boolean purgeOnNoConsumers, Boolean exclusive) throws Exception {
synchronized (addressLock) {
final QueueBinding queueBinding = (QueueBinding) addressManager.getBinding(name);
if (queueBinding == null) {
return null;
}
final Queue queue = queueBinding.getQueue();
boolean changed = false;
// validate update
if (maxConsumers != null && maxConsumers.intValue() != Queue.MAX_CONSUMERS_UNLIMITED) {
final int consumerCount = queue.getConsumerCount();
if (consumerCount > maxConsumers) {
throw ActiveMQMessageBundle.BUNDLE.invalidMaxConsumersUpdate(name.toString(), maxConsumers, consumerCount);
}
}
if (routingType != null) {
final SimpleString address = queue.getAddress();
final AddressInfo addressInfo = addressManager.getAddressInfo(address);
final EnumSet<RoutingType> addressRoutingTypes = addressInfo.getRoutingTypes();
if (!addressRoutingTypes.contains(routingType)) {
throw ActiveMQMessageBundle.BUNDLE.invalidRoutingTypeUpdate(name.toString(), routingType, address.toString(), addressRoutingTypes);
}
}
// atomic update
if (maxConsumers != null && queue.getMaxConsumers() != maxConsumers.intValue()) {
changed = true;
queue.setMaxConsumer(maxConsumers);
}
if (routingType != null && queue.getRoutingType() != routingType) {
changed = true;
queue.setRoutingType(routingType);
}
if (purgeOnNoConsumers != null && queue.isPurgeOnNoConsumers() != purgeOnNoConsumers.booleanValue()) {
changed = true;
queue.setPurgeOnNoConsumers(purgeOnNoConsumers);
}
if (exclusive != null && queue.isExclusive() != exclusive.booleanValue()) {
changed = true;
queue.setExclusive(exclusive);
}
if (changed) {
final long txID = storageManager.generateID();
try {
storageManager.updateQueueBinding(txID, queueBinding);
storageManager.commitBindings(txID);
} catch (Throwable throwable) {
storageManager.rollback(txID);
logger.warn(throwable.getMessage(), throwable);
throw throwable;
}
}
return queueBinding;
}
}
use of org.apache.activemq.artemis.core.server.Queue in project activemq-artemis by apache.
the class QueueView method toJson.
@Override
public JsonObjectBuilder toJson(QueueControl queue) {
Queue q = server.locateQueue(new SimpleString(queue.getName()));
JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("id", toString(queue.getID())).add("name", toString(queue.getName())).add("address", toString(queue.getAddress())).add("filter", toString(queue.getFilter())).add("rate", toString(q.getRate())).add("durable", toString(queue.isDurable())).add("paused", toString(q.isPaused())).add("temporary", toString(queue.isTemporary())).add("purgeOnNoConsumers", toString(queue.isPurgeOnNoConsumers())).add("consumerCount", toString(queue.getConsumerCount())).add("maxConsumers", toString(queue.getMaxConsumers())).add("autoCreated", toString(q.isAutoCreated())).add("user", toString(q.getUser())).add("routingType", toString(queue.getRoutingType())).add("messagesAdded", toString(queue.getMessagesAdded())).add("messageCount", toString(queue.getMessageCount())).add("messagesAcked", toString(queue.getMessagesAcknowledged())).add("deliveringCount", toString(queue.getDeliveringCount())).add("messagesKilled", toString(queue.getMessagesKilled())).add("deliverDeliver", toString(q.isDirectDeliver())).add("exclusive", toString(queue.isExclusive())).add("lastValue", toString(queue.isLastValue()));
return obj;
}
use of org.apache.activemq.artemis.core.server.Queue in project activemq-artemis by apache.
the class ClusterConnectionImpl method nodeUP.
@Override
public void nodeUP(final TopologyMember topologyMember, final boolean last) {
if (stopping) {
return;
}
final String nodeID = topologyMember.getNodeId();
if (logger.isDebugEnabled()) {
String ClusterTestBase = "receiving nodeUP for nodeID=";
logger.debug(this + ClusterTestBase + nodeID + " connectionPair=" + topologyMember);
}
if (nodeID.equals(nodeManager.getNodeId().toString())) {
if (logger.isTraceEnabled()) {
logger.trace(this + "::informing about backup to itself, nodeUUID=" + nodeManager.getNodeId() + ", connectorPair=" + topologyMember + ", this = " + this);
}
return;
}
// if the node is more than 1 hop away, we do not create a bridge for direct cluster connection
if (allowDirectConnectionsOnly && !allowableConnections.contains(topologyMember.getLive().newTransportConfig(TRANSPORT_CONFIG_NAME))) {
return;
}
// and empty static connectors to create bridges... ulgy!
if (serverLocator == null) {
return;
}
/*we don't create bridges to backups*/
if (topologyMember.getLive() == null) {
if (logger.isTraceEnabled()) {
logger.trace(this + " ignoring call with nodeID=" + nodeID + ", topologyMember=" + topologyMember + ", last=" + last);
}
return;
}
synchronized (recordsGuard) {
try {
MessageFlowRecord record = records.get(nodeID);
if (record == null) {
if (logger.isDebugEnabled()) {
logger.debug(this + "::Creating record for nodeID=" + nodeID + ", topologyMember=" + topologyMember);
}
// New node - create a new flow record
final SimpleString queueName = new SimpleString(storeAndForwardPrefix + name + "." + nodeID);
Binding queueBinding = postOffice.getBinding(queueName);
Queue queue;
if (queueBinding != null) {
queue = (Queue) queueBinding.getBindable();
} else {
// Add binding in storage so the queue will get reloaded on startup and we can find it - it's never
// actually routed to at that address though
queue = server.createQueue(queueName, RoutingType.MULTICAST, queueName, null, true, false, -1, false, true);
}
// There are a few things that will behave differently when it's an internal queue
// such as we don't hold groupIDs inside the SnF queue
queue.setInternalQueue(true);
createNewRecord(topologyMember.getUniqueEventID(), nodeID, topologyMember.getLive(), queueName, queue, true);
} else {
if (logger.isTraceEnabled()) {
logger.trace(this + " ignored nodeUp record for " + topologyMember + " on nodeID=" + nodeID + " as the record already existed");
}
}
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.errorUpdatingTopology(e);
}
}
}
Aggregations