Details
Description
When publishing to a topic, a ClassCastException occurs:
Caused by: java.lang.ClassCastException: org.apache.activemq.ActiveMQConnectionConsumer
at org.apache.activemq.broker.TransportConnection.processDispatch(TransportConnection.java:810)
at org.apache.activemq.broker.TransportConnection.dispatchSync(TransportConnection.java:769)
at org.apache.activemq.broker.region.TopicSubscription.dispatch(TopicSubscription.java:360)
at org.apache.activemq.broker.region.TopicSubscription.add(TopicSubscription.java:83)
at org.apache.activemq.broker.region.policy.SimpleDispatchPolicy.dispatch(SimpleDispatchPolicy.java:51)
at org.apache.activemq.broker.region.Topic.dispatch(Topic.java:417)
at org.apache.activemq.broker.region.Topic.send(Topic.java:264)
at org.apache.activemq.broker.region.AbstractRegion.send(AbstractRegion.java:292)
at org.apache.activemq.broker.region.RegionBroker.send(RegionBroker.java:385)
at org.apache.activemq.broker.TransactionBroker.send(TransactionBroker.java:193)
at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:126)
at org.apache.activemq.broker.CompositeDestinationBroker.send(CompositeDestinationBroker.java:98)
at org.apache.activemq.broker.MutableBrokerFilter.send(MutableBrokerFilter.java:136)
at org.apache.activemq.broker.TransportConnection.processMessage(TransportConnection.java:497)
at org.apache.activemq.command.ActiveMQMessage.visit(ActiveMQMessage.java:604)
at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:293)
at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:184)
at org.apache.activemq.transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:95)
at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:65)
at org.apache.activemq.transport.vm.VMTransport.syncOneWay(VMTransport.java:96)
at org.apache.activemq.transport.vm.VMTransport.oneway(VMTransport.java:83)
at org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:47)
at org.apache.activemq.transport.ResponseCorrelator.asyncRequest(ResponseCorrelator.java:69)
at org.apache.activemq.transport.ResponseCorrelator.request(ResponseCorrelator.java:74)
at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1175)
... 7 more
The problem seems to stem in the processDispatch() method of the org.apache.activemq.broker.TransportConnection class. Specifically, it happens during the line:
Runnable sub=(Runnable) md.getConsumer();
It doesn't appear that ActiveMQConnectionConsumer implements the Runnable interface, so this is why the ClassCastException occurs.