Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring bot master db #420

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.finos.springbot.workflow.java.resolvers;

import java.util.Optional;

import org.finos.springbot.workflow.annotations.ChatButton;
import org.finos.springbot.workflow.java.mapping.ChatHandlerExecutor;

/**
* Get chat button detail in controller
* @author mankvaia
*
*/
public class ChatButtonWorkflowResolverFactory implements WorkflowResolverFactory {


private final class ChatButtonWorkflowResolver extends AbstractClassWorkflowResolver {
private final ChatHandlerExecutor che;

private ChatButtonWorkflowResolver(ChatHandlerExecutor che) {
this.che = che;
}

@Override
public Optional<Object> resolve(Class<?> cl) {
if (ChatButton.class.isAssignableFrom(cl) && che.getOriginatingMapping().getMapping() instanceof ChatButton) {

return Optional.of((ChatButton) che.getOriginatingMapping().getMapping());

} else {
return Optional.empty();
}
}


@Override
public boolean canResolve(Class<?> cl) {
return resolve(cl).isPresent();
}
}

@Override
public WorkflowResolver createResolver(ChatHandlerExecutor che) {
return new ChatButtonWorkflowResolver(che);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,19 @@ public FormDataArgumentWorkflowResolverFactory formDataArgumentWorkflowResolverF
return new FormDataArgumentWorkflowResolverFactory();
}

//to get Chat button detail in controller
@Bean
@ConditionalOnMissingBean
public ChatButtonWorkflowResolverFactory chatButtonWorkflowResolverFactory() {
return new ChatButtonWorkflowResolverFactory();
}

@Bean
@ConditionalOnMissingBean
public ChatVariableWorkflowResolverFactory chatVariableWorkflowResolverFactory() {
return new ChatVariableWorkflowResolverFactory();
}

@Bean
@ConditionalOnMissingBean
public AddressableWorkflowResolverFactory addressableWorkflowResolverFactory() {
Expand Down
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
Loading