4 Replies Latest reply on Sep 7, 2011 8:40 PM by wmcdonald

    Oracle JDBC store does not automatically restore queues upon restart?

    wmcdonald

      When I setup Oracle JDBC for ActiveMQ and create a queue 'myq' and send a persistent message to it, I can see it in the browser admin tool.  Then I shutdown the amq and restart it.  When I do this, the queue 'myq' isn't in the browser.  I can see in the db that the message is still there though. 

       

      If I 'create' a new queue called 'myq', then the queue and the persisted message from the db appear in the admin tool.  I've used another browser tool and gotten the same results, so I don't think its the admin tool per se. 

       

      The kahadb doesn't behave this way.  It correctly shows the queue and msg when restarting the amq server - as you'd expect - without having to 'create' myq again.  Given kahadb's behavior I am leaning towards the JDBC behavior being incorrect.

       

      Can you confirm this behavior of the JDBC store method and explain why it is different than Kahadb?

        • 1. Re: Oracle JDBC store does not automatically restore queues upon restart?
          garytully

          That does sounds incorrect, what version are you using? Can you post the persistenceAdapter configuration you are using?

          Are there any relevant messages in the activemq.log (log4j logging). Possibly enable trace level logging and post the results.

          There are some simple JDBC restart junit tests that verify JDBC persistence with derbyDB that work just fine so there is something wrong here.

          • 2. Re: Oracle JDBC store does not automatically restore queues upon restart?
            wmcdonald

            apache-activemq-5.5.0-fuse-00-27

             

            Broker Machine:

            === System Information ===

            SunOS olympia 5.10 Generic_142900-02 sun4u sparc SUNW,Sun-Fire-V210

             

            Processor(s):  Status of virtual processor 0 as of: 09/01/2011 10:35:07

              on-line since 08/17/2011 11:02:58.

              The sparcv9 processor operates at 1336 MHz,

                    and has a sparcv9 floating point processor.

             

            RAM:  Memory size: 4608 Megabytes

             

            Disk Space:  47443718 of 57764678 kilobytes in use.

             

            -


            DB machine:

            === System Information ===

            SunOS gold 5.10 Generic_138888-08 sun4u sparc SUNW,Sun-Fire-V210

             

            Processor(s): 

            Status of virtual processor 0 as of: 09/01/2011 10:39:54

              on-line since 08/26/2011 13:51:00.

              The sparcv9 processor operates at 1280 MHz,

                    and has a sparcv9 floating point processor.

            Status of virtual processor 1 as of: 09/01/2011 10:39:54

              on-line since 08/26/2011 13:50:58.

              The sparcv9 processor operates at 1280 MHz,

                    and has a sparcv9 floating point processor.

             

            RAM:  Memory size: 4096 Megabytes

             

            Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi

             

            -


            activemq.xml snippet:

            ==============

             

             

            -


            Can you set up your own similar config and verify that yours works correctly?  If it does NOT work for you, then you have a case you can locally debug. 

             

            When you mention the JDBC tests w Derby, you're talking about an external Derby server and not the embedded one, right?

             

            UPDATE:

            I have tested it with an external Derby server and still get the same behavior (activemq.xml attached). 

             

            Can you explain where/how in the source code the JDBC Adapter gets the messages from the db and then populates the queue with them on a restart?  I didn't see anything obvious (perhaps I missed it), but I'm starting to wonder if the code that does this is even there; unless its a side effect of a queue refresh or something.

             

            Also, I noticed that I had to set createOnStartup to false if I didn't want it to run the createSchema statements.  Why isn't it smart enough to look for the tables/schema, and if they are not there, create them, but afterwards, when they are there to not create them?  I think the createOnStartup should either work or fail completely.  I think its currently just running the schema statements, so table creations fail, but dropping indexes and recreating them run.

             

            I'll look in the source for the restart JDBC tests, but can you post the names of the classes anyway?  If I find them, I'll try and run them against my Derby net server setup and see what happens.

             

            ps.  I had to fix the blob bug in the oracleJDBCAdapter.  See https://fusesource.com/forums/thread.jspa?messageID=11865⹙

            • 3. Re: Oracle JDBC store does not automatically restore queues upon restart?
              garytully

              The jdbc test I had in mind is org.apache.activemq.broker.ft.DbRestartJDBCQueueTest[1]

               

              There is a single messages table where one column is the destination name, a queue refresh is simply a select from messages with a matching destination. For an example see: org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter#doRecover

               

               

              Thanks for the feedback, the create tables, update indexes code could be tidier but to date it has been safe to simply let creating tables that already exist fail.

               

              With respect to the changes for blob support, can you reopen and attach you changes (patch) to https://issues.apache.org/jira/browse/AMQ-3289

               

              http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueTest.java?view=markup

              • 4. Re: Oracle JDBC store does not automatically restore queues upon restart?
                wmcdonald

                doRecovery was not being called. 

                 

                What I did discover is that the getInactiveDestinations() is not returning any of the destinations for the queue that is in the db because it is accessing the ACTIVEMQ_ACKS table instead of the ACTIVEMQ_MSGS table.  I don't have any topics, so there is nothing in the ACTIVEMQ_ACKS table.  However, this seems like a mistake since I think it should be getting the CONTAINER set from the ACTIVEMQ_MSGS table and not the ACTIVEMQ_ACKS table, no?  If so, then the Statements class should be changed, but for now I added the following to the OracleJDBCAdapter:

                 

                String findAllDestinationsStatement = "SELECT DISTINCT CONTAINER FROM " + statements.getFullMessageTableName();    //getFullAckTableName();

                statements.setFindAllDestinationsStatement(findAllDestinationsStatement); 

                 

                I've included two screen shots.  The first starts with RegionBroker.start() and the second is where it ends up (see the call stack) calling the Statements class.  In the second shot you can see that my fix in OracleJDBCAdapter has already overridden the default:

                           findAllDestinationsStatement = "SELECT DISTINCT CONTAINER FROM " + getFullAckTableName();

                 

                ...with the MSGS table (see variables window vs code window).

                 

                Adding this fix, the broker pulls up the queue 'myq' and message that are in the db. 

                 

                However I noticed that the Advisory queue didn't seem to load for the 'myq'.  If I Using ActiveMQBrowser, I can refresh the Destination name list, and the advisory queue shows up (I think it creates it at that time).