This post was first posted by Yanglbme on GitHub’s Doocs (stars over 30K). Project address: github.com/doocs/advan…

Message queue interview scenario

Interviewer: Hello.

Candidate: Hello.

(The interviewer saw on your resume, oops, there’s a highlight, you used MQ in a project, like ActiveMQ)

Interviewer: Have you ever used message queues in your system? (The interviewer begins the interview in an easygoing tone.)

Candidate: Used (feels fine at the moment)

Interviewer: Can you tell me how you used message queues in your projects?

Candidate: Blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah. For example, we have an order system. Every time a new order is placed, the order system sends a message to ActiveMQ, and there is an inventory system in the background that gets the message and updates the inventory.”

(Some of you are getting into a mistake here, where you just know and answer how you use the message queue, what you do with it?)

Interviewer: Then why do you use message queues? Instead of sending a message to MQ, your order system calls an interface to the inventory system, clicks it, and the inventory is updated.

Candidate: Uh… (Pause, why? I didn’t how carefully thought over, the eldest brother let use), hard head of head gibberish a few words.

(The interviewer listens for a moment, then hears some gibberish and begins to wonder if you haven’t thought about it before.)

Interviewer: What are the advantages and disadvantages of using message queues?

(You haven’t given much thought to why you should use MQ in your project, so I’ll make it a little simpler and ask you if you’ve given any thought to the advantages and disadvantages of using message queues.)

Candidate: Well… (I really don’t think much about this at ordinary times… Gibberish)

(The interviewer already thinks you’re a bad guy and you don’t think much.)

Interviewer: What is the difference between Kafka, ActiveMQ, RabbitMQ and RocketMQ?

(The interviewer is asking you this question, which means bypassing the more mundane topics and going straight to see if you know, have done your homework, and have done your research on various MQ middleware.)

Candidate: We’ve used ActiveMQ, so we haven’t used anything else… The difference is not so clear…

(The interviewer will think that you are a fool and have no thought at all.)

Interviewer: So how do you ensure that message queues are highly available?

Candidate: Well… I usually just go through the API call, not quite sure how the message queue is deployed…

Interviewer: How to ensure that messages are not re-consumed? How do you ensure that consumption is idempotent?

Candidate: What? (MQ is not write & consume can be, why so many problems)

Interviewer: How to ensure the reliable transmission of messages? What if the message gets lost?

Candidate: We don’t lose a lot of messages…

Interviewer: How do you ensure that the messages are sequential?

Candidate: Sequential? What do you mean? Why should I keep my messages sequential? Doesn’t it have an order?

Interviewer: How to solve message queue delay and expiration issues? What happens when the message queue is full? There are millions of messages waiting for hours. How do you fix them?

Candidate: No, I don’t have these problems in my life, just to use it briefly and know some of the functions of MQ.

Interviewer: If you were to write a message queue, how would you structure it? Tell me what you think.

Candidate:… I’d better go…

Scenario analysis

This is an interview style in which the interviewer’s questions do not spread out, but spread out slowly from a small point. For example, the interviewer may want to talk to you about high concurrency. In this topic, they will talk to you about caching, MQ, etc.

In fact, the above is a very typical technical investigation process about the message queue, the good interviewer will start from a point you have done, and then expand the in-depth investigation, one question after another, until the technical point down to the bottom.

All the answers you need are here

  • Why message queues? What are the advantages and disadvantages of message queues? What are the advantages and disadvantages of Kafka, ActiveMQ, RabbitMQ, and RocketMQ?
  • How can message queues be highly available?
  • How to ensure that messages are not re-consumed? (How to keep message consumption idempotent)
  • How to ensure the reliable transmission of messages? (How to handle message loss)
  • How do I ensure that messages are sequential?
  • How to solve message queue delay and expiration problem? What happens when the message queue is full? There are millions of messages waiting for hours. How do you fix them?
  • If you were to write a message queue, how would you architecture it? Tell me what you think.

Welcome to follow my wechat public account “Doocs Open Source Community” and push original technical articles as soon as possible.