Skip to content

Commit

Permalink
SYMPHONYP-1069-inmemory retry logger added
Browse files Browse the repository at this point in the history
  • Loading branch information
pranav-biyani-db committed Jan 10, 2024
1 parent cc95cc1 commit 12de175
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@

import org.finos.springbot.teams.content.TeamsAddressable;
import org.finos.springbot.teams.conversations.TeamsConversations;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.microsoft.bot.schema.Activity;
import com.microsoft.bot.schema.ResourceResponse;

public class InMemoryRetryingActivityHandler extends AbstractRetryingActivityHandler {

protected static final Logger LOG = LoggerFactory.getLogger(InMemoryRetryingActivityHandler.class);

static final ScheduledExecutorService SCHEDULER = new ScheduledThreadPoolExecutor(10);

public InMemoryRetryingActivityHandler(TeamsConversations tc) {
Expand All @@ -29,6 +33,9 @@ public CompletableFuture<ResourceResponse> handleActivity(Activity activity, Tea
f = f.thenApply(CompletableFuture::completedFuture).exceptionally(t -> {
if (isTooManyRequest(t)) {
int ra = getRetryAfter((CompletionException) t);

LOG.info("message inserted into InMemory Retry after {} with address id {}",ra, to.getKey());

Executor afterRetryTime = createDelayedExecutor(ra, TimeUnit.SECONDS);
return CompletableFuture.supplyAsync(() -> null, afterRetryTime)
.thenCompose(m -> tc.handleActivity(activity, to));
Expand Down

0 comments on commit 12de175

Please sign in to comment.