use of org.apache.activemq.artemis.core.server.ActiveMQServer in project wildfly by wildfly.
the class AddressSettingsWriteHandler method applyUpdateToRuntime.
@Override
protected boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode resolvedValue, final ModelNode currentValue, final HandbackHolder<RevertHandback> handbackHolder) throws OperationFailedException {
final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
final ActiveMQServer server = getActiveMQServer(context, operation);
if (server != null) {
final ModelNode model = resource.getModel();
final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
final AddressSettings settings = AddressSettingAdd.createSettings(context, model);
final HierarchicalRepository<AddressSettings> repository = server.getAddressSettingsRepository();
final String match = address.getLastElement().getValue();
final AddressSettings existingSettings = repository.getMatch(match);
repository.addMatch(match, settings);
if (existingSettings != null) {
handbackHolder.setHandback(new RevertHandback() {
@Override
public void doRevertUpdateToRuntime() {
// Restore the old settings
repository.addMatch(address.getLastElement().getValue(), existingSettings);
}
});
}
}
return false;
}
use of org.apache.activemq.artemis.core.server.ActiveMQServer in project wildfly by wildfly.
the class DivertRemove method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final String name = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
final ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
final ServiceController<?> service = registry.getService(serviceName);
if (service != null && service.getState() == ServiceController.State.UP) {
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
try {
server.getActiveMQServerControl().destroyDivert(name);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
// TODO should this be an OFE instead?
throw new RuntimeException(e);
}
}
}
use of org.apache.activemq.artemis.core.server.ActiveMQServer in project wildfly by wildfly.
the class LegacyConnectionFactoryService method start.
@Override
public void start(StartContext context) throws StartException {
ActiveMQServer activeMQServer = injectedActiveMQServer.getValue();
DiscoveryGroupConfiguration discoveryGroupConfiguration = null;
if (discoveryGroupName != null) {
if (activeMQServer.getConfiguration().getDiscoveryGroupConfigurations().keySet().contains(discoveryGroupName)) {
discoveryGroupConfiguration = translateDiscoveryGroupConfiguration(activeMQServer.getConfiguration().getDiscoveryGroupConfigurations().get(discoveryGroupName));
} else {
throw MessagingLogger.ROOT_LOGGER.discoveryGroupIsNotDefined(discoveryGroupName);
}
}
TransportConfiguration[] transportConfigurations = translateTransportGroupConfigurations(activeMQServer.getConfiguration().getConnectorConfigurations(), connectors);
JMSFactoryType factoryType = JMSFactoryType.valueOf(uncompletedConnectionFactory.getFactoryType());
if (uncompletedConnectionFactory.isHA()) {
if (discoveryGroupConfiguration != null) {
connectionFactory = HornetQJMSClient.createConnectionFactoryWithHA(discoveryGroupConfiguration, factoryType);
} else {
connectionFactory = HornetQJMSClient.createConnectionFactoryWithHA(factoryType, transportConfigurations);
}
} else {
if (discoveryGroupConfiguration != null) {
connectionFactory = HornetQJMSClient.createConnectionFactoryWithoutHA(discoveryGroupConfiguration, factoryType);
} else {
connectionFactory = HornetQJMSClient.createConnectionFactoryWithoutHA(factoryType, transportConfigurations);
}
}
connectionFactory.setAutoGroup(uncompletedConnectionFactory.isAutoGroup());
connectionFactory.setBlockOnAcknowledge(uncompletedConnectionFactory.isBlockOnAcknowledge());
connectionFactory.setBlockOnDurableSend(uncompletedConnectionFactory.isBlockOnDurableSend());
connectionFactory.setBlockOnNonDurableSend(uncompletedConnectionFactory.isBlockOnNonDurableSend());
connectionFactory.setCacheLargeMessagesClient(uncompletedConnectionFactory.isCacheLargeMessagesClient());
connectionFactory.setCallFailoverTimeout(uncompletedConnectionFactory.getCallFailoverTimeout());
connectionFactory.setCallTimeout(uncompletedConnectionFactory.getCallTimeout());
connectionFactory.setClientFailureCheckPeriod(uncompletedConnectionFactory.getClientFailureCheckPeriod());
connectionFactory.setClientID(uncompletedConnectionFactory.getClientID());
connectionFactory.setCompressLargeMessage(uncompletedConnectionFactory.isCompressLargeMessage());
connectionFactory.setConfirmationWindowSize(uncompletedConnectionFactory.getConfirmationWindowSize());
connectionFactory.setConnectionLoadBalancingPolicyClassName(uncompletedConnectionFactory.getConnectionLoadBalancingPolicyClassName());
connectionFactory.setConnectionTTL(uncompletedConnectionFactory.getConnectionTTL());
connectionFactory.setConsumerMaxRate(uncompletedConnectionFactory.getConsumerMaxRate());
connectionFactory.setConsumerWindowSize(uncompletedConnectionFactory.getConsumerWindowSize());
connectionFactory.setConfirmationWindowSize(uncompletedConnectionFactory.getConfirmationWindowSize());
connectionFactory.setDupsOKBatchSize(uncompletedConnectionFactory.getDupsOKBatchSize());
connectionFactory.setFailoverOnInitialConnection(uncompletedConnectionFactory.isFailoverOnInitialConnection());
connectionFactory.setGroupID(uncompletedConnectionFactory.getGroupID());
connectionFactory.setInitialConnectAttempts(uncompletedConnectionFactory.getInitialConnectAttempts());
connectionFactory.setInitialMessagePacketSize(uncompletedConnectionFactory.getInitialMessagePacketSize());
connectionFactory.setMaxRetryInterval(uncompletedConnectionFactory.getMaxRetryInterval());
connectionFactory.setMinLargeMessageSize(uncompletedConnectionFactory.getMinLargeMessageSize());
connectionFactory.setPreAcknowledge(uncompletedConnectionFactory.isPreAcknowledge());
connectionFactory.setProducerMaxRate(uncompletedConnectionFactory.getProducerMaxRate());
connectionFactory.setProducerWindowSize(uncompletedConnectionFactory.getProducerWindowSize());
connectionFactory.setReconnectAttempts(uncompletedConnectionFactory.getReconnectAttempts());
connectionFactory.setRetryInterval(uncompletedConnectionFactory.getRetryInterval());
connectionFactory.setRetryIntervalMultiplier(uncompletedConnectionFactory.getRetryIntervalMultiplier());
connectionFactory.setScheduledThreadPoolMaxSize(uncompletedConnectionFactory.getScheduledThreadPoolMaxSize());
connectionFactory.setThreadPoolMaxSize(uncompletedConnectionFactory.getThreadPoolMaxSize());
connectionFactory.setTransactionBatchSize(uncompletedConnectionFactory.getTransactionBatchSize());
connectionFactory.setUseGlobalPools(uncompletedConnectionFactory.isUseGlobalPools());
}
use of org.apache.activemq.artemis.core.server.ActiveMQServer in project wildfly by wildfly.
the class AbstractActiveMQComponentControlHandler method getActiveMQComponentControl.
/**
* Gets the runtime ActiveMQ control object that can help service this request.
*
* @param context the operation context
* @param operation the operation
* @param forWrite {@code true} if this operation will modify the runtime; {@code false} if not.
* @return the control object
* @throws OperationFailedException
*/
protected final T getActiveMQComponentControl(final OperationContext context, final ModelNode operation, final boolean forWrite) throws OperationFailedException {
final ServiceName artemisServiceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
ServiceController<?> artemisService = context.getServiceRegistry(forWrite).getService(artemisServiceName);
ActiveMQServer server = ActiveMQServer.class.cast(artemisService.getValue());
PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
T control = getActiveMQComponentControl(server, address);
if (control == null) {
throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(address);
}
return control;
}
use of org.apache.activemq.artemis.core.server.ActiveMQServer in project wildfly by wildfly.
the class ConnectionFactoryReadAttributeHandler method executeRuntimeStep.
@Override
public void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
if (ignoreOperationIfServerNotActive(context, operation)) {
return;
}
validator.validate(operation);
final String attributeName = operation.require(ModelDescriptionConstants.NAME).asString();
String factoryName = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
ServiceController<?> service = context.getServiceRegistry(false).getService(serviceName);
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
ConnectionFactoryControl control = ConnectionFactoryControl.class.cast(server.getManagementService().getResource(ResourceNames.JMS_CONNECTION_FACTORY + factoryName));
if (control == null) {
PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(address);
}
if (HA.getName().equals(attributeName)) {
context.getResult().set(control.isHA());
} else if (ConnectionFactoryAttributes.Regular.FACTORY_TYPE.getName().equals(attributeName)) {
context.getResult().set(control.getFactoryType());
} else if (ConnectionFactoryAttributes.Regular.INITIAL_MESSAGE_PACKET_SIZE.getName().equals(attributeName)) {
context.getResult().set(control.getInitialMessagePacketSize());
} else {
// Bug
throw MessagingLogger.ROOT_LOGGER.unsupportedAttribute(attributeName);
}
}
Aggregations