ARTEMIS-2631 address orphaned from JMS temp queue
This commit is contained in:
parent
32829d6542
commit
339ccccbd7
|
@ -269,7 +269,7 @@ public class SimpleAddressManager implements AddressManager {
|
||||||
@Override
|
@Override
|
||||||
public boolean addAddressInfo(AddressInfo addressInfo) throws Exception {
|
public boolean addAddressInfo(AddressInfo addressInfo) throws Exception {
|
||||||
boolean added = reloadAddressInfo(addressInfo);
|
boolean added = reloadAddressInfo(addressInfo);
|
||||||
if (added && storageManager != null) {
|
if (!addressInfo.isTemporary() && added && storageManager != null) {
|
||||||
long txID = storageManager.generateID();
|
long txID = storageManager.generateID();
|
||||||
try {
|
try {
|
||||||
storageManager.addAddressBinding(txID, addressInfo);
|
storageManager.addAddressBinding(txID, addressInfo);
|
||||||
|
|
|
@ -3382,9 +3382,10 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
||||||
RoutingType rt = (routingType == null ? ActiveMQDefaultConfiguration.getDefaultRoutingType() : routingType);
|
RoutingType rt = (routingType == null ? ActiveMQDefaultConfiguration.getDefaultRoutingType() : routingType);
|
||||||
if (autoCreateAddress || temporary) {
|
if (autoCreateAddress || temporary) {
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
final AddressInfo addressInfo = new AddressInfo(addressToUse, rt);
|
final AddressInfo addressInfo = new AddressInfo(addressToUse, rt)
|
||||||
addressInfo.setAutoCreated(true);
|
.setAutoCreated(true)
|
||||||
addressInfo.setInternal(addrInfo == null ? false : addrInfo.isInternal());
|
.setTemporary(temporary)
|
||||||
|
.setInternal(addrInfo == null ? false : addrInfo.isInternal());
|
||||||
addAddressInfo(addressInfo);
|
addAddressInfo(addressInfo);
|
||||||
} else if (!info.getRoutingTypes().contains(rt)) {
|
} else if (!info.getRoutingTypes().contains(rt)) {
|
||||||
EnumSet<RoutingType> routingTypes = EnumSet.copyOf(info.getRoutingTypes());
|
EnumSet<RoutingType> routingTypes = EnumSet.copyOf(info.getRoutingTypes());
|
||||||
|
|
|
@ -46,6 +46,8 @@ public class AddressInfo {
|
||||||
|
|
||||||
private boolean autoCreated = false;
|
private boolean autoCreated = false;
|
||||||
|
|
||||||
|
private volatile boolean temporary = false;
|
||||||
|
|
||||||
private static final EnumSet<RoutingType> EMPTY_ROUTING_TYPES = EnumSet.noneOf(RoutingType.class);
|
private static final EnumSet<RoutingType> EMPTY_ROUTING_TYPES = EnumSet.noneOf(RoutingType.class);
|
||||||
private EnumSet<RoutingType> routingTypes;
|
private EnumSet<RoutingType> routingTypes;
|
||||||
private RoutingType firstSeen;
|
private RoutingType firstSeen;
|
||||||
|
@ -101,6 +103,15 @@ public class AddressInfo {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isTemporary() {
|
||||||
|
return temporary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AddressInfo setTemporary(boolean temporary) {
|
||||||
|
this.temporary = temporary;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public SimpleString getName() {
|
public SimpleString getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,11 @@ public class TemporaryDestinationTest extends JMSTestBase {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean usePersistence() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTemporaryQueueLeak() throws Exception {
|
public void testTemporaryQueueLeak() throws Exception {
|
||||||
ActiveMQConnection conn = null;
|
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
|
@Test
|
||||||
public void testForTempQueueCleanerUpperLeak() throws Exception {
|
public void testForTempQueueCleanerUpperLeak() throws Exception {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue