Package org.jboss.messaging.core.message

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


  
   private void moveInTransaction(JBossMessage msg, Delivery del, Queue queue) throws Throwable
   {
      Transaction tx = tr.createTransaction();
     
      MessageReference ref = ms.reference(msg);
                      
      try
      {              
         if (queue != null)
         {                                                      
            queue.handle(null, ref, tx);
            del.acknowledge(tx);
         }
         else
         {
            log.warn("Cannot move to destination since destination has not been deployed! " +
               "The message will be removed");
           
            del.acknowledge(tx);
         }            
        
         tx.commit();        
      }
      catch (Throwable t)
      {
         tx.rollback();
         throw t;
      }
      finally
      {
         if (ref != null)
         {
            ref.releaseMemoryReference();
         }
      }
     
      //Need to prompt delivery on the dlq/expiry queue
     
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 = null;
     
      try
      {        
         ref = ms.reference(msg);
        
         long schedDeliveryTime = msg.getScheduledDeliveryTime();
        
         if (schedDeliveryTime > 0)
         {
            ref.setScheduledDeliveryTime(schedDeliveryTime);
         }
        
         if (dest.isQueue())
         {
            if (!postOffice.route(ref, new JMSCondition(true, dest.getName()), tx))
            {
               throw new JMSException("Failed to route " + ref + " to " + dest.getName());
            }
         }
         else
         {
            postOffice.route(ref, new JMSCondition(false, dest.getName()), tx);  
         }
      }
      finally
      {
         if (ref != null)
         {
            ref.releaseMemoryReference();
         }
      }
        
      if (trace) { log.trace("sent " + msg); }
   }
View Full Code Here

      //    Send 100 more refs then roll back
      tx = this.createXATx();
      for (int i = 200; i < 300; i++)
      {
         Message m = CoreMessageFactory.createCoreMessage(i, true, null);
         MessageReference ref = ms.reference(m);
         queue.handle(null, ref, tx);       
         ref.releaseMemoryReference();
     
      tx.prepare();
      tx.rollback();
     
     
View Full Code Here

      Condition routingKey = conditionFactory.createCondition(routingKeyText);

      lock.readLock().acquire();

      // Need to reference the message
      MessageReference ref = null;
      try
      {
         if (message.isReliable())
         {
            // It will already have been persisted on the sender's side
            message.setPersisted(true);
         }

         ref = ms.reference(message);

         // We route on the condition
         DefaultClusteredBindings cb = (DefaultClusteredBindings)conditionMap.get(routingKey);

         if (cb != null)
         {
            Collection bindings = cb.getAllBindings();

            Iterator iter = bindings.iterator();

            while (iter.hasNext())
            {
               Binding binding = (Binding)iter.next();

               if (binding.getNodeID() == this.currentNodeId)
               {
                  boolean handle = true;

                  if (queueNameNodeIdMap != null)
                  {
                     Integer in = (Integer)queueNameNodeIdMap.get(binding.getQueue().getName());

                     //When there are more than one queues with the same name across the cluster we only
                     //want to chose one of them

                     if (in != null)
                     {
                        handle = in.intValue() == currentNodeId;
                     }
                  }

                  if (handle)
                  {
                     //It's a local binding so we pass the message on to the subscription

                     LocalClusteredQueue queue = (LocalClusteredQueue)binding.getQueue();

                     Delivery del = queue.handleFromCluster(ref);

                     if (trace)
                     {
                        log.trace(this.currentNodeId + " queue " + queue.getName() + " handled reference from cluster " + del);
                     }
                  }
               }
            }
         }
      }
      finally
      {
         if (ref != null)
         {
            ref.releaseMemoryReference();
         }
         lock.readLock().release();
      }
   }
View Full Code Here

      //    Send 100 more refs then roll back
      tx = this.createXATx();
      for (int i = 200; i < 300; i++)
      {
         Message m = CoreMessageFactory.createCoreMessage(i, true, null);
         MessageReference ref = ms.reference(m);
         queue.handle(null, ref, tx);      
         ref.releaseMemoryReference();
     
      tx.prepare();
      tx.rollback();
     
     
View Full Code Here

      tx = tr.createTransaction();
     
      for (int i = 200; i < 300; i++)
      {
         Message m = CoreMessageFactory.createCoreMessage(i, true, null);
         MessageReference ref = ms.reference(m);
         queue.handle(null, ref, tx);    
         ref.releaseMemoryReference();
     
      tx.rollback();
  
     
      //Send 10 more refs
View Full Code Here

      //Send 100 more refs then roll back
      tx = tr.createTransaction();
      for (int i = 200; i < 300; i++)
      {
         Message m = CoreMessageFactory.createCoreMessage(i, true, null);
         MessageReference ref = ms.reference(m);
         queue.handle(null, ref, tx);        
         ref.releaseMemoryReference();
     
      tx.rollback();
     
     
      //Send 10 more refs
View Full Code Here

           
            //We only get the delivery if receiversReady = false so as not to steal messages that
            //might be consumed by local receivers           
            if (!receiversReady)
            {                 
               MessageReference ref;
              
               synchronized (refLock)
               {
                  ref = removeFirstInMemory();
                 
View Full Code Here

               //It will already have been persisted on the other node
               //so we need to set the persisted flag here
               message.setPersisted(true);
            }
           
            MessageReference ref = null;
              
            try
            {
               ref = ms.reference(message);
              
               Delivery delRet = handleInternal(null, ref, tx, true);

               if (delRet == null || !delRet.isSelectorAccepted())
               {
                  //This should never happen
                  throw new IllegalStateException("Queue did not accept reference!");
               }           
            }
            finally
            {
               if (ref != null)
               {
                  ref.releaseMemoryReference();
               }
            }
                      
            //Acknowledge on the remote queue stub
            Delivery del = new SimpleDelivery(remoteQueue, ref);
View Full Code Here

   {
      static MessageOrderComparator instance = new MessageOrderComparator();
     
      public int compare(Object o1, Object o2)
      {       
         MessageReference ref1 = (MessageReference)o1;
         MessageReference ref2 = (MessageReference)o2;

         long id1 = ref1.getMessage().getMessageID();        
         long id2 = ref2.getMessage().getMessageID();
        
         return (id1 < id2 ? -1 : (id1 == id2 ? 0 : 1));
      }     
View Full Code Here

TOP

Related Classes of org.jboss.messaging.core.message.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.