Examples of DuplicateIDCache


Examples of org.hornetq.core.postoffice.DuplicateIDCache

         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

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

Examples of org.hornetq.core.postoffice.DuplicateIDCache

                  // 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

Examples of org.hornetq.core.postoffice.DuplicateIDCache

                  // 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

Examples of org.hornetq.core.postoffice.DuplicateIDCache

      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

Examples of org.hornetq.core.postoffice.DuplicateIDCache

      if (bridgeDup != null)
      {
         // if the message is being sent from the bridge, we just ignore the duplicate id, and use the internal one
         byte[] bridgeDupBytes = (byte[])bridgeDup;

         DuplicateIDCache cacheBridge = getDuplicateIDCache(BRIDGE_CACHE_STR.concat(message.getAddress()));

         if (cacheBridge.contains(bridgeDupBytes))
         {
            StringBuffer warnMessage = new StringBuffer();
            warnMessage.append("Duplicate message detected through the bridge - message will not be routed. Message information:\n");
            warnMessage.append(message.toString());
            PostOfficeImpl.log.warn(warnMessage.toString());

            if (context.getTransaction() != null)
            {
               context.getTransaction().markAsRollbackOnly(new HornetQException(HornetQException.DUPLICATE_ID_REJECTED, warnMessage.toString()));
            }

            message.decrementRefCount();

            return false;
         }
         else
         {
            if (context.getTransaction() == null)
            {
               context.setTransaction(new TransactionImpl(storageManager));
               startedTX.set(true);
            }
         }

         cacheBridge.addToCache(bridgeDupBytes, context.getTransaction());

         message.removeProperty(MessageImpl.HDR_BRIDGE_DUPLICATE_ID);

      }
      else
      {
         // if used BridgeDuplicate, it's not going to use the regular duplicate
         // since this will would break redistribution (re-setting the duplicateId)
         byte[] duplicateIDBytes = message.getDuplicateIDBytes();
  
         DuplicateIDCache cache = null;
  
         boolean isDuplicate = false;
  
         if (duplicateIDBytes != null)
         {
            cache = getDuplicateIDCache(message.getAddress());
  
            isDuplicate = cache.contains(duplicateIDBytes);
  
            if (rejectDuplicates && isDuplicate)
            {
               String warnMessage = "Duplicate message detected - message will not be routed. Message information:" + message.toString();
               PostOfficeImpl.log.warn(warnMessage);
  
               if (context.getTransaction() != null)
               {
                  context.getTransaction().markAsRollbackOnly(new HornetQException(HornetQException.DUPLICATE_ID_REJECTED, warnMessage));
               }
  
               message.decrementRefCount();
  
               return false;
            }
         }
  
         if (cache != null && !isDuplicate)
         {
            if (context.getTransaction() == null)
            {
               // We need to store the duplicate id atomically with the message storage, so we need to create a tx for this
               context.setTransaction(new TransactionImpl(storageManager));
  
               startedTX.set(true);
            }
  
            cache.addToCache(duplicateIDBytes, context.getTransaction());
         }
      }

      return true;
   }
View Full Code Here

Examples of org.hornetq.core.postoffice.DuplicateIDCache

   public synchronized int moveReferences(final int flushLimit, final Filter filter,
                                          final SimpleString toAddress,
                                          final boolean rejectDuplicates) throws Exception
   {
      final DuplicateIDCache targetDuplicateCache = postOffice.getDuplicateIDCache(toAddress);

      return iterQueue(flushLimit, filter, new QueueIterateAction()
      {
         @Override
         public void actMessage(Transaction tx, MessageReference ref) throws Exception
         {
            boolean ignored = false;

            deliveringCount.incrementAndGet();

            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 " +
View Full Code Here

Examples of org.hornetq.core.postoffice.DuplicateIDCache

               ids[i] = iterator.next().getMessage().getMessageID();
            }

            iterator.close();

            DuplicateIDCache duplicateTargetCache = server1.getPostOffice()
                                                           .getDuplicateIDCache(PostOfficeImpl.BRIDGE_CACHE_STR.concat(forwardAddress));

            TransactionImpl tx = new TransactionImpl(server1.getStorageManager());
            for (long id : ids)
            {
               byte[] duplicateArray = BridgeImpl.getDuplicateBytes(server0.getNodeManager().getUUID(), id);
               duplicateTargetCache.addToCache(duplicateArray, tx);
            }
            tx.commit();
         }

         Thread.sleep(1000);
View Full Code Here

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

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());
         }
      }

      for (Pair<Long, Long> msgToDelete : pendingLargeMessages)
      {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.