Search in sources :

Example 6 with RoutingType

use of org.apache.activemq.artemis.api.core.RoutingType in project activemq-artemis by apache.

the class ActiveMQServerControlImpl method updateAddress.

@Override
public String updateAddress(String name, String routingTypes) throws Exception {
    checkStarted();
    clearIO();
    try {
        final EnumSet<RoutingType> routingTypeSet;
        if (routingTypes == null) {
            routingTypeSet = null;
        } else {
            routingTypeSet = EnumSet.noneOf(RoutingType.class);
            final String[] routingTypeNames = routingTypes.split(",");
            for (String routingTypeName : routingTypeNames) {
                routingTypeSet.add(RoutingType.valueOf(routingTypeName));
            }
        }
        if (!server.updateAddressInfo(SimpleString.toSimpleString(name), routingTypeSet)) {
            throw ActiveMQMessageBundle.BUNDLE.addressDoesNotExist(SimpleString.toSimpleString(name));
        }
        return AddressInfoTextFormatter.Long.format(server.getAddressInfo(SimpleString.toSimpleString(name)), new StringBuilder()).toString();
    } finally {
        blockOnIO();
    }
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) DivertConfigurationRoutingType(org.apache.activemq.artemis.core.server.DivertConfigurationRoutingType) RoutingType(org.apache.activemq.artemis.api.core.RoutingType)

Example 7 with RoutingType

use of org.apache.activemq.artemis.api.core.RoutingType in project activemq-artemis by apache.

the class ActiveMQServerControlImpl method createAddress.

@Override
public String createAddress(String name, String routingTypes) throws Exception {
    checkStarted();
    clearIO();
    try {
        EnumSet<RoutingType> set = EnumSet.noneOf(RoutingType.class);
        for (String routingType : ListUtil.toList(routingTypes)) {
            set.add(RoutingType.valueOf(routingType));
        }
        final AddressInfo addressInfo = new AddressInfo(new SimpleString(name), set);
        if (server.addAddressInfo(addressInfo)) {
            return AddressInfoTextFormatter.Long.format(addressInfo, new StringBuilder()).toString();
        } else {
            throw ActiveMQMessageBundle.BUNDLE.addressAlreadyExists(addressInfo.getName());
        }
    } finally {
        blockOnIO();
    }
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) DivertConfigurationRoutingType(org.apache.activemq.artemis.core.server.DivertConfigurationRoutingType) RoutingType(org.apache.activemq.artemis.api.core.RoutingType) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo)

Example 8 with RoutingType

use of org.apache.activemq.artemis.api.core.RoutingType in project activemq-artemis by apache.

the class AddressControlImpl method getRoutingTypes.

@Override
public String[] getRoutingTypes() {
    EnumSet<RoutingType> routingTypes = addressInfo.getRoutingTypes();
    String[] result = new String[routingTypes.size()];
    int i = 0;
    for (RoutingType routingType : routingTypes) {
        result[i++] = routingType.toString();
    }
    return result;
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) RoutingType(org.apache.activemq.artemis.api.core.RoutingType)

Example 9 with RoutingType

use of org.apache.activemq.artemis.api.core.RoutingType in project activemq-artemis by apache.

the class CreateAddressMessage method encodeRest.

@Override
public void encodeRest(final ActiveMQBuffer buffer) {
    buffer.writeSimpleString(address);
    buffer.writeInt(routingTypes.size());
    for (RoutingType routingType : routingTypes) {
        buffer.writeByte(routingType.getType());
    }
    buffer.writeBoolean(requiresResponse);
    buffer.writeBoolean(autoCreated);
}
Also used : RoutingType(org.apache.activemq.artemis.api.core.RoutingType)

Example 10 with RoutingType

use of org.apache.activemq.artemis.api.core.RoutingType in project activemq-artemis by apache.

the class StompSession method addSubscription.

public StompPostReceiptFunction addSubscription(long consumerID, String subscriptionID, String clientID, String durableSubscriptionName, String destination, String selector, String ack) throws Exception {
    SimpleString queueName = SimpleString.toSimpleString(destination);
    boolean pubSub = false;
    final int receiveCredits = ack.equals(Stomp.Headers.Subscribe.AckModeValues.AUTO) ? -1 : consumerCredits;
    Set<RoutingType> routingTypes = manager.getServer().getAddressInfo(getCoreSession().removePrefix(SimpleString.toSimpleString(destination))).getRoutingTypes();
    boolean topic = routingTypes.size() == 1 && routingTypes.contains(RoutingType.MULTICAST);
    if (topic) {
        // subscribes to a topic
        pubSub = true;
        if (durableSubscriptionName != null) {
            if (clientID == null) {
                throw BUNDLE.missingClientID();
            }
            queueName = SimpleString.toSimpleString(clientID + "." + durableSubscriptionName);
            if (manager.getServer().locateQueue(queueName) == null) {
                session.createQueue(SimpleString.toSimpleString(destination), queueName, SimpleString.toSimpleString(selector), false, true);
            }
        } else {
            queueName = UUIDGenerator.getInstance().generateSimpleStringUUID();
            session.createQueue(SimpleString.toSimpleString(destination), queueName, SimpleString.toSimpleString(selector), true, false);
        }
    }
    final ServerConsumer consumer = topic ? session.createConsumer(consumerID, queueName, null, false, false, 0) : session.createConsumer(consumerID, queueName, SimpleString.toSimpleString(selector), false, false, 0);
    StompSubscription subscription = new StompSubscription(subscriptionID, ack, queueName, pubSub);
    subscriptions.put(consumerID, subscription);
    session.start();
    return () -> consumer.receiveCredits(receiveCredits);
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ServerConsumer(org.apache.activemq.artemis.core.server.ServerConsumer) RoutingType(org.apache.activemq.artemis.api.core.RoutingType)

Aggregations

RoutingType (org.apache.activemq.artemis.api.core.RoutingType)45 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)31 Test (org.junit.Test)15 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)11 AddressInfo (org.apache.activemq.artemis.core.server.impl.AddressInfo)11 HashSet (java.util.HashSet)9 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)9 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)8 QueueQueryResult (org.apache.activemq.artemis.core.server.QueueQueryResult)7 OperationContext (org.apache.activemq.artemis.core.persistence.OperationContext)6 ServerSession (org.apache.activemq.artemis.core.server.ServerSession)6 QueueBinding (org.apache.activemq.artemis.core.postoffice.QueueBinding)5 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)5 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)4 Semaphore (java.util.concurrent.Semaphore)4 Pair (org.apache.activemq.artemis.api.core.Pair)4 CoreAddressConfiguration (org.apache.activemq.artemis.core.config.CoreAddressConfiguration)4 CoreQueueConfiguration (org.apache.activemq.artemis.core.config.CoreQueueConfiguration)4 Filter (org.apache.activemq.artemis.core.filter.Filter)4 PageSubscription (org.apache.activemq.artemis.core.paging.cursor.PageSubscription)4