Description
When an AMQP client creates a receiver link and the logged in user is not authorized on error is sent to the client and the link is closed, this generates an event which causes us to try and remove the consumer but that consumer was never registered so you see these sorts of things in the logs:
java.lang.IllegalStateException: Cannot remove a consumer that had not been registered: ID:OfficePC-58049-1422548859782-1:3:1:0 at org.apache.activemq.broker.TransportConnection.processRemoveConsumer(TransportConnection.java:691) at org.apache.activemq.command.RemoveInfo.visit(RemoveInfo.java:76) at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:334) at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:188) at org.apache.activemq.transport.amqp.AmqpTransportFilter.sendToActiveMQ(AmqpTransportFilter.java:114) at org.apache.activemq.transport.amqp.AmqpProtocolConverter.sendToActiveMQ(AmqpProtocolConverter.java:1486) at org.apache.activemq.transport.amqp.AmqpProtocolConverter$ConsumerContext.onClose(AmqpProtocolConverter.java:1017) at org.apache.activemq.transport.amqp.AmqpProtocolConverter.processLinkEvent(AmqpProtocolConverter.java:390) at org.apache.activemq.transport.amqp.AmqpProtocolConverter.onFrame(AmqpProtocolConverter.java:331) at org.apache.activemq.transport.amqp.AmqpProtocolConverter.onAMQPData(AmqpProtocolConverter.java:275) at org.apache.activemq.transport.amqp.AmqpTransportFilter.onCommand(AmqpTransportFilter.java:98) at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83) at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:214) at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:196)
This would likely also happen for a sender link.
We need to track this state and not try and remove consumers or producers from the Broker that not actually registered due to security or other errors. This causes not just log spam but a connection close as we treat the returned error from the Broker as a fatal protocol error which it is not.