High-level representations of AMQP protocol objects
amqpy.proto.
Frame
[source]¶Bases: object
AMQP frame
A Frame represents the lowest-level packet of data specified by the AMQP 0.9.1 wire-level protocol. All methods and messages are packed into one or more frames before being sent to the peer.
The format of the AMQP frame is as follows:
offset: 0 1 3 7 size+7 size+8
+------+---------+---------+-------------------+-----------+
| type | channel | size | --- payload --- | frame-end |
+------+---------+---------+-------------------+-----------+
size (bytes) 1 2 4 size 1
data
¶raw frame data; can be manually manipulated at any time
Type: | bytearray |
---|
amqpy.proto.
Method
[source]¶Bases: object
AMQP method
The AMQP 0.9.1 protocol specifies communication as sending and receiving “methods”. Methods consist of a “class-id” and “method-id” and are represented by a method_t namedtuple in amqpy. Methods are packed into the payload of a FrameType.METHOD frame, and most methods can be fully sent in a single frame. If the method specified to be carrying content (such as a message), the method frame is followed by additional frames: a FrameType.HEADER frame, then zero or more FrameType.BODY frames.
The format of the FrameType.METHOD frame’s payload is as follows:
offset: 0 2 4
+----------+-----------+-------------- - -
| class-id | method-id | arguments...
+----------+-----------+-------------- - -
size (bytes): 2 2 variable
The format of the FrameType.HEADER frame’s payload is as follows:
offset: 0 2 4 12 14
+----------+--------+-----------+----------------+------------------- - -
| class-id | weight | body size | property flags | property list...
+----------+--------+-----------+----------------+------------------- - -
size (bytes): 2 2 8 2 variable
The format of the FrameType.BODY frame’s payload is simply raw binary data of the message body.
channel_id
¶Type: | int |
---|
complete
¶@property
Check if the message that is carried by this method has been completely assembled, i.e. the expected number of bytes have been loaded
This method is intended to be called when constructing a Method from incoming data.
Returns: | True if method is complete, else False |
---|---|
Return type: | bool |
content
¶Type: | Message or None |
---|
method_type
¶Type: | amqpy.spec.method_t |
---|
__init__
(method_type=None, args=None, content=None, channel_id=None)[source]¶Parameters: |
|
---|
dump_body_frame
(chunk_size) → generator[amqpy.proto.Frame][source]¶Create a body frame
This method is intended to be called when sending frames for an already-completed Method.
Parameters: | chunk_size (int) – body chunk size in bytes; this is typically the maximum frame size - 8 |
---|---|
Returns: | generator of FrameType.BODY frames |
Return type: | generator[amqpy.proto.Frame] |
dump_header_frame
() → amqpy.proto.Frame[source]¶Create a header frame
This method is intended to be called when sending frames for an already-completed Method.
Returns: | FrameType.HEADER frame |
---|---|
Return type: | amqpy.proto.Frame |
dump_method_frame
() → amqpy.proto.Frame[source]¶Create a method frame
This method is intended to be called when sending frames for an already-completed Method.
Returns: | FrameType.METHOD frame |
---|---|
Return type: | amqpy.proto.Frame |
load_body_frame
(frame) → None[source]¶Add content to partial method
This method is intended to be called when constructing a Method from incoming data.
Parameters: | frame (amqpy.proto.Frame) – FrameType.BODY frame |
---|
load_header_frame
(frame) → None[source]¶Add header to partial method
This method is intended to be called when constructing a Method from incoming data.
Parameters: | frame (amqpy.proto.Frame) – FrameType.HEADER frame |
---|
load_method_frame
(frame) → None[source]¶Load method frame payload data
This method is intended to be called when constructing a Method from incoming data.
After calling, self.method_type, self.args, and self.channel_id will be loaded with data from the frame.
Parameters: | frame (amqpy.proto.Frame) – FrameType.METHOD frame |
---|