View Source ExRocketmq.Remote.Packet (lib_oss v0.1.0)

The communication package of RocketMQ is divided into four parts:

|-- Length --|-- Header Length --|-- Header --|-- Body --|
  1. Header: This is the header of the protocol, and the data is serialized in JSON format. Each key field in the JSON is fixed, but the fields for different communication requests may vary.
  2. Body: This contains the actual binary data of the request. For example, in a network request to send a message, the body would contain the actual message content.
  3. Length: This represents the overall length of the package, which is a four-byte integer.
  4. Header length: This indicates the length of the header, also represented as a four-byte integer.

Header explanation:

  • code: Request/Response code. see ExRocketmq.Protocol.Request and ExRocketmq.Protocol.Response for details.

  • language: Since support for multiple languages is required, this field can inform both communicating parties about the programming language used in the communication layer.

  • version: Informs the communication layer about the version number of the other party. The responding party can use this information to perform special operations for compatibility with older versions, among other things.

  • opaque: Request identification code. this is simply an incrementing integer used to match the corresponding request with its response.

  • flag: Bit interpretation. The 0th bit indicates whether the communication is a request or a response. 0 represents a request, while 1 represents a response. The 1st bit indicates whether the request is a one-way request. 1 represents a one-way request. When handling a one-way request, the responding party does not provide a response, and the requesting party does not need to wait for a response from the responding party.

  • remark: Additional text information. Commonly used to store exception messages returned by brokers/nameservers, facilitating problem localization for developers.

  • extFields: This field is a string-dict, and it differs for each request/response and is completely customizable.

Summary

Types

@type t() ::
  {:packet, code :: non_neg_integer(), language :: non_neg_integer(),
   version :: non_neg_integer(), opaque :: non_neg_integer(),
   flag :: non_neg_integer(), remark :: String.t(),
   ext_fields :: ExRocketmq.Typespecs.ext_fields(), body :: binary()}

Functions

Link to this macro

packet(args \\ [])

View Source (macro)
Link to this macro

packet(record, args)

View Source (macro)
@spec response_type?(t()) :: boolean()