Can't unsubscribe a durable subscription when there's a virtual topic present on the broker -------------------------------------------------------------------------------------------
Key: AMQ-2144 URL: https://issues.apache.org/activemq/browse/AMQ-2144 Project: ActiveMQ Issue Type: Bug Components: Broker Affects Versions: 5.2.0 Environment: Ubuntu Reporter: Cláudio de Miranda Luz The scenario is: There's a virtual topic being used. (i.e. topic VirtualTopic.Orders). A consumer subscribes to any topic present on the broker and after some time it tries to unsubscribe the durable subscription. When it calls session.unsubscribe(consumerName) to unsubscribe a durable subscription, it receives the following exception: Caught: javax.jms.JMSException: org.apache.activemq.broker.region.virtual.VirtualTopicInterceptor cannot be cast to org.apache.activemq.broker.region.Topic javax.jms.JMSException: org.apache.activemq.broker.region.virtual.VirtualTopicInterceptor cannot be cast to org.apache.activemq.broker.region.Topic at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:49) at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1244) at org.apache.activemq.ActiveMQConnection.unsubscribe(ActiveMQConnection.java:2052) at org.apache.activemq.ActiveMQSession.unsubscribe(ActiveMQSession.java:1431) at DurableSubscriber.consumeMessagesAndClose(DurableSubscriber.java:206) at DurableSubscriber.run(DurableSubscriber.java:112) at DurableSubscriber.main(DurableSubscriber.java:70) Caused by: java.lang.ClassCastException: org.apache.activemq.broker.region.virtual.VirtualTopicInterceptor cannot be cast to org.apache.activemq.broker.region.Topic at org.apache.activemq.broker.region.TopicRegion.removeSubscription(TopicRegion.java:139) at org.apache.activemq.broker.region.RegionBroker.removeSubscription(RegionBroker.java:409) at org.apache.activemq.broker.BrokerFilter.removeSubscription(BrokerFilter.java:98) at org.apache.activemq.broker.BrokerFilter.removeSubscription(BrokerFilter.java:98) at org.apache.activemq.broker.BrokerFilter.removeSubscription(BrokerFilter.java:98) at org.apache.activemq.broker.MutableBrokerFilter.removeSubscription(MutableBrokerFilter.java:105) at org.apache.activemq.broker.TransportConnection.processRemoveSubscription(TransportConnection.java:339) at org.apache.activemq.command.RemoveSubscriptionInfo.visit(RemoveSubscriptionInfo.java:83) at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:305) at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:179) at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:68) at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:143) at org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:206) at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:84) at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:203) at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:185) at java.lang.Thread.run(Thread.java:619) The error happens on the following method of org.apache.activemq.broker.region.TopicRegion class: public void removeSubscription(ConnectionContext context, RemoveSubscriptionInfo info) throws Exception { SubscriptionKey key = new SubscriptionKey(info.getClientId(), info.getSubscriptionName()); DurableTopicSubscription sub = durableSubscriptions.get(key); if (sub == null) { throw new InvalidDestinationException("No durable subscription exists for: " + info.getSubscriptionName()); } if (sub.isActive()) { throw new JMSException("Durable consumer is in use"); } durableSubscriptions.remove(key); synchronized (destinationsMutex) { for (Iterator<Destination> iter = destinations.values().iterator(); iter.hasNext();) { Topic topic = (Topic)iter.next(); topic.deleteSubscription(context, key); } } super.removeConsumer(context, sub.getConsumerInfo()); } The virtual topic is present on the destinations collection being iterated but its type is not Topic and that is what causes the error. If there is no virtual topics present on the broker, unsubscriptions work well. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.