use of org.apache.activemq.artemis.core.config.CoreQueueConfiguration in project activemq-artemis by apache.
the class CorePluginTest method testSimpleBridge.
@Test
public void testSimpleBridge() throws Exception {
server.stop();
ActiveMQServer server0;
ActiveMQServer server1;
Map<String, Object> server0Params = new HashMap<>();
server0 = createClusteredServerWithParams(false, 0, false, server0Params);
Map<String, Object> server1Params = new HashMap<>();
server1Params.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
server1 = createClusteredServerWithParams(false, 1, false, server1Params);
final String testAddress = "testAddress";
final String queueName0 = "queue0";
final String forwardAddress = "forwardAddress";
TransportConfiguration server1tc = new TransportConfiguration(INVM_CONNECTOR_FACTORY, server1Params);
HashMap<String, TransportConfiguration> connectors = new HashMap<>();
connectors.put(server1tc.getName(), server1tc);
server0.getConfiguration().setConnectorConfigurations(connectors);
server0.registerBrokerPlugin(verifier);
ArrayList<String> connectorConfig = new ArrayList<>();
connectorConfig.add(server1tc.getName());
BridgeConfiguration bridgeConfiguration = new BridgeConfiguration().setName("bridge1").setQueueName(queueName0).setForwardingAddress(forwardAddress).setRetryInterval(1000).setReconnectAttemptsOnSameNode(-1).setUseDuplicateDetection(false).setStaticConnectors(connectorConfig);
List<BridgeConfiguration> bridgeConfigs = new ArrayList<>();
bridgeConfigs.add(bridgeConfiguration);
server0.getConfiguration().setBridgeConfigurations(bridgeConfigs);
CoreQueueConfiguration queueConfig0 = new CoreQueueConfiguration().setAddress(testAddress).setName(queueName0);
List<CoreQueueConfiguration> queueConfigs0 = new ArrayList<>();
queueConfigs0.add(queueConfig0);
server0.getConfiguration().setQueueConfigurations(queueConfigs0);
server1.start();
server0.start();
verifier.validatePluginMethodsEquals(1, BEFORE_DEPLOY_BRIDGE, AFTER_DEPLOY_BRIDGE);
server0.stop();
server1.stop();
}
use of org.apache.activemq.artemis.core.config.CoreQueueConfiguration in project wildfly by wildfly.
the class QueueAdd method performRuntime.
@Override
@SuppressWarnings("unchecked")
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(context.getCurrentAddress());
ServiceController<?> serverService = registry.getService(serviceName);
if (serverService != null) {
final String queueName = context.getCurrentAddressValue();
final CoreQueueConfiguration queueConfiguration = ConfigurationHelper.createCoreQueueConfiguration(context, queueName, model);
final ServiceName queueServiceName = MessagingServices.getQueueBaseServiceName(serviceName).append(queueName);
final ServiceBuilder sb = context.getServiceTarget().addService(queueServiceName);
sb.requires(ActiveMQActivationService.getServiceName(serviceName));
Supplier<ActiveMQServer> serverSupplier = sb.requires(serviceName);
final QueueService service = new QueueService(serverSupplier, queueConfiguration, false, true);
sb.setInitialMode(Mode.PASSIVE);
sb.setInstance(service);
sb.install();
}
// else the initial subsystem install is not complete; MessagingSubsystemAdd will add a
// handler that calls addQueueConfigs
}
use of org.apache.activemq.artemis.core.config.CoreQueueConfiguration in project wildfly by wildfly.
the class QueueAdd method createCoreQueueConfiguration.
private static CoreQueueConfiguration createCoreQueueConfiguration(final OperationContext context, String name, ModelNode model) throws OperationFailedException {
final String queueAddress = QueueDefinition.ADDRESS.resolveModelAttribute(context, model).asString();
final ModelNode filterNode = FILTER.resolveModelAttribute(context, model);
final String filter = filterNode.isDefined() ? filterNode.asString() : null;
final boolean durable = DURABLE.resolveModelAttribute(context, model).asBoolean();
return new CoreQueueConfiguration().setAddress(queueAddress).setName(name).setFilterString(filter).setDurable(durable);
}
use of org.apache.activemq.artemis.core.config.CoreQueueConfiguration in project activemq-artemis by apache.
the class FileConfigurationParser method parseQueueConfiguration.
protected CoreQueueConfiguration parseQueueConfiguration(final Node node) {
String name = getAttributeValue(node, "name");
String address = null;
String filterString = null;
boolean durable = true;
int maxConsumers = ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers();
boolean purgeOnNoConsumers = ActiveMQDefaultConfiguration.getDefaultPurgeOnNoConsumers();
String user = null;
Boolean exclusive = null;
Boolean lastValue = null;
NamedNodeMap attributes = node.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
Node item = attributes.item(i);
if (item.getNodeName().equals("max-consumers")) {
maxConsumers = Integer.parseInt(item.getNodeValue());
Validators.MAX_QUEUE_CONSUMERS.validate(name, maxConsumers);
} else if (item.getNodeName().equals("purge-on-no-consumers")) {
purgeOnNoConsumers = Boolean.parseBoolean(item.getNodeValue());
} else if (item.getNodeName().equals("exclusive")) {
exclusive = Boolean.parseBoolean(item.getNodeValue());
} else if (item.getNodeName().equals("last-value")) {
lastValue = Boolean.parseBoolean(item.getNodeValue());
}
}
NodeList children = node.getChildNodes();
for (int j = 0; j < children.getLength(); j++) {
Node child = children.item(j);
if (child.getNodeName().equals("address")) {
address = getTrimmedTextContent(child);
} else if (child.getNodeName().equals("filter")) {
filterString = getAttributeValue(child, "string");
} else if (child.getNodeName().equals("durable")) {
durable = XMLUtil.parseBoolean(child);
} else if (child.getNodeName().equals("user")) {
user = getTrimmedTextContent(child);
}
}
return new CoreQueueConfiguration().setAddress(address).setName(name).setFilterString(filterString).setDurable(durable).setMaxConsumers(maxConsumers).setPurgeOnNoConsumers(purgeOnNoConsumers).setUser(user).setExclusive(exclusive).setLastValue(lastValue);
}
use of org.apache.activemq.artemis.core.config.CoreQueueConfiguration in project activemq-artemis by apache.
the class FileConfigurationParser method parseQueueConfigurations.
private List<CoreQueueConfiguration> parseQueueConfigurations(final Element node, RoutingType routingType) {
List<CoreQueueConfiguration> queueConfigurations = new ArrayList<>();
NodeList list = node.getElementsByTagName("queue");
for (int i = 0; i < list.getLength(); i++) {
CoreQueueConfiguration queueConfig = parseQueueConfiguration(list.item(i));
queueConfig.setRoutingType(routingType);
queueConfigurations.add(queueConfig);
}
return queueConfigurations;
}
Aggregations