use of org.apache.activemq.artemis.api.jms.management.JMSServerControl in project wildfly by wildfly.
the class JMSTopicRemove method performRuntime.
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
final String name = context.getCurrentAddress().getLastElement().getValue();
ServiceController<?> service = context.getServiceRegistry(false).getService(serviceName);
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
JMSServerControl control = JMSServerControl.class.cast(server.getManagementService().getResource(ResourceNames.JMS_SERVER));
if (control != null) {
try {
control.destroyTopic(name, true);
} catch (Exception e) {
throw new OperationFailedException(e);
}
}
context.removeService(JMSServices.getJmsTopicBaseServiceName(serviceName).append(name));
for (String entry : CommonAttributes.DESTINATION_ENTRIES.unwrap(context, model)) {
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(entry);
ServiceName binderServiceName = bindInfo.getBinderServiceName();
context.removeService(binderServiceName);
}
for (String legacyEntry : CommonAttributes.LEGACY_ENTRIES.unwrap(context, model)) {
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(legacyEntry);
ServiceName binderServiceName = bindInfo.getBinderServiceName();
context.removeService(binderServiceName);
}
}
use of org.apache.activemq.artemis.api.jms.management.JMSServerControl in project wildfly by wildfly.
the class JMSQueueRemove method performRuntime.
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
final String name = address.getLastElement().getValue();
ServiceController<?> service = context.getServiceRegistry(false).getService(serviceName);
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
JMSServerControl control = JMSServerControl.class.cast(server.getManagementService().getResource(ResourceNames.JMS_SERVER));
if (control != null) {
try {
control.destroyQueue(name, true);
} catch (Exception e) {
throw new OperationFailedException(e);
}
}
context.removeService(JMSServices.getJmsQueueBaseServiceName(serviceName).append(name));
for (String entry : CommonAttributes.DESTINATION_ENTRIES.unwrap(context, model)) {
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(entry);
ServiceName binderServiceName = bindInfo.getBinderServiceName();
context.removeService(binderServiceName);
}
for (String legacyEntry : CommonAttributes.LEGACY_ENTRIES.unwrap(context, model)) {
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(legacyEntry);
ServiceName binderServiceName = bindInfo.getBinderServiceName();
context.removeService(binderServiceName);
}
}
use of org.apache.activemq.artemis.api.jms.management.JMSServerControl in project wildfly by wildfly.
the class JMSServerControlHandler method executeRuntimeStep.
@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
if (rollbackOperationIfServerNotActive(context, operation)) {
return;
}
final String operationName = operation.require(OP).asString();
final JMSServerControl serverControl = getServerControl(context, operation);
if (serverControl == null) {
PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(address);
}
try {
if (LIST_CONNECTIONS_AS_JSON.equals(operationName)) {
String json = serverControl.listConnectionsAsJSON();
context.getResult().set(json);
} else if (LIST_CONSUMERS_AS_JSON.equals(operationName)) {
String connectionID = CONNECTION_ID.resolveModelAttribute(context, operation).asString();
String json = serverControl.listConsumersAsJSON(connectionID);
context.getResult().set(json);
} else if (LIST_ALL_CONSUMERS_AS_JSON.equals(operationName)) {
String json = serverControl.listAllConsumersAsJSON();
context.getResult().set(json);
} else if (LIST_TARGET_DESTINATIONS.equals(operationName)) {
String sessionID = SESSION_ID.resolveModelAttribute(context, operation).asString();
String[] list = serverControl.listTargetDestinations(sessionID);
reportListOfStrings(context, list);
} else if (GET_LAST_SENT_MESSAGE_ID.equals(operationName)) {
String sessionID = SESSION_ID.resolveModelAttribute(context, operation).asString();
String addressName = ADDRESS_NAME.resolveModelAttribute(context, operation).asString();
String msgId = serverControl.getLastSentMessageID(sessionID, addressName);
context.getResult().set(msgId);
} else if (GET_SESSION_CREATION_TIME.equals(operationName)) {
String sessionID = SESSION_ID.resolveModelAttribute(context, operation).asString();
String time = serverControl.getSessionCreationTime(sessionID);
context.getResult().set(time);
} else if (LIST_SESSIONS_AS_JSON.equals(operationName)) {
String connectionID = CONNECTION_ID.resolveModelAttribute(context, operation).asString();
String json = serverControl.listSessionsAsJSON(connectionID);
context.getResult().set(json);
} else if (LIST_PREPARED_TRANSACTION_JMS_DETAILS_AS_JSON.equals(operationName)) {
String json = serverControl.listPreparedTransactionDetailsAsJSON();
context.getResult().set(json);
} else if (LIST_PREPARED_TRANSACTION_JMS_DETAILS_AS_HTML.equals(operationName)) {
String html = serverControl.listPreparedTransactionDetailsAsHTML();
context.getResult().set(html);
} else {
// Bug
throw MessagingLogger.ROOT_LOGGER.unsupportedOperation(operationName);
}
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
context.getFailureDescription().set(e.getLocalizedMessage());
}
}
Aggregations