mirror of https://github.com/apache/activemq.git
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1511321 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
82c4ab83ed
commit
45c399d810
|
@ -25,7 +25,13 @@ import org.apache.activemq.broker.Broker;
|
|||
import org.apache.activemq.broker.BrokerFilter;
|
||||
import org.apache.activemq.broker.ConnectionContext;
|
||||
import org.apache.activemq.broker.ProducerBrokerExchange;
|
||||
import org.apache.activemq.broker.region.*;
|
||||
import org.apache.activemq.broker.region.Destination;
|
||||
import org.apache.activemq.broker.region.DurableTopicSubscription;
|
||||
import org.apache.activemq.broker.region.MessageReference;
|
||||
import org.apache.activemq.broker.region.RegionBroker;
|
||||
import org.apache.activemq.broker.region.Subscription;
|
||||
import org.apache.activemq.broker.region.TopicRegion;
|
||||
import org.apache.activemq.broker.region.TopicSubscription;
|
||||
import org.apache.activemq.command.*;
|
||||
import org.apache.activemq.security.SecurityContext;
|
||||
import org.apache.activemq.state.ProducerState;
|
||||
|
@ -251,9 +257,10 @@ public class AdvisoryBroker extends BrokerFilter {
|
|||
@Override
|
||||
public void removeSubscription(ConnectionContext context, RemoveSubscriptionInfo info) throws Exception {
|
||||
SubscriptionKey key = new SubscriptionKey(context.getClientId(), info.getSubscriptionName());
|
||||
|
||||
DurableTopicSubscription sub = ((TopicRegion)((RegionBroker)next).getTopicRegion()).getDurableSubscription(key);
|
||||
|
||||
super.removeSubscription(context, info);
|
||||
|
||||
if (sub == null) {
|
||||
LOG.warn("We cannot send an advisory message for a durable sub removal when we don't know about the durable sub");
|
||||
return;
|
||||
|
@ -261,8 +268,6 @@ public class AdvisoryBroker extends BrokerFilter {
|
|||
|
||||
ActiveMQDestination dest = sub.getConsumerInfo().getDestination();
|
||||
|
||||
super.removeSubscription(context, info);
|
||||
|
||||
// Don't advise advisory topics.
|
||||
if (!AdvisorySupport.isAdvisoryTopic(dest)) {
|
||||
ActiveMQTopic topic = AdvisorySupport.getConsumerAdvisoryTopic(dest);
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
/**
|
||||
* 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.bugs;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.Session;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class AMQ4671Test {
|
||||
|
||||
private static final transient Logger LOG = LoggerFactory.getLogger(AMQ4671Test.class);
|
||||
private static BrokerService brokerService;
|
||||
private static String BROKER_ADDRESS = "tcp://localhost:0";
|
||||
|
||||
private String connectionUri;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
brokerService = new BrokerService();
|
||||
brokerService.setPersistent(false);
|
||||
brokerService.setUseJmx(true);
|
||||
brokerService.setDeleteAllMessagesOnStartup(true);
|
||||
connectionUri = brokerService.addConnector(BROKER_ADDRESS).getPublishableConnectString();
|
||||
connectionUri = connectionUri + "?trace=true";
|
||||
brokerService.start();
|
||||
brokerService.waitUntilStarted();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
brokerService.stop();
|
||||
brokerService.waitUntilStopped();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonDurableSubscriberInvalidUnsubscribe() throws Exception {
|
||||
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(connectionUri);
|
||||
|
||||
Connection connection = connectionFactory.createConnection();
|
||||
connection.setClientID(getClass().getName());
|
||||
connection.start();
|
||||
|
||||
try {
|
||||
Session ts = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
|
||||
try {
|
||||
ts.unsubscribe("invalid-subscription-name");
|
||||
fail("this should fail");
|
||||
} catch (javax.jms.InvalidDestinationException e) {
|
||||
LOG.info("Test caught correct invalid destination exception");
|
||||
}
|
||||
} finally {
|
||||
if (connection != null) {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue