Search in sources :

Example 1 with ManagementService

use of org.apache.activemq.artemis.core.server.management.ManagementService in project activemq-artemis by apache.

the class ActiveMQServerImpl method bindingQuery.

@Override
public BindingQueryResult bindingQuery(SimpleString address) throws Exception {
    if (address == null) {
        throw ActiveMQMessageBundle.BUNDLE.addressIsNull();
    }
    CompositeAddress addressKey = new CompositeAddress(address.toString());
    String realAddress = addressKey.isFqqn() ? addressKey.getAddress() : addressKey.getQueueName();
    AddressSettings addressSettings = getAddressSettingsRepository().getMatch(realAddress);
    boolean autoCreateQeueus = addressSettings.isAutoCreateQueues();
    boolean autoCreateAddresses = addressSettings.isAutoCreateAddresses();
    boolean defaultPurgeOnNoConsumers = addressSettings.isDefaultPurgeOnNoConsumers();
    int defaultMaxConsumers = addressSettings.getDefaultMaxConsumers();
    boolean defaultExclusive = addressSettings.isDefaultExclusiveQueue();
    boolean defaultLastValie = addressSettings.isDefaultLastValueQueue();
    List<SimpleString> names = new ArrayList<>();
    // make an exception for the management address (see HORNETQ-29)
    ManagementService managementService = getManagementService();
    SimpleString bindAddress = new SimpleString(realAddress);
    if (managementService != null) {
        if (bindAddress.equals(managementService.getManagementAddress())) {
            return new BindingQueryResult(true, null, names, autoCreateQeueus, autoCreateAddresses, defaultPurgeOnNoConsumers, defaultMaxConsumers, defaultExclusive, defaultLastValie);
        }
    }
    Bindings bindings = getPostOffice().getMatchingBindings(bindAddress);
    for (Binding binding : bindings.getBindings()) {
        if (binding.getType() == BindingType.LOCAL_QUEUE || binding.getType() == BindingType.REMOTE_QUEUE) {
            if (addressKey.isFqqn()) {
                names.add(new SimpleString(addressKey.getAddress()).concat(CompositeAddress.SEPARATOR).concat(binding.getUniqueName()));
            } else {
                names.add(binding.getUniqueName());
            }
        }
    }
    AddressInfo info = getAddressInfo(bindAddress);
    return new BindingQueryResult(info != null, info, names, autoCreateQeueus, autoCreateAddresses, defaultPurgeOnNoConsumers, defaultMaxConsumers, defaultExclusive, defaultLastValie);
}
Also used : BindingQueryResult(org.apache.activemq.artemis.core.server.BindingQueryResult) Binding(org.apache.activemq.artemis.core.postoffice.Binding) DivertBinding(org.apache.activemq.artemis.core.postoffice.impl.DivertBinding) LocalQueueBinding(org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding) QueueBinding(org.apache.activemq.artemis.core.postoffice.QueueBinding) AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) ArrayList(java.util.ArrayList) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Bindings(org.apache.activemq.artemis.core.postoffice.Bindings) ReplicationEndpoint(org.apache.activemq.artemis.core.replication.ReplicationEndpoint) CompositeAddress(org.apache.activemq.artemis.utils.CompositeAddress) ManagementService(org.apache.activemq.artemis.core.server.management.ManagementService)

Example 2 with ManagementService

use of org.apache.activemq.artemis.core.server.management.ManagementService in project activemq-artemis by apache.

the class FailoverBackupLeakTest method getConnectionCount.

private int getConnectionCount(EmbeddedJMS server) throws Exception {
    ManagementService managementService = server.getActiveMQServer().getManagementService();
    ActiveMQServerControl jmsControl = (ActiveMQServerControl) managementService.getResource(ResourceNames.BROKER);
    String[] ids = jmsControl.listConnectionIDs();
    if (ids != null) {
        return ids.length;
    }
    return 0;
}
Also used : ManagementService(org.apache.activemq.artemis.core.server.management.ManagementService) ActiveMQServerControl(org.apache.activemq.artemis.api.core.management.ActiveMQServerControl)

Example 3 with ManagementService

use of org.apache.activemq.artemis.core.server.management.ManagementService in project activemq-artemis by apache.

the class BridgeTestBase method checkEmpty.

public boolean checkEmpty(final Queue queue, final int index) throws Exception {
    ManagementService managementService = server0.getManagementService();
    if (index == 1) {
        managementService = server1.getManagementService();
    }
    QueueControl queueControl = (QueueControl) managementService.getResource(ResourceNames.QUEUE + queue.getQueueName());
    // server may be closed
    if (queueControl != null) {
        queueControl.flushExecutor();
        Long messageCount = queueControl.getMessageCount();
        if (messageCount > 0) {
            queueControl.removeMessages(null);
        }
    }
    return true;
}
Also used : ManagementService(org.apache.activemq.artemis.core.server.management.ManagementService) QueueControl(org.apache.activemq.artemis.api.core.management.QueueControl)

Example 4 with ManagementService

use of org.apache.activemq.artemis.core.server.management.ManagementService in project activemq-artemis by apache.

the class BridgeTestBase method checkNoSubscriptions.

protected void checkNoSubscriptions(final Topic topic, final int index) throws Exception {
    ManagementService managementService = server0.getManagementService();
    if (index == 1) {
        managementService = server1.getManagementService();
    }
    AddressControl topicControl = (AddressControl) managementService.getResource(ResourceNames.ADDRESS + topic.getTopicName());
    if (topicControl != null) {
        Assert.assertEquals(0, topicControl.getQueueNames().length);
    }
}
Also used : AddressControl(org.apache.activemq.artemis.api.core.management.AddressControl) ManagementService(org.apache.activemq.artemis.core.server.management.ManagementService)

Example 5 with ManagementService

use of org.apache.activemq.artemis.core.server.management.ManagementService in project wildfly by wildfly.

the class ActiveMQServerResource method getCoreAddressNames.

private Set<String> getCoreAddressNames() {
    final ManagementService managementService = getManagementService();
    if (managementService == null) {
        return Collections.emptySet();
    } else {
        Set<String> result = new HashSet<String>();
        for (Object obj : managementService.getResources(AddressControl.class)) {
            AddressControl ac = AddressControl.class.cast(obj);
            result.add(ac.getAddress());
        }
        return result;
    }
}
Also used : AddressControl(org.apache.activemq.artemis.api.core.management.AddressControl) ManagementService(org.apache.activemq.artemis.core.server.management.ManagementService) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

ManagementService (org.apache.activemq.artemis.core.server.management.ManagementService)10 AddressControl (org.apache.activemq.artemis.api.core.management.AddressControl)4 QueueControl (org.apache.activemq.artemis.api.core.management.QueueControl)4 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)2 OperationFailedException (org.jboss.as.controller.OperationFailedException)2 PathAddress (org.jboss.as.controller.PathAddress)2 ServiceName (org.jboss.msc.service.ServiceName)2 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)1 ActiveMQNotConnectedException (org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException)1 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)1 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)1 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)1 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)1 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)1 ActiveMQServerControl (org.apache.activemq.artemis.api.core.management.ActiveMQServerControl)1 BridgeConfiguration (org.apache.activemq.artemis.core.config.BridgeConfiguration)1