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();
}
}
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();
}
}
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;
}
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);
}
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);
}
Aggregations