Liferay Microservices Communication Guide (Enterprise Architecture)

 Modern portals are no longer monolithic.

Today, Liferay acts as a digital experience layer while business logic lives in independent microservices.

This means the most important design decision becomes:

👉 How Liferay communicates with microservices

In this guide you’ll learn all production communication patterns.


📌 Why Microservices with Liferay?

Old architecture:

Portal → Database → Business Logic inside portal

Modern architecture:

Portal → APIs → Microservices → Databases

Benefits:

  • Independent deployment

  • Better scalability

  • Easier upgrades

  • Domain separation


🖼️ High Level Architecture


🧠 Communication Patterns Overview

There are 4 enterprise patterns:

  1. REST APIs (most common)

  2. Event-driven messaging

  3. GraphQL gateway

  4. Async job workers

Each has different purpose.


🔹 1️⃣ REST API Communication (Synchronous)

Best for real-time UI responses.

Example:
User updates profile → Call customer service

Liferay Java Client

URL url = new URL("http://customer-service/api/profile"); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setRequestMethod("POST"); con.getResponseCode();

Use when user waits for response.


🖼️ REST Flow


🔹 2️⃣ Event-Driven Messaging (Asynchronous)

Best for background processing.

Example:
Document upload → processing → notification

Portal publishes event → services react.

Technologies:

  • Kafka

  • RabbitMQ

Portal never waits.


🖼️ Event Driven Flow


🔹 3️⃣ GraphQL Gateway

Best for aggregating multiple services.

Instead of 5 REST calls → single query.

Benefits:

  • Faster frontend

  • Reduced network calls


🖼️ GraphQL Aggregation


🔹 4️⃣ Background Job Workers

Used for long processing tasks.

Example:
Generate PDF report
Bulk import users

Portal triggers job → worker processes later.


🖼️ Background Worker Flow


⚖️ When to Use What

ScenarioBest Pattern
User waitingREST
Heavy processingAsync events
Multiple servicesGraphQL
Long tasksWorkers

🔐 Security Considerations

Use:

  • OAuth2 / OIDC

  • API Gateway

  • Token forwarding

  • Rate limiting

Never expose services directly to internet.


🏆 Best Practices

✔ Keep portal thin
✔ No business logic in Liferay
✔ Use gateway layer
✔ Prefer async when possible
✔ Design domain-based services


⚠️ Common Mistakes

❌ Database sharing
❌ Large synchronous chains
❌ Portal orchestrating everything
❌ Tight coupling APIs


🎯 Conclusion

Liferay should act as:

👉 Experience layer only

Microservices handle business logic.

Correct communication pattern ensures scalable enterprise architecture.

Recommended Reading


💼 Professional Support Available

If you are facing issues in real projects related to enterprise backend development or workflow automation, I provide paid consulting, production debugging, project support, and focused trainings.

Technologies covered include Java, Spring Boot, PL/SQL, Azure, CMS and workflow automation (jBPM, Camunda BPM, RHPAM).

📧 Contact: ishikhanirankari@gmail.com | info@realtechnologiesindia.com

🌐 Website: IT Trainings | Digital metal podium     


Comments

Popular posts from this blog

Scopes of Signal in jBPM

OOPs Concepts in Java | English | Object Oriented Programming Explained

jBPM Installation Guide: Step by Step Setup