use of org.apache.activemq.command.DestinationInfo in project activemq-artemis by apache.
the class OpenWireConnection method removeDestination.
public void removeDestination(ActiveMQDestination dest) throws Exception {
if (dest.isQueue()) {
try {
server.destroyQueue(new SimpleString(dest.getPhysicalName()), getRemotingConnection());
} catch (ActiveMQNonExistentQueueException neq) {
// this is ok, ActiveMQ 5 allows this and will actually do it quite often
ActiveMQServerLogger.LOGGER.debug("queue never existed");
}
} else {
Bindings bindings = server.getPostOffice().getBindingsForAddress(new SimpleString(dest.getPhysicalName()));
for (Binding binding : bindings.getBindings()) {
Queue b = (Queue) binding.getBindable();
if (b.getConsumerCount() > 0) {
throw new Exception("Destination still has an active subscription: " + dest.getPhysicalName());
}
if (b.isDurable()) {
throw new Exception("Destination still has durable subscription: " + dest.getPhysicalName());
}
b.deleteQueue();
}
}
if (!AdvisorySupport.isAdvisoryTopic(dest)) {
AMQConnectionContext context = getContext();
DestinationInfo advInfo = new DestinationInfo(context.getConnectionId(), DestinationInfo.REMOVE_OPERATION_TYPE, dest);
ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(dest);
protocolManager.fireAdvisory(context, topic, advInfo);
}
}
use of org.apache.activemq.command.DestinationInfo 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);
}
}
use of org.apache.activemq.command.DestinationInfo in project activemq-artemis by apache.
the class BrokerNetworkWithStuckMessagesTest method createDestinationInfo.
protected ActiveMQDestination createDestinationInfo(StubConnection connection, ConnectionInfo connectionInfo1, byte destinationType) throws Exception {
if ((destinationType & ActiveMQDestination.TEMP_MASK) != 0) {
DestinationInfo info = createTempDestinationInfo(connectionInfo1, destinationType);
connection.send(info);
return info.getDestination();
} else {
return ActiveMQDestination.createDestination(queueName, destinationType);
}
}
use of org.apache.activemq.command.DestinationInfo in project activemq-artemis by apache.
the class DestinationInfoTest method createObject.
@Override
public Object createObject() throws Exception {
DestinationInfo info = new DestinationInfo();
populateObject(info);
return info;
}
use of org.apache.activemq.command.DestinationInfo in project activemq-artemis by apache.
the class DestinationInfoTest method createObject.
@Override
public Object createObject() throws Exception {
DestinationInfo info = new DestinationInfo();
populateObject(info);
return info;
}
Aggregations