use of org.apache.activemq.artemis.core.server.ActiveMQServer in project wildfly by wildfly.
the class HTTPUpgradeService method switchToMessagingProtocol.
private static HttpUpgradeListener switchToMessagingProtocol(final ActiveMQServer activemqServer, final String acceptorName, final String protocolName) {
return new HttpUpgradeListener() {
@Override
public void handleUpgrade(StreamConnection streamConnection, HttpServerExchange exchange) {
ChannelListener<StreamConnection> listener = new ChannelListener<StreamConnection>() {
@Override
public void handleEvent(StreamConnection connection) {
MessagingLogger.ROOT_LOGGER.debugf("Switching to %s protocol for %s http-acceptor", protocolName, acceptorName);
ActiveMQServer server = selectServer(exchange, activemqServer);
RemotingService remotingService = server.getRemotingService();
if (!server.isActive() || !remotingService.isStarted()) {
// ActiveMQ does not accept connection
IoUtils.safeClose(connection);
return;
}
NettyAcceptor acceptor = (NettyAcceptor) remotingService.getAcceptor(acceptorName);
SocketChannel channel = new WrappingXnioSocketChannel(connection);
try {
acceptor.transfer(channel);
connection.getSourceChannel().resumeReads();
} catch (IllegalStateException e) {
IoUtils.safeClose(connection);
}
}
};
ChannelListeners.invokeChannelListener(streamConnection, listener);
}
};
}
use of org.apache.activemq.artemis.core.server.ActiveMQServer in project wildfly by wildfly.
the class AddressControlHandler method getAddressControl.
private AddressControl getAddressControl(final OperationContext context, final ModelNode operation) {
final String addressName = PathAddress.pathAddress(operation.require(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());
return AddressControl.class.cast(server.getManagementService().getResource(ResourceNames.CORE_ADDRESS + addressName));
}
use of org.apache.activemq.artemis.core.server.ActiveMQServer in project wildfly by wildfly.
the class AddressSettingAdd method performRuntime.
@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
final ActiveMQServer server = getActiveMQServer(context, operation);
if (server != null) {
final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
final AddressSettings settings = createSettings(context, model);
server.getAddressSettingsRepository().addMatch(address.getLastElement().getValue(), settings);
}
}
use of org.apache.activemq.artemis.core.server.ActiveMQServer in project wildfly by wildfly.
the class AddressSettingsResolveHandler method executeRuntimeStep.
@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
if (ignoreOperationIfServerNotActive(context, operation)) {
return;
}
final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(address);
ServiceController<?> service = context.getServiceRegistry(false).getService(serviceName);
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
final String activeMQAddress = ACTIVEMQ_ADDRESS.resolveModelAttribute(context, operation).asString();
AddressSettings settings = server.getAddressSettingsRepository().getMatch(activeMQAddress);
ModelNode result = context.getResult();
result.get(ADDRESS_FULL_MESSAGE_POLICY.getName()).set(settings.getAddressFullMessagePolicy().toString());
ModelNode deadLetterAddress = result.get(DEAD_LETTER_ADDRESS.getName());
if (settings.getDeadLetterAddress() != null) {
deadLetterAddress.set(settings.getDeadLetterAddress().toString());
}
ModelNode expiryAddress = result.get(EXPIRY_ADDRESS.getName());
if (settings.getExpiryAddress() != null) {
expiryAddress.set(settings.getExpiryAddress().toString());
}
result.get(EXPIRY_DELAY.getName()).set(settings.getExpiryDelay());
result.get(LAST_VALUE_QUEUE.getName()).set(settings.isLastValueQueue());
result.get(MAX_DELIVERY_ATTEMPTS.getName()).set(settings.getMaxDeliveryAttempts());
result.get(MAX_REDELIVERY_DELAY.getName()).set(settings.getMaxRedeliveryDelay());
result.get(MAX_SIZE_BYTES.getName()).set(settings.getMaxSizeBytes());
result.get(MESSAGE_COUNTER_HISTORY_DAY_LIMIT.getName()).set(settings.getMessageCounterHistoryDayLimit());
result.get(PAGE_MAX_CACHE_SIZE.getName()).set(settings.getPageCacheMaxSize());
result.get(PAGE_SIZE_BYTES.getName()).set(settings.getPageSizeBytes());
result.get(REDELIVERY_DELAY.getName()).set(settings.getRedeliveryDelay());
result.get(REDELIVERY_MULTIPLIER.getName()).set(settings.getRedeliveryMultiplier());
result.get(REDISTRIBUTION_DELAY.getName()).set(settings.getRedistributionDelay());
result.get(SEND_TO_DLA_ON_NO_ROUTE.getName()).set(settings.isSendToDLAOnNoRoute());
result.get(SLOW_CONSUMER_CHECK_PERIOD.getName()).set(settings.getSlowConsumerCheckPeriod());
result.get(SLOW_CONSUMER_POLICY.getName()).set(settings.getSlowConsumerPolicy().toString());
result.get(SLOW_CONSUMER_THRESHOLD.getName()).set(settings.getSlowConsumerThreshold());
result.get(AUTO_CREATE_JMS_QUEUES.getName()).set(settings.isAutoCreateJmsQueues());
result.get(AUTO_DELETE_JMS_QUEUES.getName()).set(settings.isAutoDeleteJmsQueues());
}
use of org.apache.activemq.artemis.core.server.ActiveMQServer in project wildfly by wildfly.
the class QueueReadAttributeHandler 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();
PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
String queueName = address.getLastElement().getValue();
if (forwardToRuntimeQueue(context, operation, RUNTIME_INSTANCE)) {
return;
}
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(address);
ServiceController<?> service = context.getServiceRegistry(false).getService(serviceName);
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
QueueControl control = QueueControl.class.cast(server.getManagementService().getResource(ResourceNames.CORE_QUEUE + queueName));
if (control == null) {
throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(address);
}
if (MESSAGE_COUNT.getName().equals(attributeName)) {
context.getResult().set(control.getMessageCount());
} else if (SCHEDULED_COUNT.getName().equals(attributeName)) {
context.getResult().set(control.getScheduledCount());
} else if (CONSUMER_COUNT.getName().equals(attributeName)) {
context.getResult().set(control.getConsumerCount());
} else if (DELIVERING_COUNT.getName().equals(attributeName)) {
context.getResult().set(control.getDeliveringCount());
} else if (MESSAGES_ADDED.getName().equals(attributeName)) {
context.getResult().set(control.getMessagesAdded());
} else if (ID.getName().equals(attributeName)) {
context.getResult().set(control.getID());
} else if (PAUSED.getName().equals(attributeName)) {
try {
context.getResult().set(control.isPaused());
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
} else if (TEMPORARY.getName().equals(attributeName)) {
context.getResult().set(control.isTemporary());
} else if (EXPIRY_ADDRESS.getName().equals(attributeName)) {
if (control.getExpiryAddress() != null) {
context.getResult().set(control.getExpiryAddress());
}
} else if (DEAD_LETTER_ADDRESS.getName().equals(attributeName)) {
if (control.getDeadLetterAddress() != null) {
context.getResult().set(control.getDeadLetterAddress());
}
} else if (readStorageAttributes && getStorageAttributeNames().contains(attributeName)) {
if (ADDRESS.getName().equals(attributeName)) {
context.getResult().set(control.getAddress());
} else if (DURABLE.getName().equals(attributeName)) {
context.getResult().set(control.isDurable());
} else if (FILTER.getName().equals(attributeName)) {
ModelNode result = context.getResult();
String filter = control.getFilter();
if (filter != null) {
result.set(filter);
}
}
} else {
throw MessagingLogger.ROOT_LOGGER.unsupportedAttribute(attributeName);
}
}
Aggregations