This closes #2993
This commit is contained in:
commit
e899fac372
|
@ -269,7 +269,7 @@ public class SimpleAddressManager implements AddressManager {
|
|||
@Override
|
||||
public boolean addAddressInfo(AddressInfo addressInfo) throws Exception {
|
||||
boolean added = reloadAddressInfo(addressInfo);
|
||||
if (added && storageManager != null) {
|
||||
if (!addressInfo.isTemporary() && added && storageManager != null) {
|
||||
long txID = storageManager.generateID();
|
||||
try {
|
||||
storageManager.addAddressBinding(txID, addressInfo);
|
||||
|
|
|
@ -3382,9 +3382,10 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
|||
RoutingType rt = (routingType == null ? ActiveMQDefaultConfiguration.getDefaultRoutingType() : routingType);
|
||||
if (autoCreateAddress || temporary) {
|
||||
if (info == null) {
|
||||
final AddressInfo addressInfo = new AddressInfo(addressToUse, rt);
|
||||
addressInfo.setAutoCreated(true);
|
||||
addressInfo.setInternal(addrInfo == null ? false : addrInfo.isInternal());
|
||||
final AddressInfo addressInfo = new AddressInfo(addressToUse, rt)
|
||||
.setAutoCreated(true)
|
||||
.setTemporary(temporary)
|
||||
.setInternal(addrInfo == null ? false : addrInfo.isInternal());
|
||||
addAddressInfo(addressInfo);
|
||||
} else if (!info.getRoutingTypes().contains(rt)) {
|
||||
EnumSet<RoutingType> routingTypes = EnumSet.copyOf(info.getRoutingTypes());
|
||||
|
|
|
@ -46,6 +46,8 @@ public class AddressInfo {
|
|||
|
||||
private boolean autoCreated = false;
|
||||
|
||||
private volatile boolean temporary = false;
|
||||
|
||||
private static final EnumSet<RoutingType> EMPTY_ROUTING_TYPES = EnumSet.noneOf(RoutingType.class);
|
||||
private EnumSet<RoutingType> routingTypes;
|
||||
private RoutingType firstSeen;
|
||||
|
@ -101,6 +103,15 @@ public class AddressInfo {
|
|||
return this;
|
||||
}
|
||||
|
||||
public boolean isTemporary() {
|
||||
return temporary;
|
||||
}
|
||||
|
||||
public AddressInfo setTemporary(boolean temporary) {
|
||||
this.temporary = temporary;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SimpleString getName() {
|
||||
return name;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,11 @@ public class TemporaryDestinationTest extends JMSTestBase {
|
|||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean usePersistence() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTemporaryQueueLeak() throws Exception {
|
||||
ActiveMQConnection conn = null;
|
||||
|
@ -213,6 +218,37 @@ public class TemporaryDestinationTest extends JMSTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTemporaryResourcesDeletedAfterServerRestart() throws Exception {
|
||||
server.getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false));
|
||||
|
||||
Connection conn = null;
|
||||
|
||||
try {
|
||||
conn = createConnection();
|
||||
|
||||
Session producerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
|
||||
TemporaryQueue tempQueue = producerSession.createTemporaryQueue();
|
||||
|
||||
assertNotNull(server.getAddressInfo(SimpleString.toSimpleString(tempQueue.getQueueName())));
|
||||
|
||||
server.stop();
|
||||
|
||||
conn.close();
|
||||
|
||||
server.start();
|
||||
|
||||
waitForServerToStart(server);
|
||||
|
||||
assertNull(server.getAddressInfo(SimpleString.toSimpleString(tempQueue.getQueueName())));
|
||||
} finally {
|
||||
if (conn != null) {
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForTempQueueCleanerUpperLeak() throws Exception {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue