Understanding Microservice Client Extensions
Microservice client extensions are lightweight, configurable extensions that act as a proxy between Liferay and external microservices. These client extensions are standalone applications communicating with Liferay DXP via OAuth 2.0. Microservice client extensions execute actions in response to events within the Liferay instance. Instead of relying on tight coupling with internal services, this integration offers greater flexibility and agility by leveraging standards-based headless APIs. This is particularly essential for cloud-native applications and businesses requiring rapid iteration and independent scaling for their services.
Scenarios leveraging microservice client extensions include
- Creating communication channels between Liferay and external systems.
- Offloading tasks from Liferay to a secondary system.
- Prioritizing a loosely coupled architectural design.
- Empowering independent teams to maintain a cohesive overall strategy while managing their own build and release processes.
A clear understanding of microservice client extensions is key to leveraging their full potential.
Integration Using Microservice Client Extensions
Integration with microservices through client extensions occurs via REST endpoints, empowering you to consume external services directly within Liferay without implementing additional portal logic. This provides a distinct advantage over traditional OSGi modules that tightly couple with platform components.
The essential components of a microservice client extension's structure include
- A descriptor
client-extension.yaml
file for the extension. - The elements that make up the microservice.
The Liferay Sample Workspace provides example microservice client extension projects using NodeJS and Spring Boot (Java, displayed in the above screenshot), which you'll explore later in this course. While NodeJS and Spring Boot were chosen for these examples, they are just starting points. The REST-based communication of microservice client extensions empowers you to use any technology that can leverage headless API requests and responses, with adaptability to adhere to best practices of those specific technologies.
Types of Microservice Client Extension
Microservice client extensions include various types that handle business logic, manage data, integrate third-party systems, and perform other data-driven actions (depending on the type). Four primary types of microservice client extensions are:
Type | YAML Definition | Example Use Case |
---|---|---|
Object Action | type: objectAction |
Call external APIs when a custom object is created to synchronize the data with another system, such as a CRM or ERP. |
Object Validation | type: objectValidationRule |
When data is entered into an object field, start calculations and integrate with external analytics platforms to provide immediate insights on user behavior. |
Workflow Action | type: workflowAction |
Run external checks verifying with third party systems when a workflow reaches an approval stage. |
Notification Type | type: notificationType |
Send personalized emails or SMS notifications when users complete object forms, integrating with third party messaging platforms to handle the communication. |
With the exception of Cron Jobs (a separate type not described in this course), all types share the same basic execution behavior. When the extension is deployed, Liferay processes the package and registers a new client extension. These microservice extensions then hook into a Liferay process and offload tasks to the specified endpoint.
Typical use cases where microservice client extensions would be ideal include
- Enterprise System Integration: Integrating with CRM or ERP systems where sensitive data and strong authentication are essential.
- Data Processing: Handling data-intensive tasks that require secure and controlled access.
- Microservice Architectures: Managing integrations with multiple microservices that require varying levels of access.
Clarity's Microservice Client Extensions
Clarity plans to leverage microservices to offload distributor management account creation. For their use case, the microservice descriptor provides the definition for a workflow action. They’ve created a workflow managing the approval process and configured an object action to trigger on application approval. When its trigger fires during runtim, the action invokes the registered extension's REST endpoint and waits for a response. The microservice queues the object action’s request, processes it, and sends a response back to Liferay to create a new account.
By leveraging a microservice client extension for this use case, Clarity can independently develop components of its approval process using diverse technologies suitable to specific needs. These pieces are then orchestrated to achieve the overall objective, while their loose coupling ensures easy modification and scalability.
Benefits of Microservice Client Extensions
Microservice client extensions offer numerous benefits for integrating and extending Liferay DXP with external systems:
- Flexible Integration: Integrating with any system or service with microservice client extensions, regardless of their underlying technology, as long as they support REST.
- Decoupled Systems: Reducing dependencies by facilitating loose coupling between Liferay and external systems.
- Improved Maintainability: Lowering total cost of ownership and improving maintainability by enabling independent teams to work on separate microservices, promoting parallel development and efficient resource allocation.
- Maximized Technology Reuse: Leveraging existing systems and services within your current infrastructure, improving development time.
Considerations for Leveraging Microservices
Before deciding whether microservice client extensions are right for a specific use case, there are important factors to consider. These extensions are backend services with no frontend or visual element being added to Liferay. Similarly, microservice client extensions are only registered through deployment, and can't be manually added via Liferay's administration UI. Microservice client extensions are primarily suited for offloading tasks to separate systems, and are not always ideal for other integration scenarios.
Troubleshooting Microservice Client Extensions
When working with microservice client extensions, keep these specific troubleshooting suggestions in mind:
- Replace hard-coded paths and only reference injected route information.
- If observing issues related to scopes, redeploy the client extension as a first troubleshooting step.
- Intentionally avoid creating excessive API calls. Too many calls will exhaust the system's available threads, causing performance issues. Leveraging connection pooling and rate limiting will prevent thread exhaustion. Implementing GraphQL queries are another approach for resolving such issues.
Conclusion
Microservice client extensions enable flexible, agile development by leveraging standards-based headless APIs. These lightweight and configurable extensions between Liferay and external microservices handle business logic, manage data, and integrate third-party systems within your environment. Next, you'll take a closer look at the anatomy of microservice client extensions to understand how they can be built with any framework, including Spring Boot and NodeJS.
Capabilities
Product
Education
Contact Us