Skip to content

Commit

Permalink
Merge pull request #385 from deutschebank/spring-bot-master-db
Browse files Browse the repository at this point in the history
Retry / File State Storage
  • Loading branch information
robmoffat committed May 17, 2023
2 parents 5911655 + 9007a16 commit 4280e2f
Show file tree
Hide file tree
Showing 18 changed files with 554 additions and 311 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import org.finos.springbot.teams.conversations.TeamsConversationsConfig;
import org.finos.springbot.teams.form.TeamsFormConverter;
import org.finos.springbot.teams.form.TeamsFormDeserializerModule;
import org.finos.springbot.teams.handlers.InMemoryMessageRetryHandler;
import org.finos.springbot.teams.handlers.MessageRetryHandler;
import org.finos.springbot.teams.handlers.ActivityHandler;
import org.finos.springbot.teams.handlers.SimpleActivityHandler;
import org.finos.springbot.teams.handlers.TeamsResponseHandler;
import org.finos.springbot.teams.history.StateStorageBasedTeamsHistory;
import org.finos.springbot.teams.history.StorageIDResponseHandler;
Expand Down Expand Up @@ -75,8 +75,7 @@
ThymeleafEngineConfig.class,
AdaptiveCardConverterConfig.class,
ThymeleafConverterConfig.class,
TeamsConversationsConfig.class,
TeamsScheduledConfig.class
TeamsConversationsConfig.class
})
@Profile("teams")
public class TeamsWorkflowConfig {
Expand Down Expand Up @@ -129,16 +128,23 @@ public TeamsResponseHandler teamsResponseHandler(
AdaptiveCardTemplateProvider formTemplater,
ThymeleafTemplateProvider displayTemplater,
TeamsStateStorage th,
TeamsConversations tc,
MessageRetryHandler mr) {
ActivityHandler ah) {
return new TeamsResponseHandler(
null, // attachment handler
markupTemplater,
formTemplater,
displayTemplater,
th,
tc,
mr);
ah);
}

/**
If you want to include retry logic for activities, override this bean and return an instance of InMemoryRetryingActivityHandler
*/
@Bean
@ConditionalOnMissingBean
public ActivityHandler activityHandler(TeamsConversations tc) {
return new SimpleActivityHandler(tc);
}

@Bean
Expand Down Expand Up @@ -230,10 +236,5 @@ public void setResourceLoaderClassLoader() {
resourceLoader.setClassLoader(this.getClass().getClassLoader());
}

@Bean
@ConditionalOnMissingBean
public MessageRetryHandler messageRetryHandler() {
return new InMemoryMessageRetryHandler();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.finos.springbot.teams.handlers;

import java.util.concurrent.CompletableFuture;

import org.finos.springbot.teams.content.TeamsAddressable;

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

public interface ActivityHandler {

public CompletableFuture<ResourceResponse> handleActivity(Activity activity, TeamsAddressable to);
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.finos.springbot.teams.handlers;

import java.util.concurrent.CompletableFuture;

import org.finos.springbot.teams.content.TeamsAddressable;
import org.finos.springbot.teams.conversations.TeamsConversations;

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

public class SimpleActivityHandler implements ActivityHandler {

private TeamsConversations tc;

public SimpleActivityHandler(TeamsConversations tc) {
this.tc = tc;
}

@Override
public CompletableFuture<ResourceResponse> handleActivity(Activity activity, TeamsAddressable to) {
return tc.handleActivity(activity, to);
}

}

0 comments on commit 4280e2f

Please sign in to comment.