Search in sources :

Example 6 with AddressSettings

use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.

the class ActiveMQServerControlImpl method getAddressSettingsAsJSON.

@Override
public String getAddressSettingsAsJSON(final String address) throws Exception {
    checkStarted();
    AddressSettings addressSettings = server.getAddressSettingsRepository().getMatch(address);
    String policy = addressSettings.getAddressFullMessagePolicy() == AddressFullMessagePolicy.PAGE ? "PAGE" : addressSettings.getAddressFullMessagePolicy() == AddressFullMessagePolicy.BLOCK ? "BLOCK" : addressSettings.getAddressFullMessagePolicy() == AddressFullMessagePolicy.DROP ? "DROP" : "FAIL";
    String consumerPolicy = addressSettings.getSlowConsumerPolicy() == SlowConsumerPolicy.NOTIFY ? "NOTIFY" : "KILL";
    JsonObjectBuilder settings = JsonLoader.createObjectBuilder();
    if (addressSettings.getDeadLetterAddress() != null) {
        settings.add("DLA", addressSettings.getDeadLetterAddress().toString());
    }
    if (addressSettings.getExpiryAddress() != null) {
        settings.add("expiryAddress", addressSettings.getExpiryAddress().toString());
    }
    return settings.add("expiryDelay", addressSettings.getExpiryDelay()).add("maxDeliveryAttempts", addressSettings.getMaxDeliveryAttempts()).add("pageCacheMaxSize", addressSettings.getPageCacheMaxSize()).add("maxSizeBytes", addressSettings.getMaxSizeBytes()).add("pageSizeBytes", addressSettings.getPageSizeBytes()).add("redeliveryDelay", addressSettings.getRedeliveryDelay()).add("redeliveryMultiplier", addressSettings.getRedeliveryMultiplier()).add("maxRedeliveryDelay", addressSettings.getMaxRedeliveryDelay()).add("redistributionDelay", addressSettings.getRedistributionDelay()).add("lastValueQueue", addressSettings.isDefaultLastValueQueue()).add("sendToDLAOnNoRoute", addressSettings.isSendToDLAOnNoRoute()).add("addressFullMessagePolicy", policy).add("slowConsumerThreshold", addressSettings.getSlowConsumerThreshold()).add("slowConsumerCheckPeriod", addressSettings.getSlowConsumerCheckPeriod()).add("slowConsumerPolicy", consumerPolicy).add("autoCreateJmsQueues", addressSettings.isAutoCreateJmsQueues()).add("autoCreateJmsTopics", addressSettings.isAutoCreateJmsTopics()).add("autoDeleteJmsQueues", addressSettings.isAutoDeleteJmsQueues()).add("autoDeleteJmsTopics", addressSettings.isAutoDeleteJmsQueues()).add("autoCreateQueues", addressSettings.isAutoCreateQueues()).add("autoDeleteQueues", addressSettings.isAutoDeleteQueues()).add("autoCreateAddress", addressSettings.isAutoCreateAddresses()).add("autoDeleteAddress", addressSettings.isAutoDeleteAddresses()).build().toString();
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) JsonObjectBuilder(javax.json.JsonObjectBuilder)

Example 7 with AddressSettings

use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.

the class QueueControlImpl method getDeadLetterAddress.

@Override
public String getDeadLetterAddress() {
    checkStarted();
    clearIO();
    try {
        AddressSettings addressSettings = addressSettingsRepository.getMatch(address);
        if (addressSettings != null && addressSettings.getDeadLetterAddress() != null) {
            return addressSettings.getDeadLetterAddress().toString();
        }
        return null;
    } finally {
        blockOnIO();
    }
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings)

Example 8 with AddressSettings

use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.

the class QueueControlImpl method getExpiryAddress.

@Override
public String getExpiryAddress() {
    checkStarted();
    clearIO();
    try {
        AddressSettings addressSettings = addressSettingsRepository.getMatch(address);
        if (addressSettings != null && addressSettings.getExpiryAddress() != null) {
            return addressSettings.getExpiryAddress().toString();
        } else {
            return null;
        }
    } finally {
        blockOnIO();
    }
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings)

Example 9 with AddressSettings

use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.

the class PagingStoreFactoryDatabase method reloadStores.

@Override
public synchronized List<PagingStore> reloadStores(final HierarchicalRepository<AddressSettings> addressSettingsRepository) throws Exception {
    // We assume the directory list < Integer.MAX_VALUE (this is only a list of addresses).
    JDBCSequentialFile directoryList = (JDBCSequentialFile) pagingFactoryFileFactory.createSequentialFile(DIRECTORY_NAME);
    directoryList.open();
    int size = ((Long) directoryList.size()).intValue();
    ActiveMQBuffer buffer = readActiveMQBuffer(directoryList, size);
    ArrayList<PagingStore> storesReturn = new ArrayList<>();
    while (buffer.readableBytes() > 0) {
        SimpleString table = buffer.readSimpleString();
        JDBCSequentialFileFactory factory = (JDBCSequentialFileFactory) newFileFactory(table.toString(), false);
        factory.start();
        JDBCSequentialFile addressFile = (JDBCSequentialFile) factory.createSequentialFile(ADDRESS_FILE);
        addressFile.open();
        size = ((Long) addressFile.size()).intValue();
        if (size == 0) {
            continue;
        }
        ActiveMQBuffer addrBuffer = readActiveMQBuffer(addressFile, size);
        SimpleString address = addrBuffer.readSimpleString();
        AddressSettings settings = addressSettingsRepository.getMatch(address.toString());
        PagingStore store = new PagingStoreImpl(address, scheduledExecutor, syncTimeout, pagingManager, storageManager, factory, this, address, settings, executorFactory.getExecutor(), syncNonTransactional);
        storesReturn.add(store);
    }
    directoryList.close();
    return storesReturn;
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) ArrayList(java.util.ArrayList) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) JDBCSequentialFile(org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFile) PagingStore(org.apache.activemq.artemis.core.paging.PagingStore) JDBCSequentialFileFactory(org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFileFactory) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer)

Example 10 with AddressSettings

use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.

the class OpenWireConnection method addDestination.

public void addDestination(DestinationInfo info) throws Exception {
    boolean created = false;
    ActiveMQDestination dest = info.getDestination();
    if (!protocolManager.isSupportAdvisory() && AdvisorySupport.isAdvisoryTopic(dest)) {
        return;
    }
    SimpleString qName = SimpleString.toSimpleString(dest.getPhysicalName());
    if (server.locateQueue(qName) == null) {
        AddressSettings addressSettings = server.getAddressSettingsRepository().getMatch(dest.getPhysicalName());
        AddressInfo addressInfo = new AddressInfo(qName, dest.isTopic() ? RoutingType.MULTICAST : RoutingType.ANYCAST);
        if (AdvisorySupport.isAdvisoryTopic(dest) && protocolManager.isSuppressInternalManagementObjects()) {
            addressInfo.setInternal(true);
        }
        if (dest.isQueue() && (addressSettings.isAutoCreateQueues() || dest.isTemporary())) {
            try {
                internalSession.createQueue(addressInfo, qName, null, dest.isTemporary(), !dest.isTemporary(), !dest.isTemporary());
                created = true;
            } catch (ActiveMQQueueExistsException exists) {
            // The queue may have been created by another thread in the mean time.  Catch and do nothing.
            }
        } else if (dest.isTopic() && (addressSettings.isAutoCreateAddresses() || dest.isTemporary())) {
            try {
                internalSession.createAddress(addressInfo, !dest.isTemporary());
                created = true;
            } catch (ActiveMQAddressExistsException exists) {
            // The address may have been created by another thread in the mean time.  Catch and do nothing.
            }
        }
    }
    if (dest.isTemporary()) {
        // Openwire needs to store the DestinationInfo in order to send
        // Advisory messages to clients
        this.state.addTempDestination(info);
    }
    if (created && !AdvisorySupport.isAdvisoryTopic(dest)) {
        AMQConnectionContext context = getContext();
        DestinationInfo advInfo = new DestinationInfo(context.getConnectionId(), DestinationInfo.ADD_OPERATION_TYPE, dest);
        ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(dest);
        protocolManager.fireAdvisory(context, topic, advInfo);
    }
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) DestinationInfo(org.apache.activemq.command.DestinationInfo) ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) ActiveMQAddressExistsException(org.apache.activemq.artemis.api.core.ActiveMQAddressExistsException) AMQConnectionContext(org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext) ActiveMQQueueExistsException(org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo)

Aggregations

AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)273 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)162 Test (org.junit.Test)161 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)103 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)103 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)88 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)81 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)65 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)54 Configuration (org.apache.activemq.artemis.core.config.Configuration)52 HashMap (java.util.HashMap)31 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)30 Queue (org.apache.activemq.artemis.core.server.Queue)24 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)21 Before (org.junit.Before)19 Session (javax.jms.Session)18 Message (org.apache.activemq.artemis.api.core.Message)18 ArrayList (java.util.ArrayList)15 PagingStore (org.apache.activemq.artemis.core.paging.PagingStore)15 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)14