1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| class MethodWriter(object): def write_method(self, channel, method_sig, args, content=None): ... if content: body = content.body if isinstance(body, string): coding = content.properties.get('content_encoding', None) if coding is None: coding = content.properties['content_encoding'] = 'UTF-8'
body = body.encode(coding) properties = content._serialize_properties() ... if content: payload = pack('>HHQ', method_sig[0], 0, len(body)) + properties
write_frame(2, channel, payload)
chunk_size = self.frame_max - 8 for i in range(0, len(body), chunk_size): write_frame(3, channel, body[i:i + chunk_size]) self.bytes_sent += 1 class Message(GenericContent): PROPERTIES = [ ('content_type', 'shortstr'), ('content_encoding', 'shortstr'), ('application_headers', 'table'), ('delivery_mode', 'octet'), ('priority', 'octet'), ('correlation_id', 'shortstr'), ('reply_to', 'shortstr'), ('expiration', 'shortstr'), ('message_id', 'shortstr'), ('timestamp', 'timestamp'), ('type', 'shortstr'), ('user_id', 'shortstr'), ('app_id', 'shortstr'), ('cluster_id', 'shortstr') ]
|