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

APP-2814 SpringBoot Starter setup #186

Merged
merged 15 commits into from
Aug 28, 2020

Conversation

thibauult
Copy link
Member

@thibauult thibauult commented Aug 26, 2020

Description

This PR brings a very first integration of the BDK Core layer within a SpringBoot Starter module. Also, a BOM module (symphony-bdk-bom) has been created in order to simplify dependency management across the BDK project.

Example

An example application have been created in order to demonstrate how to implement a very simple Request/Reply Bot using the BDK SpringBoot Starter.

Only 2 files are required in order to setup the application:

  • an application.yaml that contains the configuration of the Symphony environment (e.g. BdkConfig)
  • a RequestReplyApplication.java main class that contains the Bot business logic

application.yaml

bdk:
   host: devx1.symphony.com
   bot:
    username: tibot
    privateKey: ${user.home}/local/conf/agent/privateKey.pem

RequestReplyApplication.java

@SpringBootApplication
public class RequestReplyApplication implements RealTimeEventsListener {

  @Autowired
  private MessageService messageService;

  @Override
  public void onMessageSent(V4MessageSent event) {
    this.messageService.send(event.getMessage().getStream(),"<messageML>Hello, from Spring!</messageML>");
  }

  public static void main(String[] args) { SpringApplication.run(RequestReplyApplication.class, args); }
} 

@thibauult thibauult changed the title [DRAFT] APP-2814 SpringBoot Module setup [DRAFT] APP-2814 SpringBoot Starter setup Aug 26, 2020
…ot-module-setup

# Conflicts:
#	symphony-bdk-core/src/main/java/com/symphony/bdk/core/SymphonyBdk.java
#	symphony-bdk-core/src/main/java/com/symphony/bdk/core/client/ApiClientFactory.java
@@ -0,0 +1,15 @@
domain: devx1.symphony.com
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on reusing the same format

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idea for later, provide properties documentation with https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-configuration-metadata.html
and validation with javax.validation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

symphony-bdk-bom/pom.xml Outdated Show resolved Hide resolved
symphony-bdk-bom/pom.xml Outdated Show resolved Hide resolved
* </p>
*
* <p>
* Those beans are not intended to be used by end-developers. They are injected into the Spring application context
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case do we want to make them bean and put them in the context? (vs creating them manually where needed, i.e in BdkServiceConfig

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that : "just in case", I'd feel more confident to have them injected in the context.

Actually, I already imagine a customer request saying: "oh we need to call this API (such as DLP, Security...) but the service does not already exists". In this situation we could easily reply by : OK you just have to inject this bean and this bean and you'll be able to proceed to the API call, the service layer will come later.

Maybe I should refine this Javadoc comment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I'll guess we won't document that they exist then

* Asynchronous execution of the {@link DatafeedService#start()} method.
*/
public void start() {
Executors.newSingleThreadExecutor().submit(() -> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to make stacktraces easier to read we would use Thread.currentThread().setName(); (or use a custom thread factory) to set a meaningful thread's name

@symphony-youri
Copy link
Contributor

Do you keep a wish list somewhere for the BDK where we could track ideas and improvements?

…ot-module-setup

# Conflicts:
#	symphony-bdk-core/src/main/java/com/symphony/bdk/core/SymphonyBdk.java
#	symphony-bdk-core/src/main/java/com/symphony/bdk/core/auth/impl/BotAuthenticatorRsaImpl.java
@thibauult thibauult marked this pull request as ready for review August 27, 2020 18:23
@thibauult thibauult requested a review from a team August 27, 2020 18:23
@thibauult thibauult changed the title [DRAFT] APP-2814 SpringBoot Starter setup APP-2814 SpringBoot Starter setup Aug 27, 2020
@thibauult thibauult removed the request for review from symphonydarlys August 28, 2020 07:07
Copy link
Contributor

@symphony-hong symphony-hong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@thibauult thibauult merged commit c1c7e71 into finos:master Aug 28, 2020
@thibauult thibauult deleted the APP-2814_SpringBoot-module-setup branch August 28, 2020 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants