Why RocketMQ’s Ordinary Messages Power Business Integration
This article explains how RocketMQ’s ordinary messages meet the core demands of business integration, detailing their architecture, lifecycle, key features, typical use cases, and practical code examples for sending and consuming messages.
Business Integration vs. Data Integration
Business integration focuses on real‑time order flow, millisecond‑level latency, and tightly coupled service interactions. Data integration emphasizes aggregation and analysis of heterogeneous data sources, tolerating near‑real‑time or batch processing.
Core Messaging Requirements for Business Integration
Support for multiple message types: ordinary, scheduled, transactional, ordered.
Rich routing: tag filtering, attribute filtering, one‑to‑many and one‑to‑one dispatch.
Various interaction modes: synchronous, asynchronous, push‑pull, streaming responses.
Observability: metrics, tracing, events, full‑link tracing, alerts.
Ordinary Message Fundamentals
Ordinary messages are the simplest and most widely used RocketMQ message type, offering high throughput, horizontal scalability, low latency, and asynchronous communication.
Key Characteristics
Atomic processing – each message is independent.
Scalable – multiple queues, horizontal sharding, concurrent consumption.
Low latency – short processing path enables millisecond‑level delivery.
Message Lifecycle
Initialization : Producer constructs the message (topic, tag, key, payload) and sends it.
Pending consumption : Broker stores the message and makes it visible to consumers.
Consuming : Consumer fetches the message; if no ack is received, the broker retries.
Consume‑ack : Consumer acknowledges success or failure; the message remains retained for possible replay.
Deletion : After the configured retention period, the broker physically removes the message.
Typical Use Cases
Microservice decoupling – asynchronous calls reduce response time and smooth traffic spikes.
Real‑time data transmission – high‑throughput pipelines for telemetry, logs, or event streams.
Case Study: E‑commerce Transaction Platform
During large‑scale sales events, RocketMQ ordinary messages decouple order processing, payment, logistics, and inventory systems. The architecture must handle complex order state machines, massive order spikes, and ensure transactional consistency across services.
Practical Code Walkthrough
Sending an Ordinary Message
Key steps:
Fully initialize the message with topic, tag, key, and payload.
Capture the send result and handle exceptions for retry logic.
Message msg = new Message("TopicTest", "TagA", "Key123", "Hello RocketMQ".getBytes());
SendResult result = producer.send(msg);
System.out.printf("Send status: %s, msgId: %s%n", result.getSendStatus(), result.getMsgId());Consuming an Ordinary Message
RocketMQ provides two consumption models:
Passive listener – register a MessageListenerConcurrently (or Orderly) and return ConsumeConcurrentlyStatus.CONSUME_SUCCESS on success; throw an exception or return RECONSUME_LATER to trigger retry.
Active pull – use DefaultMQPullConsumer to pull messages on demand, allowing custom rate‑limiting and concurrency control.
DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("ConsumerGroupA");
consumer.subscribe("TopicTest", "*");
consumer.registerMessageListener((msgs, context) -> {
for (MessageExt msg : msgs) {
System.out.println(new String(msg.getBody()));
}
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
});
consumer.start();Observability Features
RocketMQ integrates metrics, tracing, and event reporting. It supports single‑link and full‑link traceability, enabling monitoring dashboards and alerting for latency, throughput, and error rates.
Future Outlook
Alibaba Cloud plans to release RocketMQ 5.0, which will provide higher elasticity, lower cost, and simplified operations, further strengthening its suitability for mission‑critical business integration scenarios.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Alibaba Cloud Native
We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
