tibtof
tibtof

Reputation: 7957

Exception when restarting embedded activeMQ broker with jdbcPersistenceAdapter

Using ActiveMQ 5.9.0, I have the following broker configuration:

<amq:broker id="broker" useShutdownHook="false" persistent="true">
    <amq:persistenceAdapter>
        <amq:jdbcPersistenceAdapter dataSource="#dataSource">
        </amq:jdbcPersistenceAdapter>
    </amq:persistenceAdapter>
    <amq:transportConnectors>
        <amq:transportConnector uri="${broker.url}" />
    </amq:transportConnectors>
</amq:broker>

If there are already messages in the database when the broker is started, I get the exception:

java.lang.ClassCastException: org.apache.activemq.command.WireFormatInfo cannot be cast to org.apache.activemq.command.Message at org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.getLastMessageBrokerSequenceId(JDBCPersistenceAdapter.java:265) at org.apache.activemq.broker.region.DestinationFactoryImpl.getLastMessageBrokerSequenceId(DestinationFactoryImpl.java:147) at org.apache.activemq.broker.region.RegionBroker.(RegionBroker.java:128) at org.apache.activemq.broker.jmx.ManagedRegionBroker.(ManagedRegionBroker.java:111) at org.apache.activemq.broker.BrokerService.createRegionBroker(BrokerService.java:2172) at org.apache.activemq.broker.BrokerService.createRegionBroker(BrokerService.java:2165) at org.apache.activemq.broker.BrokerService.createBroker(BrokerService.java:2122) at org.apache.activemq.broker.BrokerService.getBroker(BrokerService.java:906) at org.apache.activemq.broker.BrokerService.getAdminConnectionContext(BrokerService.java:2393) at org.apache.activemq.broker.BrokerService.startVirtualConsumerDestinations(BrokerService.java:2533) at org.apache.activemq.broker.BrokerService.startDestinations(BrokerService.java:2384) at org.apache.activemq.broker.BrokerService.doStartBroker(BrokerService.java:640) at org.apache.activemq.broker.BrokerService.startBroker(BrokerService.java:632) at org.apache.activemq.broker.BrokerService.start(BrokerService.java:568) at org.apache.activemq.broker.BrokerService.autoStart(BrokerService.java:524) at org.apache.activemq.broker.BrokerService.postConstruct(BrokerService.java:511)

It seems to me that the format used to marshal the message may be different from the one used when unmarshalling. Any idea why is this happening?

Upvotes: 4

Views: 795

Answers (1)

tibtof
tibtof

Reputation: 7957

The problem was the oracle driver version. When a blob column was read from the database the data got corrupted. The problem was rather difficult to reproduce (stopping the application while messages were received), so switching to amq 5.5.0 was a false positive. I was using ojdbc 10.1.0.2.0 and switching to ojdbc6 11.2.0.3 solved the problem.

Upvotes: 3

Related Questions