You can now develop microservices and deploy them in Liferay Cloud, where they run in separate Docker containers. This makes deployment and management easy and efficient.
To demonstrate this concept, consider a scenario where the microservice ingests data from a protected route and displays it in a frontend widget. This widget is implemented as a custom element client extension, allowing seamless integration into the Liferay ecosystem. By leveraging the OAuth 2 token, the custom element client extension securely fetches and displays the protected data from the microservice, ensuring that only authorized clients can access it.
Now, we are going to integrate a Spring Boot Microservice With Liferay. This process will enable seamless communication and functionality between the two platforms, leveraging the strengths of both Spring Boot and Liferay to create a robust, scalable solution.
1. Create a client-extension.yaml in your module.
This file defines the microservice client extension project in the sample workspace. The necessary lines from the client-extension.yaml can be boiled down to:
assemble:
- fromTask: bootJar
liferay-stockfish-sample-etc-spring-boot-oauth-application-user-agent:
.serviceAddress: localhost:58081
.serviceScheme: http
name: Liferay Stockfish Sample Etc Spring Boot OAuth Application User Agent
scopes:
- Liferay.Headless.Admin.Workflow.everything
type: oAuthApplicationUserAgent
The external application/microservice is created with the bootJar command that is available from the Spring Boot Gradle Plugin. The application JAR must be included in the LUFFA for deployment in Liferay SaaS.
2. To add an action field in a workflow, you need to specify the workflowAction type, which ensures that the action is correctly configured and executed within the workflow process.
liferay-stockfish-sample-etc-spring-boot-workflow-action-1:
name: Liferay Stockfish Sample Etc Spring Boot Workflow Action 1
oAuth2ApplicationExternalReferenceCode: liferay-stockfish-sample-etc-spring-boot-oauth-application-user-agent
resourcePath: /workflow/action/1
type: workflowAction
3. To create a workflow action in Liferay, you need to develop a WorkflowActionRestController.java class file which extends BaseRestController. This file should include the request mapping specified in the configuration above (e.g., /workflow/action/1). This file will handle various workflow-related actions and facilitate interaction between the workflow engine and your Liferay application.
@RequestMapping("/workflow/action/1")
@RestController
public class WorkflowActionRestController extends BaseRestController {
// ToDo: write a code for creating workflowAction
}
And now, all that's left to do is to deploy your module. Ensure that all configurations are correctly set, and your deployment environment is prepared for a smooth and successful launch.
Here, We can see our custom workflowAction is created:
This is just one use case; the power of client extensions doesn't end here. You can utilize them in various action points, such as:
Triggering on objectAction while creating or updating an object.
Triggering on objectValidationRule to provide backend validation.
As well as in notificationType.
Liferay is adopting a distributed computing approach, offering increased flexibility in resource utilization, performance, and scalability. This evolution paves the way for more robust and efficient solutions, empowering developers to build next-generation applications.
For comprehensive business solutions and in-depth insights into Building Microservices In Liferay, connect with us at info@stockfish.app to unlock the
full potential of your digital platform.