[ 
https://issues.apache.org/jira/browse/ARTEMIS-2504?focusedWorklogId=318677&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-318677
 ]

ASF GitHub Bot logged work on ARTEMIS-2504:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/Sep/19 01:07
            Start Date: 26/Sep/19 01:07
    Worklog Time Spent: 10m 
      Work Description: michaelandrepearce commented on pull request #2850: 
ARTEMIS-2504 implement retroactive addresses
URL: https://github.com/apache/activemq-artemis/pull/2850#discussion_r328398850
 
 

 ##########
 File path: 
artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
 ##########
 @@ -467,6 +478,83 @@ private boolean internalAddressInfo(AddressInfo 
addressInfo, boolean reload) thr
       }
    }
 
+   private void registerRepositoryListenerForRetroactiveAddress(SimpleString 
name) {
+      HierarchicalRepositoryChangeListener repositoryChangeListener = () -> {
+         String prefix = server.getConfiguration().getInternalNamingPrefix();
+         String address = 
ResourceNames.decomposeRetroactiveResourceName(prefix, name.toString(), 
ResourceNames.ADDRESS);
+         AddressSettings settings = 
addressSettingsRepository.getMatch(address);
+         Queue internalQueue = 
server.locateQueue(ResourceNames.getRetroactiveResourceName(prefix, 
SimpleString.toSimpleString(address), ResourceNames.QUEUE));
+         if (internalQueue != null && internalQueue.getRingSize() != 
settings.getRetroactiveMessageCount()) {
+            internalQueue.setRingSize(settings.getRetroactiveMessageCount());
+         }
+      };
+      addressSettingsRepository.registerListener(repositoryChangeListener);
+      
server.getAddressInfo(name).setRepositoryChangeListener(repositoryChangeListener);
+   }
+
+   private void createRetroactiveResources(final SimpleString 
retroactiveAddressName, final long retroactiveMessageCount, final boolean 
reload) throws Exception {
+      String prefix = server.getConfiguration().getInternalNamingPrefix();
+      final SimpleString internalAddressName = 
ResourceNames.getRetroactiveResourceName(prefix, retroactiveAddressName, 
ResourceNames.ADDRESS);
+      final SimpleString internalQueueName = 
ResourceNames.getRetroactiveResourceName(prefix, retroactiveAddressName, 
ResourceNames.QUEUE);
+      final SimpleString internalDivertName = 
ResourceNames.getRetroactiveResourceName(prefix, retroactiveAddressName, 
ResourceNames.DIVERT);
+
+      if (!reload) {
+         AddressInfo addressInfo = new 
AddressInfo(internalAddressName).addRoutingType(RoutingType.ANYCAST).setInternal(true);
+         addAddressInfo(addressInfo);
+         server.createQueue(internalAddressName,
+                            RoutingType.ANYCAST,
+                            internalQueueName,
+                            null,
+                            null,
+                            true,
+                            false,
+                            false,
+                            false,
+                            false,
+                            0,
+                            false,
+                            false,
+                            false,
+                            0,
+                            null,
+                            false,
+                            null,
+                            false,
+                            0,
+                            0L,
+                            false,
+                            0L,
+                            0L,
+                            false,
+                            retroactiveMessageCount);
+      }
+      server.deployDivert(new DivertConfiguration()
+                             .setName(internalDivertName.toString())
+                             .setAddress(retroactiveAddressName.toString())
+                             .setExclusive(false)
+                             
.setForwardingAddress(internalAddressName.toString())
+                             
.setRoutingType(ComponentConfigurationRoutingType.STRIP));
+   }
+
+   private void removeRetroactiveResources(SimpleString address) throws 
Exception {
+      String prefix = server.getConfiguration().getInternalNamingPrefix();
+
+      SimpleString internalDivertName = 
ResourceNames.getRetroactiveResourceName(prefix, address, ResourceNames.DIVERT);
 
 Review comment:
   Why divert and separate address is needed. Why not have the retro queue 
under the original address?
   With having separate address will mean message has to be copied rather than 
it simply being a message reference to existing message.
   
   Also adds more risk in what if divert or other address dont clean up cleanly 
etc.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 318677)
    Time Spent: 1.5h  (was: 1h 20m)

> Support retroactive addresses
> -----------------------------
>
>                 Key: ARTEMIS-2504
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-2504
>             Project: ActiveMQ Artemis
>          Issue Type: New Feature
>            Reporter: Justin Graham Bertram
>            Assignee: Justin Graham Bertram
>            Priority: Major
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to