Package org.hornetq.core.postoffice

Examples of org.hornetq.core.postoffice.DuplicateIDCache


      for (Map.Entry<SimpleString, List<Pair<byte[], Long>>> entry : duplicateIDMap.entrySet())
      {
         SimpleString address = entry.getKey();

         DuplicateIDCache cache = postOffice.getDuplicateIDCache(address);

         if (configuration.isPersistIDCache())
         {
            cache.load(entry.getValue());
         }
      }

      return journalInfo;
   }
View Full Code Here


      try
      {
         Iterator<MessageReference> iter = iterator();
        
         DuplicateIDCache targetDuplicateCache = postOffice.getDuplicateIDCache(toAddress);
  
         while (iter.hasNext())
         {
            MessageReference ref = iter.next();
            if (filter == null || filter.match(ref.getMessage()))
            {
               boolean ignored = false;
              
               deliveringCount.incrementAndGet();
               count++;

               byte [] duplicateBytes = ref.getMessage().getDuplicateIDBytes();
               if (duplicateBytes != null)
               {
                  if (targetDuplicateCache.contains(duplicateBytes))
                  {
                     log.info("Message with duplicate ID " + ref.getMessage().getDuplicateProperty() + " was already set at " + toAddress + ". Move from " + this.address + " being ignored and message removed from " + this.address);
                     acknowledge(tx, ref);
                     ignored = true;
                  }
               }
               if (!ignored)
               {
                  move(toAddress, tx, ref, false);
               }
               iter.remove();
            }
         }
  
         List<MessageReference> cancelled = scheduledDeliveryHandler.cancel(filter);
         for (MessageReference ref : cancelled)
         {
            byte [] duplicateBytes = ref.getMessage().getDuplicateIDBytes();
            if (duplicateBytes != null)
            {
               if (targetDuplicateCache.contains(duplicateBytes))
               {
                  log.info("Message with duplicate ID " + ref.getMessage().getDuplicateProperty() + " was already set at " + toAddress + ". Move from " + this.address + " being ignored");
                  continue;
               }
            }
View Full Code Here

         LinkedListIterator<MessageReference> iter = iterator();

         try
         {

            DuplicateIDCache targetDuplicateCache = postOffice.getDuplicateIDCache(toAddress);

            while (iter.hasNext())
            {
               MessageReference ref = iter.next();
               if (filter == null || filter.match(ref.getMessage()))
               {
                  boolean ignored = false;

                  deliveringCount.incrementAndGet();
                  count++;

                  if (rejectDuplicates)
                  {
                     byte[] duplicateBytes = ref.getMessage().getDuplicateIDBytes();
                     if (duplicateBytes != null)
                     {
                        if (targetDuplicateCache.contains(duplicateBytes))
                        {
                           log.info("Message with duplicate ID " + ref.getMessage().getDuplicateProperty() +
                                    " was already set at " +
                                    toAddress +
                                    ". Move from " +
                                    this.address +
                                    " being ignored and message removed from " +
                                    this.address);
                           acknowledge(tx, ref);
                           ignored = true;
                        }
                     }
                  }

                  if (!ignored)
                  {
                     move(toAddress, tx, ref, false, rejectDuplicates);
                  }
                  iter.remove();
               }
            }

            List<MessageReference> cancelled = scheduledDeliveryHandler.cancel(filter);
            for (MessageReference ref : cancelled)
            {
               byte[] duplicateBytes = ref.getMessage().getDuplicateIDBytes();
               if (duplicateBytes != null)
               {
                  if (targetDuplicateCache.contains(duplicateBytes))
                  {
                     log.info("Message with duplicate ID " + ref.getMessage().getDuplicateProperty() +
                              " was already set at " +
                              toAddress +
                              ". Move from " +
View Full Code Here

                  // We need load the duplicate ids at prepare time too
                  DuplicateIDEncoding encoding = new DuplicateIDEncoding();

                  encoding.decode(buff);

                  DuplicateIDCache cache = postOffice.getDuplicateIDCache(encoding.address);

                  cache.load(tx, encoding.duplID);

                  break;
               }
               case ACKNOWLEDGE_CURSOR:
               {
View Full Code Here

   public void testDuplicate() throws Exception
   {
      createStorage();

      DuplicateIDCache cache = new DuplicateIDCacheImpl(new SimpleString("test"), 2000, journal, true);

      TransactionImpl tx = new TransactionImpl(journal);

      for (int i = 0 ; i < 5000; i++)
      {
         byte [] bytes = RandomUtil.randomBytes();

         cache.addToCache(bytes, tx);
      }

      tx.commit();

      tx = new TransactionImpl(journal);

      for (int i = 0 ; i < 5000; i++)
      {
         byte [] bytes = RandomUtil.randomBytes();

         cache.addToCache(bytes, tx);
      }

      tx.commit();

      byte[] id = RandomUtil.randomBytes();

      assertFalse(cache.contains(id));

      cache.addToCache(id, null);

      assertTrue(cache.contains(id));

      cache.deleteFromCache(id);

      assertFalse(cache.contains(id));

      cache.deleteFromCache(id);

   }
View Full Code Here

   public void testDuplicateNonPersistent() throws Exception
   {
      createStorage();

      DuplicateIDCache cache = new DuplicateIDCacheImpl(new SimpleString("test"), 2000, journal, false);

      TransactionImpl tx = new TransactionImpl(journal);

      for (int i = 0 ; i < 5000; i++)
      {
         byte [] bytes = RandomUtil.randomBytes();

         cache.addToCache(bytes, tx);
      }

      tx.commit();

      for (int i = 0 ; i < 5000; i++)
      {
         byte [] bytes = RandomUtil.randomBytes();

         cache.addToCache(bytes, null);
      }

   }
View Full Code Here

         LinkedListIterator<MessageReference> iter = iterator();

         try
         {

            DuplicateIDCache targetDuplicateCache = postOffice.getDuplicateIDCache(toAddress);

            while (iter.hasNext())
            {
               MessageReference ref = iter.next();
               if (filter == null || filter.match(ref.getMessage()))
               {
                  boolean ignored = false;

                  deliveringCount.incrementAndGet();
                  count++;

                  if (rejectDuplicates)
                  {
                     byte[] duplicateBytes = ref.getMessage().getDuplicateIDBytes();
                     if (duplicateBytes != null)
                     {
                        if (targetDuplicateCache.contains(duplicateBytes))
                        {
                           HornetQLogger.LOGGER.messageWithDuplicateID(ref.getMessage().getDuplicateProperty(), toAddress, address, address);
                           acknowledge(tx, ref);
                           ignored = true;
                        }
                     }
                  }

                  if (!ignored)
                  {
                     move(toAddress, tx, ref, false, rejectDuplicates);
                  }
                  iter.remove();
               }
            }

            List<MessageReference> cancelled = scheduledDeliveryHandler.cancel(filter);
            for (MessageReference ref : cancelled)
            {
               byte[] duplicateBytes = ref.getMessage().getDuplicateIDBytes();
               if (duplicateBytes != null)
               {
                  if (targetDuplicateCache.contains(duplicateBytes))
                  {
                     HornetQLogger.LOGGER.messageWithDuplicateID(ref.getMessage().getDuplicateProperty(), toAddress, address);
                     continue;
                  }
               }
View Full Code Here

      for (Map.Entry<SimpleString, List<Pair<byte[], Long>>> entry : duplicateIDMap.entrySet())
      {
         SimpleString address = entry.getKey();

         DuplicateIDCache cache = postOffice.getDuplicateIDCache(address);

         if (configuration.isPersistIDCache())
         {
            cache.load(entry.getValue());
         }
      }

      for (Pair<Long, Long> msgToDelete : pendingLargeMessages)
      {
View Full Code Here

                  // We need load the duplicate ids at prepare time too
                  DuplicateIDEncoding encoding = new DuplicateIDEncoding();

                  encoding.decode(buff);

                  DuplicateIDCache cache = postOffice.getDuplicateIDCache(encoding.address);

                  cache.load(tx, encoding.duplID);

                  break;
               }
               case ACKNOWLEDGE_CURSOR:
               {
View Full Code Here

      return pagingManager;
   }

   public DuplicateIDCache getDuplicateIDCache(final SimpleString address)
   {
      DuplicateIDCache cache = duplicateIDCaches.get(address);

      if (cache == null)
      {
         cache = new DuplicateIDCacheImpl(address, idCacheSize, storageManager, persistIDCache);

         DuplicateIDCache oldCache = duplicateIDCaches.putIfAbsent(address, cache);

         if (oldCache != null)
         {
            cache = oldCache;
         }
View Full Code Here

TOP

Related Classes of org.hornetq.core.postoffice.DuplicateIDCache

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.