2 Replies Latest reply on Feb 9, 2009 7:54 AM by Amar Trnka

    Information about JBoss cache vs database

    Amar Trnka Newbie


      I'm using JBoss-4.2.2.GA and JBoss-messaging-1.4.0.SP3. I have created a new queue: 'TestQueue'. Sending messages through this queue can be stopped and started by user. User will be sending a large amount of messages trough the TestQueue. I have configured JBoss Messaging to store messages to Oracle database.

      Trick is: when sending messages is on, there is no need to store messages to database, because they just go through the queue and are consumed by the message listener (they shouldn't be stored in database because of performance issues). When sending messages is off, all new messages should be stored in the database. When sending messages service is stopping, messages that were temporarily in the memory should be stored into the database.

      Is there any configurable JBoss trick like JBoss cache or something ?
      Can you tell me if this is possible or direct me to some tutorial, link or book that could help me about this issue.

      Thank you in forward,


        • 1. Re: Information about JBoss cache vs database
          Amar Trnka Newbie

          Hi again,

          I've found the part of the solution. I've set jmsTemplate NON_PERSISTENT delivery mode for all messages that goes through the queue. I've tested for next sequent of events:

          - Set values for FullSize/PageSize/DownCacheSize on 1000/100/100 in the destinations-service.xml on the TestQueue
          - Sending messages service is stopped
          - 3000 messages are sent on the queue
          - 1000 messages are placed in the memory
          - Remaining 2000 messages are stored into the database

          Is there any mechanism that can store these 1000 messages from memory to the database when JBoss server shutdown hook is called (shutdown.sh) ?

          Another question, is there some "formula" for the best performance considering relationship between values for FullSize/PageSize/DownCacheSize ?

          • 2. Re: Information about JBoss cache vs database
            Amar Trnka Newbie

            Hi again,

            I've found a kind of solution. When JBoss server starts to shutdown it calls manually created destroy method that receives all messages from memory, set them as persistent and stores them in database. Our final problem is:

            I'll take example from previous post. First 1000 messages are in memory, next 2000 are in database. When we shutdown JBoss first 1000 messages are placed after message with id = 3000. So when we start JBoss again in memory will be messages with ids: 1001 to 2000. This is out of order and presents a huge problem to me. I've tried with JMSPriority to give messages that stores while shutting down jboss higher priority, but without effect, because JMSPriority only works when all messages are already in the memory.

            In oracle-persistence-service.xml file I've found SQLProperties, and query:


            I've tried to add ORDER BY PRIORITY DESC, but exception was thrown:

            [JDBCSupport] SQLException caught, SQLState 42000 code:933- assuming deadlock detected, try:1
            java.sql.SQLException: ORA-00933: SQL command not properly ended

            Is there any kind of solution that can sort messages from the database ?

            PS. Did I write this topic in the correct forum, because nobody is answering ? Should it be in the JBoss Messaging subsection ?