use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project wildfly by wildfly.
the class ServerAdd method processAddressSettings.
/**
* Process the address settings.
*
* @param configuration the ActiveMQ configuration
* @param params the detyped operation parameters
*/
/**
* Process the address settings.
*
* @param configuration the ActiveMQ configuration
* @param params the detyped operation parameters
* @throws org.jboss.as.controller.OperationFailedException
*/
static void processAddressSettings(final OperationContext context, final Configuration configuration, final ModelNode params) throws OperationFailedException {
if (params.hasDefined(ADDRESS_SETTING)) {
for (final Property property : params.get(ADDRESS_SETTING).asPropertyList()) {
final String match = property.getName();
final ModelNode config = property.getValue();
final AddressSettings settings = AddressSettingAdd.createSettings(context, config);
configuration.getAddressesSettings().put(match, settings);
}
}
}
use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.
the class PostOfficeImpl method route.
@Override
public RoutingStatus route(final Message message, final RoutingContext context, final boolean direct, boolean rejectDuplicates, final Binding bindingMove) throws Exception {
RoutingStatus result;
// Sanity check
if (message.getRefCount() > 0) {
throw new IllegalStateException("Message cannot be routed more than once");
}
setPagingStore(context.getAddress(message), message);
AtomicBoolean startedTX = new AtomicBoolean(false);
final SimpleString address = context.getAddress(message);
applyExpiryDelay(message, address);
if (!checkDuplicateID(message, context, rejectDuplicates, startedTX)) {
return RoutingStatus.DUPLICATED_ID;
}
message.cleanupInternalProperties();
Bindings bindings = addressManager.getBindingsForRoutingAddress(context.getAddress(message));
// first check for the auto-queue creation thing
if (bindings == null) {
// There is no queue with this address, we will check if it needs to be created
// if (queueCreator.create(address)) {
// TODO: this is not working!!!!
// reassign bindings if it was created
// bindings = addressManager.getBindingsForRoutingAddress(address);
// }
}
if (bindingMove != null) {
bindingMove.route(message, context);
} else if (bindings != null) {
bindings.route(message, context);
} else {
// this is a debug and not warn because this could be a regular scenario on publish-subscribe queues (or topic subscriptions on JMS)
if (logger.isDebugEnabled()) {
logger.debug("Couldn't find any bindings for address=" + address + " on message=" + message);
}
}
if (server.hasBrokerPlugins()) {
server.callBrokerPlugins(plugin -> plugin.beforeMessageRoute(message, context, direct, rejectDuplicates));
}
if (logger.isTraceEnabled()) {
logger.trace("Message after routed=" + message);
}
if (context.getQueueCount() == 0) {
// Send to DLA if appropriate
AddressSettings addressSettings = addressSettingsRepository.getMatch(address.toString());
boolean sendToDLA = addressSettings.isSendToDLAOnNoRoute();
if (sendToDLA) {
// Send to the DLA for the address
SimpleString dlaAddress = addressSettings.getDeadLetterAddress();
if (logger.isDebugEnabled()) {
logger.debug("sending message to dla address = " + dlaAddress + ", message=" + message);
}
if (dlaAddress == null) {
result = RoutingStatus.NO_BINDINGS;
ActiveMQServerLogger.LOGGER.noDLA(address);
} else {
message.referenceOriginalMessage(message, null);
message.setAddress(dlaAddress);
message.reencode();
route(message, context.getTransaction(), false);
result = RoutingStatus.NO_BINDINGS_DLA;
}
} else {
result = RoutingStatus.NO_BINDINGS;
if (logger.isDebugEnabled()) {
logger.debug("Message " + message + " is not going anywhere as it didn't have a binding on address:" + address);
}
if (message.isLargeMessage()) {
((LargeServerMessage) message).deleteFile();
}
}
} else {
result = RoutingStatus.OK;
try {
processRoute(message, context, direct);
} catch (ActiveMQAddressFullException e) {
if (startedTX.get()) {
context.getTransaction().rollback();
} else if (context.getTransaction() != null) {
context.getTransaction().markAsRollbackOnly(e);
}
throw e;
}
}
if (startedTX.get()) {
context.getTransaction().commit();
}
if (server.hasBrokerPlugins()) {
server.callBrokerPlugins(plugin -> plugin.afterMessageRoute(message, context, direct, rejectDuplicates, result));
}
return result;
}
use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.
the class PersistedAddressSetting method decode.
@Override
public void decode(ActiveMQBuffer buffer) {
addressMatch = buffer.readSimpleString();
setting = new AddressSettings();
setting.decode(buffer);
}
use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.
the class FileConfigurationParser method parseAddressSettings.
/**
* @param node
* @return
*/
protected Pair<String, AddressSettings> parseAddressSettings(final Node node) {
String match = getAttributeValue(node, "match");
NodeList children = node.getChildNodes();
AddressSettings addressSettings = new AddressSettings();
Pair<String, AddressSettings> setting = new Pair<>(match, addressSettings);
for (int i = 0; i < children.getLength(); i++) {
final Node child = children.item(i);
final String name = child.getNodeName();
if (DEAD_LETTER_ADDRESS_NODE_NAME.equalsIgnoreCase(name)) {
SimpleString queueName = new SimpleString(getTrimmedTextContent(child));
addressSettings.setDeadLetterAddress(queueName);
} else if (EXPIRY_ADDRESS_NODE_NAME.equalsIgnoreCase(name)) {
SimpleString queueName = new SimpleString(getTrimmedTextContent(child));
addressSettings.setExpiryAddress(queueName);
} else if (EXPIRY_DELAY_NODE_NAME.equalsIgnoreCase(name)) {
addressSettings.setExpiryDelay(XMLUtil.parseLong(child));
} else if (REDELIVERY_DELAY_NODE_NAME.equalsIgnoreCase(name)) {
addressSettings.setRedeliveryDelay(XMLUtil.parseLong(child));
} else if (REDELIVERY_DELAY_MULTIPLIER_NODE_NAME.equalsIgnoreCase(name)) {
addressSettings.setRedeliveryMultiplier(XMLUtil.parseDouble(child));
} else if (MAX_REDELIVERY_DELAY_NODE_NAME.equalsIgnoreCase(name)) {
addressSettings.setMaxRedeliveryDelay(XMLUtil.parseLong(child));
} else if (MAX_SIZE_BYTES_NODE_NAME.equalsIgnoreCase(name)) {
addressSettings.setMaxSizeBytes(ByteUtil.convertTextBytes(getTrimmedTextContent(child)));
} else if (PAGE_SIZE_BYTES_NODE_NAME.equalsIgnoreCase(name)) {
addressSettings.setPageSizeBytes(ByteUtil.convertTextBytes(getTrimmedTextContent(child)));
} else if (PAGE_MAX_CACHE_SIZE_NODE_NAME.equalsIgnoreCase(name)) {
addressSettings.setPageCacheMaxSize(XMLUtil.parseInt(child));
} else if (MESSAGE_COUNTER_HISTORY_DAY_LIMIT_NODE_NAME.equalsIgnoreCase(name)) {
addressSettings.setMessageCounterHistoryDayLimit(XMLUtil.parseInt(child));
} else if (ADDRESS_FULL_MESSAGE_POLICY_NODE_NAME.equalsIgnoreCase(name)) {
String value = getTrimmedTextContent(child);
Validators.ADDRESS_FULL_MESSAGE_POLICY_TYPE.validate(ADDRESS_FULL_MESSAGE_POLICY_NODE_NAME, value);
AddressFullMessagePolicy policy = Enum.valueOf(AddressFullMessagePolicy.class, value);
addressSettings.setAddressFullMessagePolicy(policy);
} else if (LVQ_NODE_NAME.equalsIgnoreCase(name) || DEFAULT_LVQ_NODE_NAME.equalsIgnoreCase(name)) {
addressSettings.setDefaultLastValueQueue(XMLUtil.parseBoolean(child));
} else if (DEFAULT_EXCLUSIVE_NODE_NAME.equalsIgnoreCase(name)) {
addressSettings.setDefaultExclusiveQueue(XMLUtil.parseBoolean(child));
} else if (MAX_DELIVERY_ATTEMPTS.equalsIgnoreCase(name)) {
addressSettings.setMaxDeliveryAttempts(XMLUtil.parseInt(child));
} else if (REDISTRIBUTION_DELAY_NODE_NAME.equalsIgnoreCase(name)) {
addressSettings.setRedistributionDelay(XMLUtil.parseLong(child));
} else if (SEND_TO_DLA_ON_NO_ROUTE.equalsIgnoreCase(name)) {
addressSettings.setSendToDLAOnNoRoute(XMLUtil.parseBoolean(child));
} else if (SLOW_CONSUMER_THRESHOLD_NODE_NAME.equalsIgnoreCase(name)) {
long slowConsumerThreshold = XMLUtil.parseLong(child);
Validators.MINUS_ONE_OR_GT_ZERO.validate(SLOW_CONSUMER_THRESHOLD_NODE_NAME, slowConsumerThreshold);
addressSettings.setSlowConsumerThreshold(slowConsumerThreshold);
} else if (SLOW_CONSUMER_CHECK_PERIOD_NODE_NAME.equalsIgnoreCase(name)) {
long slowConsumerCheckPeriod = XMLUtil.parseLong(child);
Validators.GT_ZERO.validate(SLOW_CONSUMER_CHECK_PERIOD_NODE_NAME, slowConsumerCheckPeriod);
addressSettings.setSlowConsumerCheckPeriod(slowConsumerCheckPeriod);
} else if (SLOW_CONSUMER_POLICY_NODE_NAME.equalsIgnoreCase(name)) {
String value = getTrimmedTextContent(child);
Validators.SLOW_CONSUMER_POLICY_TYPE.validate(SLOW_CONSUMER_POLICY_NODE_NAME, value);
SlowConsumerPolicy policy = Enum.valueOf(SlowConsumerPolicy.class, value);
addressSettings.setSlowConsumerPolicy(policy);
} else if (AUTO_CREATE_JMS_QUEUES.equalsIgnoreCase(name)) {
addressSettings.setAutoCreateJmsQueues(XMLUtil.parseBoolean(child));
} else if (AUTO_DELETE_JMS_QUEUES.equalsIgnoreCase(name)) {
addressSettings.setAutoDeleteJmsQueues(XMLUtil.parseBoolean(child));
} else if (AUTO_CREATE_JMS_TOPICS.equalsIgnoreCase(name)) {
addressSettings.setAutoCreateJmsTopics(XMLUtil.parseBoolean(child));
} else if (AUTO_DELETE_JMS_TOPICS.equalsIgnoreCase(name)) {
addressSettings.setAutoDeleteJmsTopics(XMLUtil.parseBoolean(child));
} else if (AUTO_CREATE_QUEUES.equalsIgnoreCase(name)) {
addressSettings.setAutoCreateQueues(XMLUtil.parseBoolean(child));
} else if (AUTO_DELETE_QUEUES.equalsIgnoreCase(name)) {
addressSettings.setAutoDeleteQueues(XMLUtil.parseBoolean(child));
} else if (CONFIG_DELETE_QUEUES.equalsIgnoreCase(name)) {
String value = getTrimmedTextContent(child);
Validators.DELETION_POLICY_TYPE.validate(CONFIG_DELETE_QUEUES, value);
DeletionPolicy policy = Enum.valueOf(DeletionPolicy.class, value);
addressSettings.setConfigDeleteQueues(policy);
} else if (AUTO_CREATE_ADDRESSES.equalsIgnoreCase(name)) {
addressSettings.setAutoCreateAddresses(XMLUtil.parseBoolean(child));
} else if (AUTO_DELETE_ADDRESSES.equalsIgnoreCase(name)) {
addressSettings.setAutoDeleteAddresses(XMLUtil.parseBoolean(child));
} else if (CONFIG_DELETE_ADDRESSES.equalsIgnoreCase(name)) {
String value = getTrimmedTextContent(child);
Validators.DELETION_POLICY_TYPE.validate(CONFIG_DELETE_ADDRESSES, value);
DeletionPolicy policy = Enum.valueOf(DeletionPolicy.class, value);
addressSettings.setConfigDeleteAddresses(policy);
} else if (MANAGEMENT_BROWSE_PAGE_SIZE.equalsIgnoreCase(name)) {
addressSettings.setManagementBrowsePageSize(XMLUtil.parseInt(child));
} else if (DEFAULT_PURGE_ON_NO_CONSUMERS.equalsIgnoreCase(name)) {
addressSettings.setDefaultPurgeOnNoConsumers(XMLUtil.parseBoolean(child));
} else if (DEFAULT_MAX_CONSUMERS.equalsIgnoreCase(name)) {
addressSettings.setDefaultMaxConsumers(XMLUtil.parseInt(child));
} else if (DEFAULT_QUEUE_ROUTING_TYPE.equalsIgnoreCase(name)) {
String value = getTrimmedTextContent(child);
Validators.ROUTING_TYPE.validate(DEFAULT_QUEUE_ROUTING_TYPE, value);
RoutingType routingType = RoutingType.valueOf(value);
addressSettings.setDefaultQueueRoutingType(routingType);
} else if (DEFAULT_ADDRESS_ROUTING_TYPE.equalsIgnoreCase(name)) {
String value = getTrimmedTextContent(child);
Validators.ROUTING_TYPE.validate(DEFAULT_ADDRESS_ROUTING_TYPE, value);
RoutingType routingType = RoutingType.valueOf(value);
addressSettings.setDefaultAddressRoutingType(routingType);
}
}
return setting;
}
use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.
the class ActiveMQServerControlImpl method createQueue.
@Override
public void createQueue(final String address, final String name, final String filterStr, final boolean durable, final String routingType) throws Exception {
AddressSettings addressSettings = server.getAddressSettingsRepository().getMatch(address == null ? name : address);
createQueue(address, routingType, name, filterStr, durable, addressSettings.getDefaultMaxConsumers(), addressSettings.isDefaultPurgeOnNoConsumers(), addressSettings.isAutoCreateAddresses());
}
Aggregations