As applications continue to evolve toward distributed and cloud-native architectures, managing dependencies between services becomes increasingly important. Direct service-to-service communication can simplify initial development but often creates tight coupling that makes applications more difficult to scale, maintain, and extend.
When a single business transaction requires multiple downstream operations, application responsiveness may become dependent on the availability and performance of external services. This challenge becomes more significant as organizations introduce additional integrations across business and operational systems.
A common approach to addressing this challenge is to introduce a messaging layer between producers and consumers. Messages are published once and processed independently by downstream systems, allowing services to operate without requiring direct awareness of one another.
This article demonstrates how Alibaba Cloud ApsaraMQ for RocketMQ can be used to implement a decoupled application architecture that supports asynchronous processing patterns while simplifying service integration.
The proposed solution introduces ApsaraMQ for RocketMQ as an intermediary layer between application producers and downstream processing services.
Instead of directly invoking consumer applications, producers publish business events to a RocketMQ topic. The messaging platform is responsible for storing, routing, and delivering messages to subscribed consumers.
In this implementation, Function Compute is used as the downstream consumer. Whenever a new message is published to the topic, RocketMQ automatically invokes the function through a configured trigger, allowing business logic to be executed without requiring dedicated consumer infrastructure.
This architecture separates message production from message consumption, enabling services to evolve independently while supporting scalable and resilient application integration.

The architecture consists of four primary layers.
Producer Layer
The producer application generates business events and publishes messages to RocketMQ. In this example, order creation events are used to simulate application activity.
Messaging Layer
ApsaraMQ for RocketMQ acts as the central messaging backbone. Messages are durably stored within a topic and delivered to authorized consumers through a publish-subscribe model.
Consumer Layer
Function Compute serves as the event consumer. Rather than maintaining a continuously running consumer application, processing logic is executed on demand whenever messages arrive.
Observability Layer
Function execution logs provide visibility into message processing activities and serve as validation that messages are being consumed successfully.
The first step is to create an ApsaraMQ for RocketMQ instance.
After the instance is provisioned, a topic named message-processing is created to receive business events. A consumer group is then configured to identify the downstream consumer responsible for processing incoming messages.
RocketMQ Instance
Topic Configuration
Consumer Group Configuration
To demonstrate message consumption, a Function Compute Event Function was deployed as a RocketMQ subscriber.
The function receives incoming messages through the configured RocketMQ trigger and executes processing logic automatically whenever new events are published.
import logging
logger = logging.getLogger()
def handler(event, context):
logger.info("===== MESSAGE RECEIVED =====")
logger.info(f"Message Body: {event}")
return "OK"
Although this example logs incoming messages, the same implementation pattern can be extended to perform database updates, API integrations, notification delivery, workflow orchestration, or business process automation.
Function Compute Deployment
Event Processing Logic
The function receives incoming messages delivered by RocketMQ and logs the payload for validation purposes. In production environments, the same processing layer can be extended to perform downstream actions such as database updates, API integrations, notification delivery, workflow orchestration, or business process automation.
To enable automatic message consumption, a RocketMQ trigger was configured on the Function Compute function.
The trigger subscribes to the message-processing topic through the designated consumer group and automatically invokes Function Compute whenever new messages are published.
This integration enables event consumption without maintaining dedicated consumer servers or implementing custom polling mechanisms.
Trigger Configuration
From the topic management page, the Send Message option was selected to publish a test event to the message-processing topic. A Normal Message type was used to simulate a standard business event generated by an application.
{
"eventType": "OrderCreated",
"orderId": "ORD-20260612-1001",
"customerId": "CUS-10001",
"amount": 250,
"currency": "USD",
"timestamp": "2026-06-12T20:40:00Z"
}
After publication, RocketMQ stored the message and delivered it to the subscribed Function Compute consumer.
Message Publishing Test
Function Compute logs confirmed successful message delivery and processing.
FunctionCompute python3 runtime inited.
FC Invoke Start RequestId: 016AB76B2B73F600010A3DA9A400000000
2026-06-12T13:54:44.704Z 016AB76B2B73F600010A3DA9A400000000 [INFO] ===== MESSAGE RECEIVED =====
2026-06-12T13:54:44.705Z 016AB76B2B73F600010A3DA9A400000000 [INFO] Message Body: [{'msgId': '016AB76B2B73F600010A3DA9A400000000', 'topic': 'message-processing', 'systemProperties': {'MSG_REGION': 'ap-southeast-5', 'MIN_OFFSET': '0', 'UNIQ_KEY': '016AB76B2B73F600010A3DA9A400000000', 'TRACE_ON': 'true', 'PGROUP': 'message-processing', 'CLUSTER': 'rocketmq-broker-rmq-sg-ycx4tph7q02', '__BORNHOST': 'c-6a2c0f9f-048400f6-93001d17da20', 'WAIT': 'true', 'BORN_TIMESTAMP': '1781272484388', 'INSTANCE_ID': 'rmq-sg-ycx4tph7q02', 'RECONSUME_TIME': '0', 'MAX_OFFSET': '1'}, 'userProperties': {}, 'body': {'eventType': 'OrderCreated', 'orderId': 'ORD-20260612-1001', 'customerId': 'CUS-10001', 'amount': 250, 'currency': 'USD', 'timestamp': '2026-06-12T20:40:00Z'}}]
FC Invoke End RequestId: 016AB76B2B73F600010A3DA9A400000000
This validation demonstrates how RocketMQ enables producers and consumers to operate independently while maintaining reliable message delivery between application components.
**Function Execution Logs
**
ApsaraMQ for RocketMQ provides a powerful foundation for implementing decoupled application architectures on Alibaba Cloud.
By introducing a managed messaging layer between producers and consumers, organizations can reduce service dependencies, improve scalability, and simplify application integration across distributed systems. Combined with serverless consumers such as Function Compute, this architecture enables reliable asynchronous processing without requiring dedicated infrastructure management.
This architecture provides a practical foundation for building loosely coupled and scalable cloud-native applications. By leveraging managed messaging and serverless processing, organizations can implement reliable asynchronous workflows while minimizing operational complexity and infrastructure management overhead.
Transforming Retail Data into Actionable Insights with OSS and MaxCompute
6 posts | 0 followers
FollowAlibaba Cloud Native - August 6, 2024
Alibaba Cloud Native Community - May 21, 2026
Alibaba Cloud Native - December 10, 2024
Alibaba Cloud Native - August 14, 2024
Alibaba Cloud Native Community - May 18, 2026
Alibaba Cloud Community - June 14, 2024
6 posts | 0 followers
Follow
ApsaraMQ for RocketMQ
ApsaraMQ for RocketMQ is a distributed message queue service that supports reliable message-based asynchronous communication among microservices, distributed systems, and serverless applications.
Learn More
Realtime Compute for Apache Flink
Realtime Compute for Apache Flink offers a highly integrated platform for real-time data processing, which optimizes the computing of Apache Flink.
Learn More
Function Compute
Alibaba Cloud Function Compute is a fully-managed event-driven compute service. It allows you to focus on writing and uploading code without the need to manage infrastructure such as servers.
Learn More
Message Queue for Apache Kafka
A fully-managed Apache Kafka service to help you quickly build data pipelines for your big data analytics.
Learn MoreMore Posts by Della L. Wardhani