Package org.jboss.messaging.core.contract

Examples of org.jboss.messaging.core.contract.MessageReference


               }

               while (iter.hasNext())
               {
                  // We may need to persist the message itself
                  MessageReference ref = (MessageReference) iter.next();

                  // For non reliable refs we insert the ref (and maybe the
                  // message) itself

                  // Now store the reference
                   
                  log.trace("Paged ref with page order " + ref.getPagingOrder());

                  addReference(channelID, ref, psInsertReference, page);

                  int rows = psInsertReference.executeUpdate();

                  if (trace)
                  {
                     log.trace("Inserted " + rows + " rows");
                  }
                 
                  // Maybe we need to persist the message itself
                  Message m = ref.getMessage();

                  rows = storeMessage(m, psInsertMessage, psUpdateMessage);

                  if (trace)
                  {
View Full Code Here


               Iterator iter = references.iterator();

               while (iter.hasNext())
               {
                  MessageReference ref = (MessageReference) iter.next();

                  removeReference(channelID, ref, psDeleteReference);

                  int rows = psDeleteReference.executeUpdate();
View Full Code Here

               psUpdateReference = conn
                     .prepareStatement(getSQLStatement("UPDATE_PAGE_ORDER"));

               while (iter.hasNext())
               {
                  MessageReference ref = (MessageReference) iter.next();

                  psUpdateReference.setLong(1, ref.getPagingOrder());

                  psUpdateReference.setLong(2, ref.getMessage().getMessageID());

                  psUpdateReference.setLong(3, channelID);

                  int rows = psUpdateReference.executeUpdate();
View Full Code Here

               boolean first = true;

               for (Iterator i = refsToAdd.iterator(); i.hasNext();)
               {
                  ChannelRefPair pair = (ChannelRefPair) i.next();
                  MessageReference ref = pair.ref;

                  if (psReference == null)
                  {
                     psReference = conn
                           .prepareStatement(getSQLStatement("INSERT_MESSAGE_REF"));
                  }

                  // Now store the reference
                  addReference(pair.channelID, ref, psReference, false);

                  int rows = psReference.executeUpdate();

                  if (trace)
                  {
                     log.trace("Inserted " + rows + " rows");
                  }

                  Message m = ref.getMessage();

                  synchronized (m)
                  {
                     if (!m.isPersisted())
                     {
View Full Code Here

               while (iter.hasNext())
               {
                  Object obj = iter.next();

                  MessageReference ref;
                  if (obj instanceof MessageReference)
                  {
                     ref = (MessageReference) obj;
                  }
                  else
                  {
                     ref = ((ChannelRefPair) obj).ref;
                  }

                  psMessage.setLong(1, ref.getMessage().getMessageID());
                  psMessage.setLong(2, ref.getMessage().getMessageID());

                  int rows = psMessage.executeUpdate();

                  if (trace)
                  {
View Full Code Here

           boolean promptDelivery = false;

            for(Iterator i = refsToAdd.iterator(); i.hasNext(); )
            {
               MessageReference ref = (MessageReference)i.next();

               if (checkAndSchedule(ref))
               {
                 if (trace) { log.trace(this + ": scheduled " + ref); }
               }
               else
               {
                 if (trace) { log.trace(this + ": adding " + ref + " to memory"); }

                 try
                 {
                    synchronized (lock)
                    {
                       addReferenceInMemory(ref);
                    }
                 }
                 catch (Throwable t)
                 {
                    throw new TransactionException("Failed to add reference", t);
                 }

                 //Only need to prompt delivery if refs were added
                 promptDelivery = true;
               }
            }

            // Remove deliveries

            for(Iterator i = deliveriesToRemove.iterator(); i.hasNext(); )
            {
               Delivery del = (Delivery)i.next();

               if (trace) { log.trace(this + " removing " + del + " after commit"); }

               if (!del.isRecovered())
               {
                 deliveringCount.decrement();
               }
              
               MessageReference ref = del.getReference();
               if (OrderingGroupMonitor.isOrderingGroupMessage(ref))
               {
                  if (trace)
                  {
                     log.trace("Ordering group message " + ref + " has been completed, trying to send next.");
View Full Code Here

      public void afterRollback(boolean onePhase) throws Exception
      {
         //tx rolled back, we need to inform the monitor
         for(Iterator i = refsToAdd.iterator(); i.hasNext(); )
         {
            MessageReference ref = (MessageReference)i.next();
            monitor.unmarkSending(ref);
         }
      }
View Full Code Here

      // We must reference the message *before* we send it the destination to be handled. This is
      // so we can guarantee that the message doesn't disappear from the store before the
      // handling is complete. Each channel then takes copies of the reference if they decide to
      // maintain it internally

      MessageReference ref = msg.createReference();

      if (checkForDuplicates)
      {
         if (serverPeer.getPersistenceManagerInstance().idExists(msg.getJMSMessageID()))
         {
            log.trace("ID exists in ID cache, probably duplicate sent on failover");

            return false;
         }
      }

      long schedDeliveryTime = msg.getScheduledDeliveryTime();

      if (schedDeliveryTime > 0)
      {
         ref.setScheduledDeliveryTime(schedDeliveryTime);
      }

      if (dest.isDirect())
      {
         if (trace) { log.trace(this + " routing " + msg + " to direct destination"); }
        //Route directly to queue - temp kludge for clustering

        Binding binding = postOffice.getBindingForQueueName(dest.getName());

        if (binding == null)
        {
          throw new IllegalArgumentException("Cannot find binding for queue " + dest.getName());
        }

        Queue queue = binding.queue;

         Long scid = (Long)ref.getMessage().removeHeader(Message.SOURCE_CHANNEL_ID);

         Delivery del = queue.handleMove(ref, scid.longValue());

        if (del == null)
        {
View Full Code Here

          
           Iterator iter = messageRefs.iterator();
          
           while (iter.hasNext())
           {
             MessageReference ref = (MessageReference)iter.next();
            
             Message message = ref.getMessage();
            
             String sessionID = (String)toRecover.remove(new Long(message.getMessageID()));
            
             if (sessionID != null)
             {
View Full Code Here

      
       if (trace) { log.trace("Session id id " + re.sessionID); }
      
       if (re.sessionID.equals(sessionID))
       {
         MessageReference ref = re.ref;
        
         iter.remove();
        
         //Put back on queue
        
         toCancel.add(ref);                       
       }
     }
    
     for (int i = toCancel.size() - 1; i >= 0; i--)
     {
       MessageReference ref = (MessageReference)toCancel.get(i);
      
       synchronized (lock)
      {
        messageRefs.addFirst(ref, ref.getMessage().getPriority());
       
        //Need to decrement the delivery count too
        deliveringCount.decrement();
      }
             
View Full Code Here

TOP

Related Classes of org.jboss.messaging.core.contract.MessageReference

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.