peter-mount / opendata

Latest & first public version of my code that monitors the UK Rail Network in real time using Open Data feeds
Other
12 stars 2 forks source link

ClassCastException when receiving from ApacheMQ #12

Closed peter-mount closed 9 years ago

peter-mount commented 9 years ago

I saw this on the Network Rail feed's logs:

Apr 05, 2015 7:05:42 AM uk.trainwatch.apachemq.TopicClient lambda$start$11
SEVERE: Exception in topic TD_ALL_SIG_AREA
javax.jms.JMSException: Unexpected error occured: java.lang.ClassCastException
        at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62)
        at org.apache.activemq.ActiveMQMessageConsumer.dequeue(ActiveMQMessageConsumer.java:476)
        at org.apache.activemq.ActiveMQMessageConsumer.receive(ActiveMQMessageConsumer.java:594)
        at uk.trainwatch.apachemq.TopicClient.lambda$start$11(TopicClient.java:88)
        at uk.trainwatch.apachemq.TopicClient$$Lambda$24/1957120193.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Unexpected error occured: java.lang.ClassCastException
        at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:203)
        ... 1 more
Caused by: java.lang.ClassCastException

Apr 05, 2015 7:05:42 AM uk.trainwatch.apachemq.Watchdog reconnect
INFO: Retry period now 8000

the client reconnected fine afterwards

peter-mount commented 9 years ago

As this appears to be within ApacheMQ's client and the networkrail feed's been running on Dec 10 2014's build I've just put the current version of that feed up to see if that fixes it.

peter-mount commented 9 years ago

Nope, that didn't do it:

Apr 05, 2015 7:19:50 AM uk.trainwatch.apachemq.TopicClient lambda$start$18
SEVERE: Exception in topic TRAIN_MVT_ALL_TOC
javax.jms.JMSException: Unexpected error occured: java.lang.ClassCastException: org.apache.activemq.command.BrokerId cannot be cast to org.apache.activemq.command.ConsumerId
        at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62)
        at org.apache.activemq.ActiveMQMessageConsumer.dequeue(ActiveMQMessageConsumer.java:476)
        at org.apache.activemq.ActiveMQMessageConsumer.receive(ActiveMQMessageConsumer.java:594)
        at uk.trainwatch.apachemq.TopicClient.lambda$start$18(TopicClient.java:91)
        at uk.trainwatch.apachemq.TopicClient$$Lambda$24/1297263578.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Unexpected error occured: java.lang.ClassCastException: org.apache.activemq.command.BrokerId cannot be cast to org.apache.activemq.command.ConsumerId
        at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:203)
        ... 1 more
Caused by: java.lang.ClassCastException: org.apache.activemq.command.BrokerId cannot be cast to org.apache.activemq.command.ConsumerId
        at org.apache.activemq.openwire.v9.MessageMarshaller.tightUnmarshal(MessageMarshaller.java:75)
        at org.apache.activemq.openwire.v9.ActiveMQMessageMarshaller.tightUnmarshal(ActiveMQMessageMarshaller.java:66)
        at org.apache.activemq.openwire.v9.ActiveMQTextMessageMarshaller.tightUnmarshal(ActiveMQTextMessageMarshaller.java:66)
        at org.apache.activemq.openwire.OpenWireFormat.tightUnmarshalNestedObject(OpenWireFormat.java:462)
        at org.apache.activemq.openwire.v9.BaseDataStreamMarshaller.tightUnmarsalNestedObject(BaseDataStreamMarshaller.java:125)
        at org.apache.activemq.openwire.v9.MessageDispatchMarshaller.tightUnmarshal(MessageDispatchMarshaller.java:71)
        at org.apache.activemq.openwire.OpenWireFormat.doUnmarshal(OpenWireFormat.java:371)
        at org.apache.activemq.openwire.OpenWireFormat.unmarshal(OpenWireFormat.java:285)
        at org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:221)
        at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:213)
        at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:196)
        ... 1 more

Apr 05, 2015 7:19:50 AM uk.trainwatch.apachemq.Watchdog reconnect
peter-mount commented 9 years ago

I've now updated Apache ActiveMQ client from 5.8.0 to 5.11.1 to see if that fixes the problem. At first it didn't but I need to watch the logs. It does seem a bit more stable now.

Sadly looking online this appears to have happened before to others around 2008/9 & the solution was to restart the broker as it's out of memory or a bug in memory management. That's not really an option as I'm the client here. On our side memory is fine & it's only Network Rail's broker - National Rail's broker is fine.

peter-mount commented 9 years ago

Closing this as the problem has not been seen since