protected void performRuntime( OperationContext context, ModelNode operation, ModelNode model, ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); final String name = address.getLastElement().getValue(); final ServiceTarget serviceTarget = context.getServiceTarget(); final ServiceName hqServiceName = MessagingServices.getHornetQServiceName( PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR))); final ModelNode selectorNode = SELECTOR.resolveModelAttribute(context, model); final boolean durable = DURABLE.resolveModelAttribute(context, model).asBoolean(); final String selector = selectorNode.isDefined() ? selectorNode.asString() : null; final ModelNode entries = CommonAttributes.DESTINATION_ENTRIES.resolveModelAttribute(context, model); final String[] jndiBindings = JMSServices.getJndiBindings(entries); installServices( verificationHandler, newControllers, name, serviceTarget, hqServiceName, selector, durable, jndiBindings); }
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); final String name = address.getLastElement().getValue(); final ServiceTarget serviceTarget = context.getServiceTarget(); final ServiceName serviceName = MessagingServices.getActiveMQServiceName( PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR))); final ModelNode selectorNode = SELECTOR.resolveModelAttribute(context, model); final boolean durable = DURABLE.resolveModelAttribute(context, model).asBoolean(); final String selector = selectorNode.isDefined() ? selectorNode.asString() : null; // Do not pass the JNDI bindings to ActiveMQ but install them directly instead so that the // dependencies from the BinderServices to the JMSQueueService are not broken Service<Queue> queueService = JMSQueueService.installService( name, serviceTarget, serviceName, selector, durable, new String[0]); final ModelNode entries = CommonAttributes.DESTINATION_ENTRIES.resolveModelAttribute(context, model); final ServiceName jmsQueueServiceName = JMSServices.getJmsQueueBaseServiceName(serviceName).append(name); final String[] jndiBindings = JMSServices.getJndiBindings(entries); for (String jndiBinding : jndiBindings) { // install a binder service which depends on the JMS queue service BinderServiceUtil.installBinderService( serviceTarget, jndiBinding, queueService, jmsQueueServiceName); } }
private static void writeQueues(final XMLExtendedStreamWriter writer, final ModelNode node) throws XMLStreamException { if (!node.isDefined()) { return; } List<Property> properties = node.asPropertyList(); if (!properties.isEmpty()) { writer.writeStartElement(Element.CORE_QUEUES.getLocalName()); for (Property queueProp : properties) { writer.writeStartElement(Element.QUEUE.getLocalName()); writer.writeAttribute(Attribute.NAME.getLocalName(), queueProp.getName()); final ModelNode queue = queueProp.getValue(); QueueDefinition.ADDRESS.marshallAsElement(queue, writer); writeFilter(writer, queue); DURABLE.marshallAsElement(queue, writer); writer.writeEndElement(); } writer.writeEndElement(); writeNewLine(writer); } }
@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); } }