ARTEMIS-1797 Auto-create-address flag shouldn't avoid temp destination creation
When creating a temp destination and auto-create-address set to false, the broker throws an error and refuse to create it. This doesn't conform to normal use-case (like amqp dynamic flag) where the temp destination should be allowed even if the auto-create-address is false.
This commit is contained in:
parent
8d4bf953fb
commit
1175d777b3
|
@ -2752,7 +2752,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
|||
|
||||
RoutingType routingType = addrInfo == null ? null : addrInfo.getRoutingType();
|
||||
RoutingType rt = (routingType == null ? ActiveMQDefaultConfiguration.getDefaultRoutingType() : routingType);
|
||||
if (autoCreateAddress) {
|
||||
if (autoCreateAddress || temporary) {
|
||||
if (info == null) {
|
||||
final AddressInfo addressInfo = new AddressInfo(addressToUse, rt);
|
||||
addressInfo.setAutoCreated(true);
|
||||
|
|
|
@ -44,9 +44,18 @@ import org.apache.activemq.transport.amqp.client.AmqpMessage;
|
|||
import org.apache.activemq.transport.amqp.client.AmqpSender;
|
||||
import org.apache.activemq.transport.amqp.client.AmqpSession;
|
||||
import org.apache.qpid.proton.amqp.Symbol;
|
||||
import org.apache.qpid.proton.amqp.messaging.DeleteOnClose;
|
||||
import org.apache.qpid.proton.amqp.messaging.Source;
|
||||
import org.apache.qpid.proton.amqp.messaging.Target;
|
||||
import org.apache.qpid.proton.amqp.messaging.TerminusDurability;
|
||||
import org.apache.qpid.proton.amqp.messaging.TerminusExpiryPolicy;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
import static org.apache.activemq.transport.amqp.AmqpSupport.LIFETIME_POLICY;
|
||||
import static org.apache.activemq.transport.amqp.AmqpSupport.TEMP_QUEUE_CAPABILITY;
|
||||
import static org.apache.activemq.transport.amqp.AmqpSupport.TEMP_TOPIC_CAPABILITY;
|
||||
|
||||
/**
|
||||
* Test support class for tests that will be using the AMQP Proton wrapper client. This is to
|
||||
* make it easier to migrate tests from ActiveMQ5
|
||||
|
@ -201,7 +210,7 @@ public class AmqpClientTestSupport extends AmqpTestSupport {
|
|||
|
||||
addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);
|
||||
addressSettings.setAutoCreateQueues(isAutoCreateQueues());
|
||||
addressSettings.setAutoCreateAddresses(isAutoCreateQueues());
|
||||
addressSettings.setAutoCreateAddresses(isAutoCreateAddresses());
|
||||
addressSettings.setDeadLetterAddress(SimpleString.toSimpleString(getDeadLetterAddress()));
|
||||
addressSettings.setExpiryAddress(SimpleString.toSimpleString(getDeadLetterAddress()));
|
||||
|
||||
|
@ -345,4 +354,48 @@ public class AmqpClientTestSupport extends AmqpTestSupport {
|
|||
connection.close();
|
||||
}
|
||||
}
|
||||
|
||||
protected Source createDynamicSource(boolean topic) {
|
||||
|
||||
Source source = new Source();
|
||||
source.setDynamic(true);
|
||||
source.setDurable(TerminusDurability.NONE);
|
||||
source.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);
|
||||
|
||||
// Set the dynamic node lifetime-policy
|
||||
Map<Symbol, Object> dynamicNodeProperties = new HashMap<>();
|
||||
dynamicNodeProperties.put(LIFETIME_POLICY, DeleteOnClose.getInstance());
|
||||
source.setDynamicNodeProperties(dynamicNodeProperties);
|
||||
|
||||
// Set the capability to indicate the node type being created
|
||||
if (!topic) {
|
||||
source.setCapabilities(TEMP_QUEUE_CAPABILITY);
|
||||
} else {
|
||||
source.setCapabilities(TEMP_TOPIC_CAPABILITY);
|
||||
}
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
protected Target createDynamicTarget(boolean topic) {
|
||||
|
||||
Target target = new Target();
|
||||
target.setDynamic(true);
|
||||
target.setDurable(TerminusDurability.NONE);
|
||||
target.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);
|
||||
|
||||
// Set the dynamic node lifetime-policy
|
||||
Map<Symbol, Object> dynamicNodeProperties = new HashMap<>();
|
||||
dynamicNodeProperties.put(LIFETIME_POLICY, DeleteOnClose.getInstance());
|
||||
target.setDynamicNodeProperties(dynamicNodeProperties);
|
||||
|
||||
// Set the capability to indicate the node type being created
|
||||
if (!topic) {
|
||||
target.setCapabilities(TEMP_QUEUE_CAPABILITY);
|
||||
} else {
|
||||
target.setCapabilities(TEMP_TOPIC_CAPABILITY);
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,10 +17,7 @@
|
|||
package org.apache.activemq.artemis.tests.integration.amqp;
|
||||
|
||||
import static org.apache.activemq.transport.amqp.AmqpSupport.LIFETIME_POLICY;
|
||||
import static org.apache.activemq.transport.amqp.AmqpSupport.TEMP_QUEUE_CAPABILITY;
|
||||
import static org.apache.activemq.transport.amqp.AmqpSupport.TEMP_TOPIC_CAPABILITY;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -282,48 +279,4 @@ public class AmqpTempDestinationTest extends AmqpClientTestSupport {
|
|||
|
||||
connection.close();
|
||||
}
|
||||
|
||||
protected Source createDynamicSource(boolean topic) {
|
||||
|
||||
Source source = new Source();
|
||||
source.setDynamic(true);
|
||||
source.setDurable(TerminusDurability.NONE);
|
||||
source.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);
|
||||
|
||||
// Set the dynamic node lifetime-policy
|
||||
Map<Symbol, Object> dynamicNodeProperties = new HashMap<>();
|
||||
dynamicNodeProperties.put(LIFETIME_POLICY, DeleteOnClose.getInstance());
|
||||
source.setDynamicNodeProperties(dynamicNodeProperties);
|
||||
|
||||
// Set the capability to indicate the node type being created
|
||||
if (!topic) {
|
||||
source.setCapabilities(TEMP_QUEUE_CAPABILITY);
|
||||
} else {
|
||||
source.setCapabilities(TEMP_TOPIC_CAPABILITY);
|
||||
}
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
protected Target createDynamicTarget(boolean topic) {
|
||||
|
||||
Target target = new Target();
|
||||
target.setDynamic(true);
|
||||
target.setDurable(TerminusDurability.NONE);
|
||||
target.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);
|
||||
|
||||
// Set the dynamic node lifetime-policy
|
||||
Map<Symbol, Object> dynamicNodeProperties = new HashMap<>();
|
||||
dynamicNodeProperties.put(LIFETIME_POLICY, DeleteOnClose.getInstance());
|
||||
target.setDynamicNodeProperties(dynamicNodeProperties);
|
||||
|
||||
// Set the capability to indicate the node type being created
|
||||
if (!topic) {
|
||||
target.setCapabilities(TEMP_QUEUE_CAPABILITY);
|
||||
} else {
|
||||
target.setCapabilities(TEMP_TOPIC_CAPABILITY);
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.amqp;
|
||||
|
||||
public class AmqpTempDestinationTest2 extends AmqpTempDestinationTest {
|
||||
|
||||
@Override
|
||||
protected boolean isAutoCreateAddresses() {
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue