Can RabbitMQ Lose Messages Under Network Packet Loss? A 50‑Hour Real‑World Test

This article details a 50‑hour experiment that simulates network packet loss between geographically separated RabbitMQ clusters and clients, showing how packet drops affect ACKs, socket buffers, and latency, and ultimately demonstrating that no messages were lost during the test.

Vipshop Quality Engineering
Vipshop Quality Engineering
Vipshop Quality Engineering
Can RabbitMQ Lose Messages Under Network Packet Loss? A 50‑Hour Real‑World Test

With Vipshop's international expansion, RabbitMQ clusters are deployed in China while applications run abroad, communicating over VPNs. Network bandwidth limits, latency, and congestion can cause ACK timeouts, leading to socket buffer buildup and TCP disconnects, raising concerns about possible message loss.

Deployment Architecture

The test simulates two parties in different IDC locations, with the RabbitMQ cluster and client placed in separate data centers.

Network Packet Loss Simulation

Using Linux iptables, packets destined for port 5672 are dropped without response, simulating network loss.

iptables -A OUTPUT -p tcp --sport 5672 -j DROP
iptables -A INPUT -p tcp --dport 5672 -j DROP

After applying the rules, the sender's socket send buffer fills with packets, as shown in the following screenshot.

Test Execution

Sender

The sender generates globally unique messages by appending an atomic counter to a fixed payload.

private static final MSG = "abcdefghijklmnopqrstuvwxyzQWERTYUIOPLKJHGFDSAZXCVBNM~@#¥%%&*";
public static AtomicInteger msgCount = new AtomicInteger(0);
/**
 * Generate message content of given length
 */
public static String genMsgContent(int length) {
    Random random = new Random();
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < length; i++) {
        int number = random.nextInt(base.length());
        sb.append(base.charAt(number));
    }
    return sb.toString();
}
@Override
public void run() {
    String msgCurrent = genMsgContent(1024); // 1K payload
    msgCurrent = msgCurrent + "-" + msgCount.getAndIncrement();
    MessageWrap msg = new MessageWrap(msgCurrent.getBytes());
    // ... send message ...
    LOGGER.error("publish msg failed:" + new String(msg.getPayload()));
}

Consumer

The consumer receives messages, extracts the numeric part, and logs it.

@Override
public void run() {
    ISubscriber sub = vmsclient.newSubscriber(queueName, "");
    sub.registerListener(new IVMSCallback() {
        @Override
        public ConsumeStatus consumeMessage(VmsConsumerContext context, VMSEventArgs e) {
            context.setDelayLevelWhenReconsume(1);
            try {
                String tmpMsg = new String(e.getMessage().getPayload());
                String mString = tmpMsg.split("-")[1];
                LOGGER.error("consumer msg info " + mString);
            } catch (Throwable e1) {
                LOGGER.error("consumes msg error:" + e1.getMessage());
            }
            return null;
        }
    });
    sub.start();
}

Test Results

The test ran for 50 hours, initiating a 3‑minute packet‑loss simulation every five minutes. Logs from both the sender (failed sends) and the consumer (received messages) were collected and compared, yielding the table below.

End‑to‑end latency at the 99.99th percentile is high because during the 3‑minute network outage the client stops consuming, causing messages to accumulate in the queue; consumption resumes once the network recovers, leading to large latency spikes.

The results show that RabbitMQ did not lose any messages during the entire test; every message logged as successfully sent was also consumed.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaMessage QueueRabbitMQNetwork Packet Loss
Vipshop Quality Engineering
Written by

Vipshop Quality Engineering

Technology exchange and sharing for quality engineering

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.