Package org.jboss.messaging.core.message

Examples of org.jboss.messaging.core.message.Message


      Object[] touple = null;
      Delivery d = null;
      for (Iterator i = messages.iterator(); i.hasNext(); )
      {
         Object[] o = (Object[])i.next();
         Message m = (Message)o[0];
         if (m == r)
         {
            log.trace("*** found it");
            d = (Delivery)o[1];
            touple = o;
View Full Code Here


      Object[] touple = null;
      Delivery d = null;
      for (Iterator i = messages.iterator(); i.hasNext(); )
      {
         Object[] o = (Object[])i.next();
         Message m = (Message)o[0];
         if (m == r)
         {
            d = (Delivery)o[1];
            touple = o;
            i.remove();
View Full Code Here

                 
                  byte[] payload = getBytes(rs, 7);
                 
                  byte type = rs.getByte(8);
                 
                  Message m = MessageFactory.createMessage(messageId, reliable, expiration, timestamp, priority,
                                                           headers, payload, type);
                  msgs.add(m);
               }
              
               rs.close();
View Full Code Here

               psInsertMessage = conn.prepareStatement(getSQLStatement("INSERT_MESSAGE"));
               psUpdateMessage = conn.prepareStatement(getSQLStatement("INC_CHANNEL_COUNT"));
            }
                                                                                    
            //Maybe we need to persist the message itself
            Message m = ref.getMessage();
           
            //In a paging situation, we cannot use the persisted flag on the message to determine whether
            //to insert the message or not.
            //This is because a channel (possibly on another node) may be paging too and referencing
            //the same message, and might have removed the message independently, the other
            //channel will not know about this.
            //Therefore we have to check if the message is already in the database and insert it if it isn't
           
            //TODO This is a bit of a hassle -
            //A cleaner and better solution here is to completely separate out the paging functionality from the
            //standard persistence functionality since it complicates things considerably.
            //We should define a paging store which is separate from the persistence store, and
            //typically not using the database for the paging store - probably use a file based store
            //e.g HOWL or some other logger
           
            //Note when running this with two or more competing channels in the same process, then
            //we do not need a FOR UPDATE on the select since we lock the messages in memory
            //However for competing nodes, we do, therefore we require a database that supports
            //this, this is another reason why we cannot use HSQL in a clustered environment
            //since it does not have a for update equivalent
           
            boolean added;
           
            psMessageExists = conn.prepareStatement(getSQLStatement("MESSAGE_EXISTS"));
           
            psMessageExists.setLong(1, m.getMessageID());
           
            rsMessageExists = psMessageExists.executeQuery();
            
            if (rsMessageExists.next())
            {
View Full Code Here

            {
               psDeleteMessage = conn.prepareStatement(getSQLStatement("DELETE_MESSAGE"));
               psUpdateMessage = conn.prepareStatement(getSQLStatement("DEC_CHANNEL_COUNT"));
            }
              
            Message m = ref.getMessage();
                                   
            //Maybe we need to delete the message itself
             
            //Update the message with the new channel count
            decrementChannelCount(m, psUpdateMessage);
View Full Code Here

         PreparedStatement psReference = null;
         PreparedStatement psMessage = null;
        
         Connection conn = ds.getConnection();
        
         Message m = ref.getMessage();    
          
         try
         {           
            // Get lock on message
            LockMap.instance.obtainLock(m);
                                   
            psReference = conn.prepareStatement(getSQLStatement("INSERT_MESSAGE_REF"));
           
            // Add the reference
            addReference(channelID, ref, psReference, false);
           
            int rows = updateWithRetry(psReference);     
           
            if (trace) { log.trace("Inserted " + rows + " rows"); }
             
            if (!m.isPersisted())
            {
               // First time so persist the message
               psMessage = conn.prepareStatement(getSQLStatement("INSERT_MESSAGE"));
              
               storeMessage(m, psMessage);
              
               m.setPersisted(true);
            }
            else
            {
               //Update the message's channel count
               psMessage = conn.prepareStatement(getSQLStatement("INC_CHANNEL_COUNT"));
View Full Code Here

         PreparedStatement psUpdate = null;
         PreparedStatement psMessage = null;
        
         Connection conn = ds.getConnection();
        
         Message m = ref.getMessage();        
        
         try
         {
            //get lock on message
            LockMap.instance.obtainLock(m);
View Full Code Here

              
               psReference.close();
               psReference = null;
            }
           
            Message m = ref.getMessage();       
           
            if (!batch)
            {
               psInsertMessage = conn.prepareStatement(getSQLStatement("INSERT_MESSAGE"));
               psIncMessage = conn.prepareStatement(getSQLStatement("INC_CHANNEL_COUNT"));
            }
                        
            boolean added;
            if (!m.isPersisted())
            {              
               // First time so add message
               storeMessage(m, psInsertMessage);
               added = true;
               m.setPersisted(true);
            }
            else
            {              
               // Update message channel count
               incrementChannelCount(m, psIncMessage);
               added = false;
            }
           
            if (batch)
            {
               if (added)
               {
                  psInsertMessage.addBatch();
                  if (trace) { log.trace("Message does not already exist so inserting it"); }
                  messageInsertsInBatch = true;
               }
               else
               {
                  if (trace) { log.trace("Message already exists so updating count"); }
                  psIncMessage.addBatch();
                  messageUpdatesInBatch = true;
               }
            }
            else
            {
               if (added)
               {
                  if (trace) { log.trace("Message does not already exist so inserting it"); }
                  int rows = updateWithRetry(psInsertMessage);
                  if (trace) { log.trace("Inserted " + rows + " rows"); }
               }
               else
               {
                  if (trace) { log.trace("Message already exists so updating count"); }
                  int rows = updateWithRetry(psIncMessage);
                  if (trace) { log.trace("Updated " + rows + " rows"); }
               }
               psInsertMessage.close();
               psInsertMessage = null;
               psIncMessage.close();
               psIncMessage = null;
            }
         }        
        
         if (batch)
         {
            // Process the add batch

            int[] rowsReference = updateWithRetryBatch(psReference);
           
            if (trace) { logBatchUpdate(getSQLStatement("INSERT_MESSAGE_REF"), rowsReference, "inserted"); }
           
            if (messageInsertsInBatch)
            {
               int[] rowsMessage = updateWithRetryBatch(psInsertMessage);
               if (trace) { logBatchUpdate(getSQLStatement("INSERT_MESSAGE"), rowsMessage, "inserted"); }
            }

            if (messageUpdatesInBatch)
            {
               int[] rowsMessage = updateWithRetryBatch(psIncMessage);
               if (trace) { logBatchUpdate(getSQLStatement("INC_CHANNEL_COUNT"), rowsMessage, "updated"); }
            }
           
            psReference.close();
            psReference = null;
            psInsertMessage.close();
            psInsertMessage = null;
            psIncMessage.close();
            psIncMessage = null;
         }
        
         // Now the removes

         psReference = null;
         psDeleteMessage = null;
         batch = usingBatchUpdates && refsToRemove.size() > 0;

         if (batch)
         {
            psReference = conn.prepareStatement(getSQLStatement("DELETE_MESSAGE_REF"));
            psDeleteMessage = conn.prepareStatement(getSQLStatement("DELETE_MESSAGE"));
            psDecMessage = conn.prepareStatement(getSQLStatement("DEC_CHANNEL_COUNT"));
         }

        
         for(Iterator i = refsToRemove.iterator(); i.hasNext(); )
         {
            ChannelRefPair pair = (ChannelRefPair)i.next();
           
            if (!batch)
            {
               psReference = conn.prepareStatement(getSQLStatement("DELETE_MESSAGE_REF"));
            }
           
            removeReference(pair.channelID, pair.ref, psReference);
           
            if (batch)
            {
               psReference.addBatch();
            }
            else
            {
               int rows = updateWithRetry(psReference);
               if (trace) { log.trace("Deleted " + rows + " rows"); }
               psReference.close();
               psReference = null;
            }
           
            if (!batch)
            {
               psDeleteMessage = conn.prepareStatement(getSQLStatement("DELETE_MESSAGE"));
               psDecMessage = conn.prepareStatement(getSQLStatement("DEC_CHANNEL_COUNT"));
            }
           
            Message m = pair.ref.getMessage();
                               
            // Update the channel count
           
            decrementChannelCount(m, psDecMessage);
           
View Full Code Here

            {
               psDeleteMessage = conn.prepareStatement(getSQLStatement("DELETE_MESSAGE"));
               psUpdateMessage = conn.prepareStatement(getSQLStatement("DEC_CHANNEL_COUNT"));
            }
           
            Message m = ref.getMessage();
                                  
            //We may need to remove the message itself
           
            //Update the channel count
           
View Full Code Here

            {
               psInsertMessage = conn.prepareStatement(getSQLStatement("INSERT_MESSAGE"));
               psUpdateMessage = conn.prepareStatement(getSQLStatement("INC_CHANNEL_COUNT"));
            }
           
            Message m = pair.ref.getMessage();
                  
            boolean added;        
           
            if (!m.isPersisted())
            {
               //First time so persist the message
               storeMessage(m, psInsertMessage);
              
               m.setPersisted(true);
              
               added = true;
            }
            else
            {
View Full Code Here

TOP

Related Classes of org.jboss.messaging.core.message.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.