Skip to content

Commit

Permalink
ACS-8323 Extend the possibility to configure the event sending strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
pzhyland committed Jul 9, 2024
1 parent e5305db commit c30cc6d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public EnqueuingEventSender(Event2MessageProducer event2MessageProducer, Executo
PropertyCheck.mandatory(this, "dequeueThreadPoolExecutor", dequeueThreadPoolExecutor);
this.enqueueThreadPoolExecutor = enqueueThreadPoolExecutor;
this.dequeueThreadPoolExecutor = dequeueThreadPoolExecutor;
dequeueThreadPoolExecutor.execute(listener);
}

/**
Expand All @@ -82,6 +81,12 @@ public void accept(Callable<Optional<RepoEvent<?>>> eventProducer)
});
}

@Override
public void initialize()
{
dequeueThreadPoolExecutor.execute(listener);
}

/**
* Create listener task in charge of dequeuing and sending events ready to be sent.
* @return The task in charge of dequeuing and sending events ready to be sent.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* Copyright (C) 2005 - 2024 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
Expand Down Expand Up @@ -40,4 +40,13 @@ public interface EventSender
* @param eventProducer - callback function that creates an event
*/
void accept(Callable<Optional<RepoEvent<?>>> eventProducer);

/**
* It's called right after event sender instantiation (see {@link org.alfresco.repo.event2.EventSenderFactoryBean}).
* It might be used to initialize the sender implementation.
*/
default void initialize()
{
//no initialization by default
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ public Class<?> getObjectType()
@Override
@Nonnull
protected EventSender createInstance() throws Exception
{
EventSender sender = instantiateConfiguredSender();

sender.initialize();

return sender;
}

private EventSender instantiateConfiguredSender()
{
if (isSenderNameConfigured())
{
Expand Down

0 comments on commit c30cc6d

Please sign in to comment.