1"""specification.py 2 3Auto-generated AMQP Support Module 4 5WARNING: DO NOT EDIT. To Generate run tools/codegen.py 6 7""" 8__since__ = '2014-12-12' 9 10import struct 11 12from pamqp import decode 13from pamqp import encode 14 15# AMQP Protocol Version 16VERSION = (0, 9, 1) 17 18# RabbitMQ Defaults 19DEFAULT_HOST = "localhost" 20DEFAULT_PORT = 5672 21DEFAULT_USER = "guest" 22DEFAULT_PASS = "guest" 23DEFAULT_VHOST = "/" 24 25# AMQP Constants 26FRAME_METHOD = 1 27FRAME_HEADER = 2 28FRAME_BODY = 3 29FRAME_HEARTBEAT = 8 30FRAME_MIN_SIZE = 4096 31FRAME_END = 206 32# Indicates that the method completed successfully. This reply code is reserved 33# for future use - the current protocol design does not use positive 34# confirmation and reply codes are sent only in case of an error. 35REPLY_SUCCESS = 200 36 37# Not included in the spec XML or JSON files. 38FRAME_MAX_SIZE = 131072 39 40# AMQP data types 41DATA_TYPES = ["bit", 42 "long", 43 "longlong", 44 "longstr", 45 "octet", 46 "short", 47 "shortstr", 48 "table", 49 "timestamp"] 50 51# AMQP domains 52DOMAINS = {"channel-id": "longstr", 53 "class-id": "short", 54 "consumer-tag": "shortstr", 55 "delivery-tag": "longlong", 56 "destination": "shortstr", 57 "duration": "longlong", 58 "exchange-name": "shortstr", 59 "method-id": "short", 60 "no-ack": "bit", 61 "no-local": "bit", 62 "offset": "longlong", 63 "path": "shortstr", 64 "peer-properties": "table", 65 "queue-name": "shortstr", 66 "redelivered": "bit", 67 "reference": "longstr", 68 "reject-code": "short", 69 "reject-text": "shortstr", 70 "reply-code": "short", 71 "reply-text": "shortstr", 72 "security-token": "longstr"} 73 74# Other constants 75DEPRECATION_WARNING = 'This command is deprecated in AMQP 0-9-1' 76 77 78class Frame(object): 79 """Base Class for AMQP Methods which specifies the encoding and decoding 80 behavior. 81 82 """ 83 __slots__ = list() 84 frame_id = 0 85 index = 0 86 name = 'Frame' 87 synchronous = False 88 valid_responses = [] 89 90 def __iter__(self): 91 """Iterate the attributes and values as key, value pairs. 92 93 :rtype: tuple 94 95 """ 96 for attribute in self.__slots__: 97 yield (attribute, getattr(self, attribute)) 98 99 def __contains__(self, item): 100 """Return if the item is in the attribute list. 101 102 :rtype: bool 103 104 """ 105 return item in self.__slots__ 106 107 def __getitem__(self, item): 108 """Return an attribute as if it were a dict. 109 110 :param str item: The item to look for 111 :raises: KeyError 112 :rtype: any 113 114 """ 115 return getattr(self, item) 116 117 def __len__(self): 118 """Return the length of the attribute list. 119 120 :rtype: int 121 122 """ 123 return len(self.__slots__) 124 125 def __repr__(self): 126 """Return the representation of the frame object 127 128 :return: str 129 130 """ 131 return '<%s.%s object at %s>' % (__name__, self.name, hex(id(self))) 132 133 @classmethod 134 def type(cls, attr): 135 """Return the data type for an attribute. 136 137 :rtype: str 138 139 """ 140 return getattr(cls, '_' + attr) 141 142 def marshal(self): 143 """ 144 Dynamically encode the frame by taking the list of attributes and 145 encode them item by item getting the value form the object attribute 146 and the data type from the class attribute. 147 148 :rtype: str 149 150 """ 151 output = list() 152 processing_bitset = False 153 byte = None 154 offset = 0 155 for argument in self.__slots__: 156 data_type = self.type(argument) 157 158 # Check if we need to turn on bit processing 159 if not processing_bitset and data_type == 'bit': 160 byte = 0 161 offset = 0 162 processing_bitset = True 163 164 # Get the data value 165 data_value = getattr(self, argument) 166 167 # If we're processing a bitset, apply special rules 168 if processing_bitset: 169 170 # Is this value not a bit? turn off bitset processing and 171 # append the byte value as an octet 172 if data_type != 'bit': 173 processing_bitset = False 174 output.append(encode.octet(byte)) 175 176 else: 177 # Apply the bit value to the byte 178 byte = encode.bit(data_value, byte, offset) 179 offset += 1 180 if offset == 8: 181 # We've filled a byte for all bits, add the byte 182 output.append(encode.octet(byte)) 183 # Turn off processing, we'll turn on in next iteration 184 # if needed 185 processing_bitset = False 186 187 # Go to the next iteration 188 continue 189 190 # Not a bit, so just process by type 191 output.append(encode.by_type(data_value, data_type)) 192 193 # Append the last byte if we're processing a bitset 194 if processing_bitset: 195 output.append(encode.octet(byte)) 196 197 return b''.join(output) 198 199 def unmarshal(self, data): 200 """ 201 Dynamically decode the frame data applying the values to the method 202 object by iterating through the attributes in order and decoding them. 203 204 :param str data: The binary encoded method data 205 206 """ 207 offset = 0 208 processing_bitset = False 209 for argument in self.__slots__: 210 data_type = self.type(argument) 211 212 if offset == 7 and processing_bitset: 213 data = data[1:] 214 offset = 0 215 216 if processing_bitset and data_type != 'bit': 217 offset = 0 218 processing_bitset = False 219 data = data[1:] 220 221 consumed, value = decode.by_type(data, data_type, offset) 222 223 if data_type == 'bit': 224 offset += 1 225 processing_bitset = True 226 consumed = 0 227 228 setattr(self, argument, value) 229 if consumed: 230 data = data[consumed:] 231 232 233class PropertiesBase(object): 234 """Provide a base object that marshals and unmarshals the Basic.Properties 235 object values. 236 237 """ 238 239 __slots__ = list() 240 flags = dict() 241 name = 'PropertiesBase' 242 243 def __contains__(self, item): 244 return item in self.__slots__ 245 246 def __delattr__(self, item): 247 setattr(self, item, None) 248 249 def __iter__(self): 250 """Iterate the attributes and values as key, value pairs. 251 252 :rtype: tuple 253 254 """ 255 for attribute in self.__slots__: 256 yield (attribute, getattr(self, attribute)) 257 258 @classmethod 259 def attributes(cls): 260 """Return the list of attributes 261 262 :rtype: list 263 264 """ 265 return [attr for attr in cls.__slots__] 266 267 @classmethod 268 def type(cls, attr): 269 """Return the data type for an attribute. 270 271 :rtype: str 272 273 """ 274 return getattr(cls, '_' + attr) 275 276 def encode_property(self, property_name, property_value): 277 """Encode a single property value 278 279 :param str property_name: The property name to encode 280 :param any property_value: The value to encode 281 282 """ 283 return encode.by_type(property_value, self.type(property_name)) 284 285 def marshal(self): 286 """Take the Basic.Properties data structure and marshal it into the data 287 structure needed for the ContentHeader. 288 289 :rtype: bytes 290 291 """ 292 flags = 0 293 parts = list() 294 for property_name in self.__slots__: 295 property_value = getattr(self, property_name) 296 if property_value is not None and property_value != '': 297 flags = flags | self.flags[property_name] 298 parts.append(self.encode_property(property_name, 299 property_value)) 300 flag_pieces = list() 301 while True: 302 remainder = flags >> 16 303 partial_flags = flags & 0xFFFE 304 if remainder != 0: 305 partial_flags |= 1 306 flag_pieces.append(struct.pack('>H', partial_flags)) 307 flags = remainder 308 if not flags: 309 break 310 return b''.join(flag_pieces + parts) 311 312 def to_dict(self): 313 """Return the properties as a dict 314 315 :rtype: dict 316 317 """ 318 return dict(self) 319 320 def unmarshal(self, flags, data): 321 """ 322 Dynamically decode the frame data applying the values to the method 323 object by iterating through the attributes in order and decoding them. 324 325 :param int flags: Flags that indicate if the data has the given property 326 :param bytes data: The binary encoded method data 327 328 """ 329 for property_name in self.__slots__: 330 if flags & self.flags[property_name]: 331 data_type = getattr(self.__class__, '_' + property_name) 332 consumed, value = decode.by_type(data, data_type) 333 setattr(self, property_name, value) 334 data = data[consumed:] 335 336 337# AMQP Errors 338class AMQPContentTooLarge(Warning): 339 """ 340 The client attempted to transfer content larger than the server could 341 accept at the present time. The client may retry at a later time. 342 343 """ 344 name = 'CONTENT-TOO-LARGE' 345 value = 311 346 347 348class AMQPNoRoute(Warning): 349 """ 350 Undocumented AMQP Soft Error 351 352 """ 353 name = 'NO-ROUTE' 354 value = 312 355 356 357class AMQPNoConsumers(Warning): 358 """ 359 When the exchange cannot deliver to a consumer when the immediate flag is 360 set. As a result of pending data on the queue or the absence of any 361 consumers of the queue. 362 363 """ 364 name = 'NO-CONSUMERS' 365 value = 313 366 367 368class AMQPAccessRefused(Warning): 369 """ 370 The client attempted to work with a server entity to which it has no access 371 due to security settings. 372 373 """ 374 name = 'ACCESS-REFUSED' 375 value = 403 376 377 378class AMQPNotFound(Warning): 379 """ 380 The client attempted to work with a server entity that does not exist. 381 382 """ 383 name = 'NOT-FOUND' 384 value = 404 385 386 387class AMQPResourceLocked(Warning): 388 """ 389 The client attempted to work with a server entity to which it has no access 390 because another client is working with it. 391 392 """ 393 name = 'RESOURCE-LOCKED' 394 value = 405 395 396 397class AMQPPreconditionFailed(Warning): 398 """ 399 The client requested a method that was not allowed because some 400 precondition failed. 401 402 """ 403 name = 'PRECONDITION-FAILED' 404 value = 406 405 406 407class AMQPConnectionForced(Exception): 408 """ 409 An operator intervened to close the connection for some reason. The client 410 may retry at some later date. 411 412 """ 413 name = 'CONNECTION-FORCED' 414 value = 320 415 416 417class AMQPInvalidPath(Exception): 418 """ 419 The client tried to work with an unknown virtual host. 420 421 """ 422 name = 'INVALID-PATH' 423 value = 402 424 425 426class AMQPFrameError(Exception): 427 """ 428 The sender sent a malformed frame that the recipient could not decode. This 429 strongly implies a programming error in the sending peer. 430 431 """ 432 name = 'FRAME-ERROR' 433 value = 501 434 435 436class AMQPSyntaxError(Exception): 437 """ 438 The sender sent a frame that contained illegal values for one or more 439 fields. This strongly implies a programming error in the sending peer. 440 441 """ 442 name = 'SYNTAX-ERROR' 443 value = 502 444 445 446class AMQPCommandInvalid(Exception): 447 """ 448 The client sent an invalid sequence of frames, attempting to perform an 449 operation that was considered invalid by the server. This usually implies a 450 programming error in the client. 451 452 """ 453 name = 'COMMAND-INVALID' 454 value = 503 455 456 457class AMQPChannelError(Exception): 458 """ 459 The client attempted to work with a channel that had not been correctly 460 opened. This most likely indicates a fault in the client layer. 461 462 """ 463 name = 'CHANNEL-ERROR' 464 value = 504 465 466 467class AMQPUnexpectedFrame(Exception): 468 """ 469 The peer sent a frame that was not expected, usually in the context of a 470 content header and body. This strongly indicates a fault in the peer's 471 content processing. 472 473 """ 474 name = 'UNEXPECTED-FRAME' 475 value = 505 476 477 478class AMQPResourceError(Exception): 479 """ 480 The server could not complete the method because it lacked sufficient 481 resources. This may be due to the client creating too many of some type of 482 entity. 483 484 """ 485 name = 'RESOURCE-ERROR' 486 value = 506 487 488 489class AMQPNotAllowed(Exception): 490 """ 491 The client tried to work with some entity in a manner that is prohibited by 492 the server, due to security settings or by some other criteria. 493 494 """ 495 name = 'NOT-ALLOWED' 496 value = 530 497 498 499class AMQPNotImplemented(Exception): 500 """ 501 The client tried to use functionality that is not implemented in the 502 server. 503 504 """ 505 name = 'NOT-IMPLEMENTED' 506 value = 540 507 508 509class AMQPInternalError(Exception): 510 """ 511 The server could not complete the method because of an internal error. The 512 server may require intervention by an operator in order to resume normal 513 operations. 514 515 """ 516 name = 'INTERNAL-ERROR' 517 value = 541 518 519 520# AMQP Error code to class mapping 521ERRORS = {320: AMQPConnectionForced, 522 505: AMQPUnexpectedFrame, 523 502: AMQPSyntaxError, 524 503: AMQPCommandInvalid, 525 530: AMQPNotAllowed, 526 504: AMQPChannelError, 527 402: AMQPInvalidPath, 528 403: AMQPAccessRefused, 529 404: AMQPNotFound, 530 405: AMQPResourceLocked, 531 406: AMQPPreconditionFailed, 532 311: AMQPContentTooLarge, 533 312: AMQPNoRoute, 534 313: AMQPNoConsumers, 535 506: AMQPResourceError, 536 540: AMQPNotImplemented, 537 541: AMQPInternalError, 538 501: AMQPFrameError} 539 540# AMQP Classes and Methods 541 542 543class Connection(object): 544 """Work with socket connections 545 546 The connection class provides methods for a client to establish a network 547 connection to a server, and for both peers to operate the connection 548 thereafter. 549 550 """ 551 __slots__ = [] 552 553 # AMQP Class Number and Mapping Index 554 frame_id = 10 555 index = 0x000A0000 556 557 class Start(Frame): 558 """Start connection negotiation 559 560 This method starts the connection negotiation process by telling the 561 client the protocol version that the server proposes, along with a list 562 of security mechanisms which the client can use for authentication. 563 564 """ 565 # AMQP Method Number and Mapping Index 566 frame_id = 10 567 index = 0x000A000A 568 name = 'Connection.Start' 569 570 # Specifies if this is a synchronous AMQP method 571 synchronous = True 572 573 # Valid responses to this method 574 valid_responses = ['Connection.StartOk'] 575 576 # AMQP Method Attributes 577 __slots__ = ['version_major', 578 'version_minor', 579 'server_properties', 580 'mechanisms', 581 'locales'] 582 583 # Class Attribute Types 584 _version_major = 'octet' 585 _version_minor = 'octet' 586 _server_properties = 'table' 587 _mechanisms = 'longstr' 588 _locales = 'longstr' 589 590 def __init__(self, version_major=0, version_minor=9, 591 server_properties=None, mechanisms='PLAIN', 592 locales='en_US'): 593 """Initialize the Connection.Start class 594 595 :param int version_major: Protocol major version 596 :param int version_minor: Protocol minor version 597 :param dict server_properties: Server properties 598 :param str mechanisms: Available security mechanisms 599 :param str locales: Available message locales 600 601 """ 602 # Protocol major version 603 self.version_major = version_major 604 605 # Protocol minor version 606 self.version_minor = version_minor 607 608 # Server properties 609 self.server_properties = server_properties 610 611 # Available security mechanisms 612 self.mechanisms = mechanisms 613 614 # Available message locales 615 self.locales = locales 616 617 class StartOk(Frame): 618 """Select security mechanism and locale 619 620 This method selects a SASL security mechanism. 621 622 """ 623 # AMQP Method Number and Mapping Index 624 frame_id = 11 625 index = 0x000A000B 626 name = 'Connection.StartOk' 627 628 # Specifies if this is a synchronous AMQP method 629 synchronous = False 630 631 # AMQP Method Attributes 632 __slots__ = ['client_properties', 633 'mechanism', 634 'response', 635 'locale'] 636 637 # Class Attribute Types 638 _client_properties = 'table' 639 _mechanism = 'shortstr' 640 _response = 'longstr' 641 _locale = 'shortstr' 642 643 def __init__(self, client_properties=None, mechanism='PLAIN', 644 response='', locale='en_US'): 645 """Initialize the Connection.StartOk class 646 647 :param dict client_properties: Client properties 648 :param str mechanism: Selected security mechanism 649 :param str response: Security response data 650 :param str locale: Selected message locale 651 652 """ 653 # Client properties 654 self.client_properties = client_properties 655 656 # Selected security mechanism 657 self.mechanism = mechanism 658 659 # Security response data 660 self.response = response 661 662 # Selected message locale 663 self.locale = locale 664 665 class Secure(Frame): 666 """Security mechanism challenge 667 668 The SASL protocol works by exchanging challenges and responses until 669 both peers have received sufficient information to authenticate each 670 other. This method challenges the client to provide more information. 671 672 """ 673 # AMQP Method Number and Mapping Index 674 frame_id = 20 675 index = 0x000A0014 676 name = 'Connection.Secure' 677 678 # Specifies if this is a synchronous AMQP method 679 synchronous = True 680 681 # Valid responses to this method 682 valid_responses = ['Connection.SecureOk'] 683 684 # AMQP Method Attributes 685 __slots__ = ['challenge'] 686 687 # Class Attribute Types 688 _challenge = 'longstr' 689 690 def __init__(self, challenge=''): 691 """Initialize the Connection.Secure class 692 693 :param str challenge: Security challenge data 694 695 """ 696 # Security challenge data 697 self.challenge = challenge 698 699 class SecureOk(Frame): 700 """Security mechanism response 701 702 This method attempts to authenticate, passing a block of SASL data for 703 the security mechanism at the server side. 704 705 """ 706 # AMQP Method Number and Mapping Index 707 frame_id = 21 708 index = 0x000A0015 709 name = 'Connection.SecureOk' 710 711 # Specifies if this is a synchronous AMQP method 712 synchronous = False 713 714 # AMQP Method Attributes 715 __slots__ = ['response'] 716 717 # Class Attribute Types 718 _response = 'longstr' 719 720 def __init__(self, response=''): 721 """Initialize the Connection.SecureOk class 722 723 :param str response: Security response data 724 725 """ 726 # Security response data 727 self.response = response 728 729 class Tune(Frame): 730 """Propose connection tuning parameters 731 732 This method proposes a set of connection configuration values to the 733 client. The client can accept and/or adjust these. 734 735 """ 736 # AMQP Method Number and Mapping Index 737 frame_id = 30 738 index = 0x000A001E 739 name = 'Connection.Tune' 740 741 # Specifies if this is a synchronous AMQP method 742 synchronous = True 743 744 # Valid responses to this method 745 valid_responses = ['Connection.TuneOk'] 746 747 # AMQP Method Attributes 748 __slots__ = ['channel_max', 749 'frame_max', 750 'heartbeat'] 751 752 # Class Attribute Types 753 _channel_max = 'short' 754 _frame_max = 'long' 755 _heartbeat = 'short' 756 757 def __init__(self, channel_max=0, frame_max=0, heartbeat=0): 758 """Initialize the Connection.Tune class 759 760 :param int channel_max: Proposed maximum channels 761 :param int/long frame_max: Proposed maximum frame size 762 :param int heartbeat: Desired heartbeat delay 763 764 """ 765 # Proposed maximum channels 766 self.channel_max = channel_max 767 768 # Proposed maximum frame size 769 self.frame_max = frame_max 770 771 # Desired heartbeat delay 772 self.heartbeat = heartbeat 773 774 class TuneOk(Frame): 775 """Negotiate connection tuning parameters 776 777 This method sends the client's connection tuning parameters to the 778 server. Certain fields are negotiated, others provide capability 779 information. 780 781 """ 782 # AMQP Method Number and Mapping Index 783 frame_id = 31 784 index = 0x000A001F 785 name = 'Connection.TuneOk' 786 787 # Specifies if this is a synchronous AMQP method 788 synchronous = False 789 790 # AMQP Method Attributes 791 __slots__ = ['channel_max', 792 'frame_max', 793 'heartbeat'] 794 795 # Class Attribute Types 796 _channel_max = 'short' 797 _frame_max = 'long' 798 _heartbeat = 'short' 799 800 def __init__(self, channel_max=0, frame_max=0, heartbeat=0): 801 """Initialize the Connection.TuneOk class 802 803 :param int channel_max: Negotiated maximum channels 804 :param int/long frame_max: Negotiated maximum frame size 805 :param int heartbeat: Desired heartbeat delay 806 807 """ 808 # Negotiated maximum channels 809 self.channel_max = channel_max 810 811 # Negotiated maximum frame size 812 self.frame_max = frame_max 813 814 # Desired heartbeat delay 815 self.heartbeat = heartbeat 816 817 class Open(Frame): 818 """Open connection to virtual host 819 820 This method opens a connection to a virtual host, which is a collection 821 of resources, and acts to separate multiple application domains within 822 a server. The server may apply arbitrary limits per virtual host, such 823 as the number of each type of entity that may be used, per connection 824 and/or in total. 825 826 """ 827 # AMQP Method Number and Mapping Index 828 frame_id = 40 829 index = 0x000A0028 830 name = 'Connection.Open' 831 832 # Specifies if this is a synchronous AMQP method 833 synchronous = True 834 835 # Valid responses to this method 836 valid_responses = ['Connection.OpenOk'] 837 838 # AMQP Method Attributes 839 __slots__ = ['virtual_host', 840 'capabilities', 841 'insist'] 842 843 # Class Attribute Types 844 _virtual_host = 'shortstr' 845 _capabilities = 'shortstr' 846 _insist = 'bit' 847 848 def __init__(self, virtual_host='/', capabilities='', insist=False): 849 """Initialize the Connection.Open class 850 851 :param str virtual_host: Virtual host name 852 :param str capabilities: Deprecated 853 :param bool insist: Deprecated 854 855 """ 856 # Virtual host name 857 self.virtual_host = virtual_host 858 859 # Deprecated 860 self.capabilities = capabilities 861 862 # Deprecated 863 self.insist = insist 864 865 class OpenOk(Frame): 866 """Signal that connection is ready 867 868 This method signals to the client that the connection is ready for use. 869 870 """ 871 # AMQP Method Number and Mapping Index 872 frame_id = 41 873 index = 0x000A0029 874 name = 'Connection.OpenOk' 875 876 # Specifies if this is a synchronous AMQP method 877 synchronous = False 878 879 # AMQP Method Attributes 880 __slots__ = ['known_hosts'] 881 882 # Class Attribute Types 883 _known_hosts = 'shortstr' 884 885 def __init__(self, known_hosts=''): 886 """Initialize the Connection.OpenOk class 887 888 :param str known_hosts: Deprecated 889 890 """ 891 # Deprecated 892 self.known_hosts = known_hosts 893 894 class Close(Frame): 895 """Request a connection close 896 897 This method indicates that the sender wants to close the connection. 898 This may be due to internal conditions (e.g. a forced shut-down) or due 899 to an error handling a specific method, i.e. an exception. When a close 900 is due to an exception, the sender provides the class and method id of 901 the method which caused the exception. 902 903 """ 904 # AMQP Method Number and Mapping Index 905 frame_id = 50 906 index = 0x000A0032 907 name = 'Connection.Close' 908 909 # Specifies if this is a synchronous AMQP method 910 synchronous = True 911 912 # Valid responses to this method 913 valid_responses = ['Connection.CloseOk'] 914 915 # AMQP Method Attributes 916 __slots__ = ['reply_code', 917 'reply_text', 918 'class_id', 919 'method_id'] 920 921 # Class Attribute Types 922 _reply_code = 'short' 923 _reply_text = 'shortstr' 924 _class_id = 'short' 925 _method_id = 'short' 926 927 def __init__(self, reply_code=0, reply_text='', class_id=0, 928 method_id=0): 929 """Initialize the Connection.Close class 930 931 :param int reply_code: Reply code from server 932 :param str reply_text: Localised reply text 933 :param int class_id: Failing method class 934 :param int method_id: Failing method ID 935 936 """ 937 # Reply code from server 938 self.reply_code = reply_code 939 940 # Localised reply text 941 self.reply_text = reply_text 942 943 # Failing method class 944 self.class_id = class_id 945 946 # Failing method ID 947 self.method_id = method_id 948 949 class CloseOk(Frame): 950 """Confirm a connection close 951 952 This method confirms a Connection.Close method and tells the recipient 953 that it is safe to release resources for the connection and close the 954 socket. 955 956 """ 957 # AMQP Method Number and Mapping Index 958 frame_id = 51 959 index = 0x000A0033 960 name = 'Connection.CloseOk' 961 962 # Specifies if this is a synchronous AMQP method 963 synchronous = False 964 965 class Blocked(Frame): 966 """Signal that connection is blocked 967 968 This method signals to the client that the connection is blocked by 969 RabbitMQ. 970 971 """ 972 # AMQP Method Number and Mapping Index 973 frame_id = 60 974 index = 0x000A003C 975 name = 'Connection.Blocked' 976 977 # Specifies if this is a synchronous AMQP method 978 synchronous = False 979 980 # AMQP Method Attributes 981 __slots__ = ['reason'] 982 983 # Class Attribute Types 984 _reason = 'shortstr' 985 986 def __init__(self, reason=''): 987 """Initialize the Connection.Blocked class 988 989 :param str reason: 990 991 """ 992 self.reason = reason 993 994 class Unblocked(Frame): 995 """Signal that connection is no longer blocked 996 997 This method signals to the client that the connection is no longer 998 blocked by RabbitMQ. 999 1000 """ 1001 # AMQP Method Number and Mapping Index 1002 frame_id = 61 1003 index = 0x000A003D 1004 name = 'Connection.Unblocked' 1005 1006 # Specifies if this is a synchronous AMQP method 1007 synchronous = False 1008 1009 1010class Channel(object): 1011 """Work with channels 1012 1013 The channel class provides methods for a client to establish a channel to a 1014 server and for both peers to operate the channel thereafter. 1015 1016 """ 1017 __slots__ = [] 1018 1019 # AMQP Class Number and Mapping Index 1020 frame_id = 20 1021 index = 0x00140000 1022 1023 class Open(Frame): 1024 """Open a channel for use 1025 1026 This method opens a channel to the server. 1027 1028 """ 1029 # AMQP Method Number and Mapping Index 1030 frame_id = 10 1031 index = 0x0014000A 1032 name = 'Channel.Open' 1033 1034 # Specifies if this is a synchronous AMQP method 1035 synchronous = True 1036 1037 # Valid responses to this method 1038 valid_responses = ['Channel.OpenOk'] 1039 1040 # AMQP Method Attributes 1041 __slots__ = ['out_of_band'] 1042 1043 # Class Attribute Types 1044 _out_of_band = 'shortstr' 1045 1046 def __init__(self, out_of_band=''): 1047 """Initialize the Channel.Open class 1048 1049 :param str out_of_band: Protocol level field, do not use, must be zero. 1050 1051 """ 1052 # Protocol level field, do not use, must be zero. 1053 self.out_of_band = out_of_band 1054 1055 class OpenOk(Frame): 1056 """Signal that the channel is ready 1057 1058 This method signals to the client that the channel is ready for use. 1059 1060 """ 1061 # AMQP Method Number and Mapping Index 1062 frame_id = 11 1063 index = 0x0014000B 1064 name = 'Channel.OpenOk' 1065 1066 # Specifies if this is a synchronous AMQP method 1067 synchronous = False 1068 1069 # AMQP Method Attributes 1070 __slots__ = ['channel_id'] 1071 1072 # Class Attribute Types 1073 _channel_id = 'longstr' 1074 1075 def __init__(self, channel_id=''): 1076 """Initialize the Channel.OpenOk class 1077 1078 :param str channel_id: Deprecated 1079 1080 """ 1081 # Deprecated 1082 self.channel_id = channel_id 1083 1084 class Flow(Frame): 1085 """Enable/disable flow from peer 1086 1087 This method asks the peer to pause or restart the flow of content data 1088 sent by a consumer. This is a simple flow-control mechanism that a peer 1089 can use to avoid overflowing its queues or otherwise finding itself 1090 receiving more messages than it can process. Note that this method is 1091 not intended for window control. It does not affect contents returned 1092 by Basic.Get-Ok methods. 1093 1094 """ 1095 # AMQP Method Number and Mapping Index 1096 frame_id = 20 1097 index = 0x00140014 1098 name = 'Channel.Flow' 1099 1100 # Specifies if this is a synchronous AMQP method 1101 synchronous = True 1102 1103 # Valid responses to this method 1104 valid_responses = ['Channel.FlowOk'] 1105 1106 # AMQP Method Attributes 1107 __slots__ = ['active'] 1108 1109 # Class Attribute Types 1110 _active = 'bit' 1111 1112 def __init__(self, active=None): 1113 """Initialize the Channel.Flow class 1114 1115 :param bool active: Start/stop content frames 1116 1117 """ 1118 # Start/stop content frames 1119 self.active = active 1120 1121 class FlowOk(Frame): 1122 """Confirm a flow method 1123 1124 Confirms to the peer that a flow command was received and processed. 1125 1126 """ 1127 # AMQP Method Number and Mapping Index 1128 frame_id = 21 1129 index = 0x00140015 1130 name = 'Channel.FlowOk' 1131 1132 # Specifies if this is a synchronous AMQP method 1133 synchronous = False 1134 1135 # AMQP Method Attributes 1136 __slots__ = ['active'] 1137 1138 # Class Attribute Types 1139 _active = 'bit' 1140 1141 def __init__(self, active=None): 1142 """Initialize the Channel.FlowOk class 1143 1144 :param bool active: Current flow setting 1145 1146 """ 1147 # Current flow setting 1148 self.active = active 1149 1150 class Close(Frame): 1151 """Request a channel close 1152 1153 This method indicates that the sender wants to close the channel. This 1154 may be due to internal conditions (e.g. a forced shut-down) or due to 1155 an error handling a specific method, i.e. an exception. When a close is 1156 due to an exception, the sender provides the class and method id of the 1157 method which caused the exception. 1158 1159 """ 1160 # AMQP Method Number and Mapping Index 1161 frame_id = 40 1162 index = 0x00140028 1163 name = 'Channel.Close' 1164 1165 # Specifies if this is a synchronous AMQP method 1166 synchronous = True 1167 1168 # Valid responses to this method 1169 valid_responses = ['Channel.CloseOk'] 1170 1171 # AMQP Method Attributes 1172 __slots__ = ['reply_code', 1173 'reply_text', 1174 'class_id', 1175 'method_id'] 1176 1177 # Class Attribute Types 1178 _reply_code = 'short' 1179 _reply_text = 'shortstr' 1180 _class_id = 'short' 1181 _method_id = 'short' 1182 1183 def __init__(self, reply_code=0, reply_text='', class_id=0, 1184 method_id=0): 1185 """Initialize the Channel.Close class 1186 1187 :param int reply_code: Reply code from server 1188 :param str reply_text: Localised reply text 1189 :param int class_id: Failing method class 1190 :param int method_id: Failing method ID 1191 1192 """ 1193 # Reply code from server 1194 self.reply_code = reply_code 1195 1196 # Localised reply text 1197 self.reply_text = reply_text 1198 1199 # Failing method class 1200 self.class_id = class_id 1201 1202 # Failing method ID 1203 self.method_id = method_id 1204 1205 class CloseOk(Frame): 1206 """Confirm a channel close 1207 1208 This method confirms a Channel.Close method and tells the recipient 1209 that it is safe to release resources for the channel. 1210 1211 """ 1212 # AMQP Method Number and Mapping Index 1213 frame_id = 41 1214 index = 0x00140029 1215 name = 'Channel.CloseOk' 1216 1217 # Specifies if this is a synchronous AMQP method 1218 synchronous = False 1219 1220 1221class Exchange(object): 1222 """Work with exchanges 1223 1224 Exchanges match and distribute messages across queues. Exchanges can be 1225 configured in the server or declared at runtime. 1226 1227 """ 1228 __slots__ = [] 1229 1230 # AMQP Class Number and Mapping Index 1231 frame_id = 40 1232 index = 0x00280000 1233 1234 class Declare(Frame): 1235 """Verify exchange exists, create if needed 1236 1237 This method creates an exchange if it does not already exist, and if 1238 the exchange exists, verifies that it is of the correct and expected 1239 class. 1240 1241 """ 1242 # AMQP Method Number and Mapping Index 1243 frame_id = 10 1244 index = 0x0028000A 1245 name = 'Exchange.Declare' 1246 1247 # Specifies if this is a synchronous AMQP method 1248 synchronous = True 1249 1250 # Valid responses to this method 1251 valid_responses = ['Exchange.DeclareOk'] 1252 1253 # AMQP Method Attributes 1254 __slots__ = ['ticket', 1255 'exchange', 1256 'exchange_type', 1257 'passive', 1258 'durable', 1259 'auto_delete', 1260 'internal', 1261 'nowait', 1262 'arguments'] 1263 1264 # Class Attribute Types 1265 _ticket = 'short' 1266 _exchange = 'shortstr' 1267 _exchange_type = 'shortstr' 1268 _passive = 'bit' 1269 _durable = 'bit' 1270 _auto_delete = 'bit' 1271 _internal = 'bit' 1272 _nowait = 'bit' 1273 _arguments = 'table' 1274 1275 def __init__(self, ticket=0, exchange='', exchange_type='direct', 1276 passive=False, durable=False, auto_delete=False, 1277 internal=False, nowait=False, arguments=None): 1278 """Initialize the Exchange.Declare class 1279 1280 Note that the AMQP type argument is referred to as "exchange_type" 1281 to not conflict with the Python type keyword. 1282 1283 :param int ticket: Deprecated 1284 :param str exchange: 1285 :param str exchange_type: Exchange type 1286 :param bool passive: Do not create exchange 1287 :param bool durable: Request a durable exchange 1288 :param bool auto_delete: Automatically delete when not in use 1289 :param bool internal: Deprecated 1290 :param bool nowait: Do not send a reply method 1291 :param dict arguments: Arguments for declaration 1292 1293 """ 1294 # Deprecated 1295 self.ticket = ticket 1296 1297 self.exchange = exchange 1298 1299 # Exchange type 1300 self.exchange_type = exchange_type 1301 1302 # Do not create exchange 1303 self.passive = passive 1304 1305 # Request a durable exchange 1306 self.durable = durable 1307 1308 # Automatically delete when not in use 1309 self.auto_delete = auto_delete 1310 1311 # Deprecated 1312 self.internal = internal 1313 1314 # Do not send a reply method 1315 self.nowait = nowait 1316 1317 # Arguments for declaration 1318 self.arguments = arguments or dict() 1319 1320 class DeclareOk(Frame): 1321 """Confirm exchange declaration 1322 1323 This method confirms a Declare method and confirms the name of the 1324 exchange, essential for automatically-named exchanges. 1325 1326 """ 1327 # AMQP Method Number and Mapping Index 1328 frame_id = 11 1329 index = 0x0028000B 1330 name = 'Exchange.DeclareOk' 1331 1332 # Specifies if this is a synchronous AMQP method 1333 synchronous = False 1334 1335 class Delete(Frame): 1336 """Delete an exchange 1337 1338 This method deletes an exchange. When an exchange is deleted all queue 1339 bindings on the exchange are cancelled. 1340 1341 """ 1342 # AMQP Method Number and Mapping Index 1343 frame_id = 20 1344 index = 0x00280014 1345 name = 'Exchange.Delete' 1346 1347 # Specifies if this is a synchronous AMQP method 1348 synchronous = True 1349 1350 # Valid responses to this method 1351 valid_responses = ['Exchange.DeleteOk'] 1352 1353 # AMQP Method Attributes 1354 __slots__ = ['ticket', 1355 'exchange', 1356 'if_unused', 1357 'nowait'] 1358 1359 # Class Attribute Types 1360 _ticket = 'short' 1361 _exchange = 'shortstr' 1362 _if_unused = 'bit' 1363 _nowait = 'bit' 1364 1365 def __init__(self, ticket=0, exchange='', if_unused=False, 1366 nowait=False): 1367 """Initialize the Exchange.Delete class 1368 1369 :param int ticket: Deprecated 1370 :param str exchange: 1371 :param bool if_unused: Delete only if unused 1372 :param bool nowait: Do not send a reply method 1373 1374 """ 1375 # Deprecated 1376 self.ticket = ticket 1377 1378 self.exchange = exchange 1379 1380 # Delete only if unused 1381 self.if_unused = if_unused 1382 1383 # Do not send a reply method 1384 self.nowait = nowait 1385 1386 class DeleteOk(Frame): 1387 """Confirm deletion of an exchange 1388 1389 This method confirms the deletion of an exchange. 1390 1391 """ 1392 # AMQP Method Number and Mapping Index 1393 frame_id = 21 1394 index = 0x00280015 1395 name = 'Exchange.DeleteOk' 1396 1397 # Specifies if this is a synchronous AMQP method 1398 synchronous = False 1399 1400 class Bind(Frame): 1401 # AMQP Method Number and Mapping Index 1402 frame_id = 30 1403 index = 0x0028001E 1404 name = 'Exchange.Bind' 1405 1406 # Specifies if this is a synchronous AMQP method 1407 synchronous = True 1408 1409 # Valid responses to this method 1410 valid_responses = ['Exchange.BindOk'] 1411 1412 # AMQP Method Attributes 1413 __slots__ = ['ticket', 1414 'destination', 1415 'source', 1416 'routing_key', 1417 'nowait', 1418 'arguments'] 1419 1420 # Class Attribute Types 1421 _ticket = 'short' 1422 _destination = 'shortstr' 1423 _source = 'shortstr' 1424 _routing_key = 'shortstr' 1425 _nowait = 'bit' 1426 _arguments = 'table' 1427 1428 def __init__(self, ticket=0, destination='', source='', routing_key='', 1429 nowait=False, arguments=None): 1430 """Initialize the Exchange.Bind class 1431 1432 :param int ticket: Deprecated 1433 :param str destination: 1434 :param str source: 1435 :param str routing-key: 1436 :param bool nowait: Do not send a reply method 1437 :param dict arguments: 1438 1439 """ 1440 # Deprecated 1441 self.ticket = ticket 1442 1443 self.destination = destination 1444 1445 self.source = source 1446 1447 self.routing_key = routing_key 1448 1449 # Do not send a reply method 1450 self.nowait = nowait 1451 1452 self.arguments = arguments or dict() 1453 1454 class BindOk(Frame): 1455 # AMQP Method Number and Mapping Index 1456 frame_id = 31 1457 index = 0x0028001F 1458 name = 'Exchange.BindOk' 1459 1460 # Specifies if this is a synchronous AMQP method 1461 synchronous = False 1462 1463 class Unbind(Frame): 1464 # AMQP Method Number and Mapping Index 1465 frame_id = 40 1466 index = 0x00280028 1467 name = 'Exchange.Unbind' 1468 1469 # Specifies if this is a synchronous AMQP method 1470 synchronous = True 1471 1472 # Valid responses to this method 1473 valid_responses = ['Exchange.UnbindOk'] 1474 1475 # AMQP Method Attributes 1476 __slots__ = ['ticket', 1477 'destination', 1478 'source', 1479 'routing_key', 1480 'nowait', 1481 'arguments'] 1482 1483 # Class Attribute Types 1484 _ticket = 'short' 1485 _destination = 'shortstr' 1486 _source = 'shortstr' 1487 _routing_key = 'shortstr' 1488 _nowait = 'bit' 1489 _arguments = 'table' 1490 1491 def __init__(self, ticket=0, destination='', source='', routing_key='', 1492 nowait=False, arguments=None): 1493 """Initialize the Exchange.Unbind class 1494 1495 :param int ticket: Deprecated 1496 :param str destination: 1497 :param str source: 1498 :param str routing-key: 1499 :param bool nowait: Do not send a reply method 1500 :param dict arguments: 1501 1502 """ 1503 # Deprecated 1504 self.ticket = ticket 1505 1506 self.destination = destination 1507 1508 self.source = source 1509 1510 self.routing_key = routing_key 1511 1512 # Do not send a reply method 1513 self.nowait = nowait 1514 1515 self.arguments = arguments or dict() 1516 1517 class UnbindOk(Frame): 1518 # AMQP Method Number and Mapping Index 1519 frame_id = 51 1520 index = 0x00280033 1521 name = 'Exchange.UnbindOk' 1522 1523 # Specifies if this is a synchronous AMQP method 1524 synchronous = False 1525 1526 1527class Queue(object): 1528 """Work with queues 1529 1530 Queues store and forward messages. Queues can be configured in the server 1531 or created at runtime. Queues must be attached to at least one exchange in 1532 order to receive messages from publishers. 1533 1534 """ 1535 __slots__ = [] 1536 1537 # AMQP Class Number and Mapping Index 1538 frame_id = 50 1539 index = 0x00320000 1540 1541 class Declare(Frame): 1542 """Declare queue, create if needed 1543 1544 This method creates or checks a queue. When creating a new queue the 1545 client can specify various properties that control the durability of 1546 the queue and its contents, and the level of sharing for the queue. 1547 1548 """ 1549 # AMQP Method Number and Mapping Index 1550 frame_id = 10 1551 index = 0x0032000A 1552 name = 'Queue.Declare' 1553 1554 # Specifies if this is a synchronous AMQP method 1555 synchronous = True 1556 1557 # Valid responses to this method 1558 valid_responses = ['Queue.DeclareOk'] 1559 1560 # AMQP Method Attributes 1561 __slots__ = ['ticket', 1562 'queue', 1563 'passive', 1564 'durable', 1565 'exclusive', 1566 'auto_delete', 1567 'nowait', 1568 'arguments'] 1569 1570 # Class Attribute Types 1571 _ticket = 'short' 1572 _queue = 'shortstr' 1573 _passive = 'bit' 1574 _durable = 'bit' 1575 _exclusive = 'bit' 1576 _auto_delete = 'bit' 1577 _nowait = 'bit' 1578 _arguments = 'table' 1579 1580 def __init__(self, ticket=0, queue='', passive=False, durable=False, 1581 exclusive=False, auto_delete=False, nowait=False, 1582 arguments=None): 1583 """Initialize the Queue.Declare class 1584 1585 :param int ticket: Deprecated 1586 :param str queue: 1587 :param bool passive: Do not create queue 1588 :param bool durable: Request a durable queue 1589 :param bool exclusive: Request an exclusive queue 1590 :param bool auto_delete: Auto-delete queue when unused 1591 :param bool nowait: Do not send a reply method 1592 :param dict arguments: Arguments for declaration 1593 1594 """ 1595 # Deprecated 1596 self.ticket = ticket 1597 1598 self.queue = queue 1599 1600 # Do not create queue 1601 self.passive = passive 1602 1603 # Request a durable queue 1604 self.durable = durable 1605 1606 # Request an exclusive queue 1607 self.exclusive = exclusive 1608 1609 # Auto-delete queue when unused 1610 self.auto_delete = auto_delete 1611 1612 # Do not send a reply method 1613 self.nowait = nowait 1614 1615 # Arguments for declaration 1616 self.arguments = arguments or dict() 1617 1618 class DeclareOk(Frame): 1619 """Confirms a queue definition 1620 1621 This method confirms a Declare method and confirms the name of the 1622 queue, essential for automatically-named queues. 1623 1624 """ 1625 # AMQP Method Number and Mapping Index 1626 frame_id = 11 1627 index = 0x0032000B 1628 name = 'Queue.DeclareOk' 1629 1630 # Specifies if this is a synchronous AMQP method 1631 synchronous = False 1632 1633 # AMQP Method Attributes 1634 __slots__ = ['queue', 1635 'message_count', 1636 'consumer_count'] 1637 1638 # Class Attribute Types 1639 _queue = 'shortstr' 1640 _message_count = 'long' 1641 _consumer_count = 'long' 1642 1643 def __init__(self, queue='', message_count=0, consumer_count=0): 1644 """Initialize the Queue.DeclareOk class 1645 1646 :param str queue: 1647 :param int/long message_count: Number of messages in queue 1648 :param int/long consumer_count: Number of consumers 1649 1650 """ 1651 self.queue = queue 1652 1653 # Number of messages in queue 1654 self.message_count = message_count 1655 1656 # Number of consumers 1657 self.consumer_count = consumer_count 1658 1659 class Bind(Frame): 1660 """Bind queue to an exchange 1661 1662 This method binds a queue to an exchange. Until a queue is bound it 1663 will not receive any messages. In a classic messaging model, store-and- 1664 forward queues are bound to a direct exchange and subscription queues 1665 are bound to a topic exchange. 1666 1667 """ 1668 # AMQP Method Number and Mapping Index 1669 frame_id = 20 1670 index = 0x00320014 1671 name = 'Queue.Bind' 1672 1673 # Specifies if this is a synchronous AMQP method 1674 synchronous = True 1675 1676 # Valid responses to this method 1677 valid_responses = ['Queue.BindOk'] 1678 1679 # AMQP Method Attributes 1680 __slots__ = ['ticket', 1681 'queue', 1682 'exchange', 1683 'routing_key', 1684 'nowait', 1685 'arguments'] 1686 1687 # Class Attribute Types 1688 _ticket = 'short' 1689 _queue = 'shortstr' 1690 _exchange = 'shortstr' 1691 _routing_key = 'shortstr' 1692 _nowait = 'bit' 1693 _arguments = 'table' 1694 1695 def __init__(self, ticket=0, queue='', exchange='', routing_key='', 1696 nowait=False, arguments=None): 1697 """Initialize the Queue.Bind class 1698 1699 :param int ticket: Deprecated 1700 :param str queue: 1701 :param str exchange: Name of the exchange to bind to 1702 :param str routing_key: Message routing key 1703 :param bool nowait: Do not send a reply method 1704 :param dict arguments: Arguments for binding 1705 1706 """ 1707 # Deprecated 1708 self.ticket = ticket 1709 1710 self.queue = queue 1711 1712 # Name of the exchange to bind to 1713 self.exchange = exchange 1714 1715 # Message routing key 1716 self.routing_key = routing_key 1717 1718 # Do not send a reply method 1719 self.nowait = nowait 1720 1721 # Arguments for binding 1722 self.arguments = arguments or dict() 1723 1724 class BindOk(Frame): 1725 """Confirm bind successful 1726 1727 This method confirms that the bind was successful. 1728 1729 """ 1730 # AMQP Method Number and Mapping Index 1731 frame_id = 21 1732 index = 0x00320015 1733 name = 'Queue.BindOk' 1734 1735 # Specifies if this is a synchronous AMQP method 1736 synchronous = False 1737 1738 class Purge(Frame): 1739 """Purge a queue 1740 1741 This method removes all messages from a queue which are not awaiting 1742 acknowledgment. 1743 1744 """ 1745 # AMQP Method Number and Mapping Index 1746 frame_id = 30 1747 index = 0x0032001E 1748 name = 'Queue.Purge' 1749 1750 # Specifies if this is a synchronous AMQP method 1751 synchronous = True 1752 1753 # Valid responses to this method 1754 valid_responses = ['Queue.PurgeOk'] 1755 1756 # AMQP Method Attributes 1757 __slots__ = ['ticket', 1758 'queue', 1759 'nowait'] 1760 1761 # Class Attribute Types 1762 _ticket = 'short' 1763 _queue = 'shortstr' 1764 _nowait = 'bit' 1765 1766 def __init__(self, ticket=0, queue='', nowait=False): 1767 """Initialize the Queue.Purge class 1768 1769 :param int ticket: Deprecated 1770 :param str queue: 1771 :param bool nowait: Do not send a reply method 1772 1773 """ 1774 # Deprecated 1775 self.ticket = ticket 1776 1777 self.queue = queue 1778 1779 # Do not send a reply method 1780 self.nowait = nowait 1781 1782 class PurgeOk(Frame): 1783 """Confirms a queue purge 1784 1785 This method confirms the purge of a queue. 1786 1787 """ 1788 # AMQP Method Number and Mapping Index 1789 frame_id = 31 1790 index = 0x0032001F 1791 name = 'Queue.PurgeOk' 1792 1793 # Specifies if this is a synchronous AMQP method 1794 synchronous = False 1795 1796 # AMQP Method Attributes 1797 __slots__ = ['message_count'] 1798 1799 # Class Attribute Types 1800 _message_count = 'long' 1801 1802 def __init__(self, message_count=0): 1803 """Initialize the Queue.PurgeOk class 1804 1805 :param int/long message-count: 1806 1807 """ 1808 self.message_count = message_count 1809 1810 class Delete(Frame): 1811 """Delete a queue 1812 1813 This method deletes a queue. When a queue is deleted any pending 1814 messages are sent to a dead-letter queue if this is defined in the 1815 server configuration, and all consumers on the queue are cancelled. 1816 1817 """ 1818 # AMQP Method Number and Mapping Index 1819 frame_id = 40 1820 index = 0x00320028 1821 name = 'Queue.Delete' 1822 1823 # Specifies if this is a synchronous AMQP method 1824 synchronous = True 1825 1826 # Valid responses to this method 1827 valid_responses = ['Queue.DeleteOk'] 1828 1829 # AMQP Method Attributes 1830 __slots__ = ['ticket', 1831 'queue', 1832 'if_unused', 1833 'if_empty', 1834 'nowait'] 1835 1836 # Class Attribute Types 1837 _ticket = 'short' 1838 _queue = 'shortstr' 1839 _if_unused = 'bit' 1840 _if_empty = 'bit' 1841 _nowait = 'bit' 1842 1843 def __init__(self, ticket=0, queue='', if_unused=False, if_empty=False, 1844 nowait=False): 1845 """Initialize the Queue.Delete class 1846 1847 :param int ticket: Deprecated 1848 :param str queue: 1849 :param bool if_unused: Delete only if unused 1850 :param bool if_empty: Delete only if empty 1851 :param bool nowait: Do not send a reply method 1852 1853 """ 1854 # Deprecated 1855 self.ticket = ticket 1856 1857 self.queue = queue 1858 1859 # Delete only if unused 1860 self.if_unused = if_unused 1861 1862 # Delete only if empty 1863 self.if_empty = if_empty 1864 1865 # Do not send a reply method 1866 self.nowait = nowait 1867 1868 class DeleteOk(Frame): 1869 """Confirm deletion of a queue 1870 1871 This method confirms the deletion of a queue. 1872 1873 """ 1874 # AMQP Method Number and Mapping Index 1875 frame_id = 41 1876 index = 0x00320029 1877 name = 'Queue.DeleteOk' 1878 1879 # Specifies if this is a synchronous AMQP method 1880 synchronous = False 1881 1882 # AMQP Method Attributes 1883 __slots__ = ['message_count'] 1884 1885 # Class Attribute Types 1886 _message_count = 'long' 1887 1888 def __init__(self, message_count=0): 1889 """Initialize the Queue.DeleteOk class 1890 1891 :param int/long message-count: 1892 1893 """ 1894 self.message_count = message_count 1895 1896 class Unbind(Frame): 1897 """Unbind a queue from an exchange 1898 1899 This method unbinds a queue from an exchange. 1900 1901 """ 1902 # AMQP Method Number and Mapping Index 1903 frame_id = 50 1904 index = 0x00320032 1905 name = 'Queue.Unbind' 1906 1907 # Specifies if this is a synchronous AMQP method 1908 synchronous = True 1909 1910 # Valid responses to this method 1911 valid_responses = ['Queue.UnbindOk'] 1912 1913 # AMQP Method Attributes 1914 __slots__ = ['ticket', 1915 'queue', 1916 'exchange', 1917 'routing_key', 1918 'arguments'] 1919 1920 # Class Attribute Types 1921 _ticket = 'short' 1922 _queue = 'shortstr' 1923 _exchange = 'shortstr' 1924 _routing_key = 'shortstr' 1925 _arguments = 'table' 1926 1927 def __init__(self, ticket=0, queue='', exchange='', routing_key='', 1928 arguments=None): 1929 """Initialize the Queue.Unbind class 1930 1931 :param int ticket: Deprecated 1932 :param str queue: 1933 :param str exchange: 1934 :param str routing_key: Routing key of binding 1935 :param dict arguments: Arguments of binding 1936 1937 """ 1938 # Deprecated 1939 self.ticket = ticket 1940 1941 self.queue = queue 1942 1943 self.exchange = exchange 1944 1945 # Routing key of binding 1946 self.routing_key = routing_key 1947 1948 # Arguments of binding 1949 self.arguments = arguments or dict() 1950 1951 class UnbindOk(Frame): 1952 """Confirm unbind successful 1953 1954 This method confirms that the unbind was successful. 1955 1956 """ 1957 # AMQP Method Number and Mapping Index 1958 frame_id = 51 1959 index = 0x00320033 1960 name = 'Queue.UnbindOk' 1961 1962 # Specifies if this is a synchronous AMQP method 1963 synchronous = False 1964 1965 1966class Basic(object): 1967 """Work with basic content 1968 1969 The Basic class provides methods that support an industry-standard 1970 messaging model. 1971 1972 """ 1973 __slots__ = [] 1974 1975 # AMQP Class Number and Mapping Index 1976 frame_id = 60 1977 index = 0x003C0000 1978 1979 class Qos(Frame): 1980 """Specify quality of service 1981 1982 This method requests a specific quality of service. The QoS can be 1983 specified for the current channel or for all channels on the 1984 connection. The particular properties and semantics of a qos method 1985 always depend on the content class semantics. Though the qos method 1986 could in principle apply to both peers, it is currently meaningful only 1987 for the server. 1988 1989 """ 1990 # AMQP Method Number and Mapping Index 1991 frame_id = 10 1992 index = 0x003C000A 1993 name = 'Basic.Qos' 1994 1995 # Specifies if this is a synchronous AMQP method 1996 synchronous = True 1997 1998 # Valid responses to this method 1999 valid_responses = ['Basic.QosOk'] 2000 2001 # AMQP Method Attributes 2002 __slots__ = ['prefetch_size', 2003 'prefetch_count', 2004 'global_'] 2005 2006 # Class Attribute Types 2007 _prefetch_size = 'long' 2008 _prefetch_count = 'short' 2009 _global_ = 'bit' 2010 2011 def __init__(self, prefetch_size=0, prefetch_count=0, global_=False): 2012 """Initialize the Basic.Qos class 2013 2014 :param int/long prefetch_size: Prefetch window in octets 2015 :param int prefetch_count: Prefetch window in messages 2016 :param bool global_: Apply to entire connection 2017 2018 """ 2019 # Prefetch window in octets 2020 self.prefetch_size = prefetch_size 2021 2022 # Prefetch window in messages 2023 self.prefetch_count = prefetch_count 2024 2025 # Apply to entire connection 2026 self.global_ = global_ 2027 2028 class QosOk(Frame): 2029 """Confirm the requested qos 2030 2031 This method tells the client that the requested QoS levels could be 2032 handled by the server. The requested QoS applies to all active 2033 consumers until a new QoS is defined. 2034 2035 """ 2036 # AMQP Method Number and Mapping Index 2037 frame_id = 11 2038 index = 0x003C000B 2039 name = 'Basic.QosOk' 2040 2041 # Specifies if this is a synchronous AMQP method 2042 synchronous = False 2043 2044 class Consume(Frame): 2045 """Start a queue consumer 2046 2047 This method asks the server to start a "consumer", which is a transient 2048 request for messages from a specific queue. Consumers last as long as 2049 the channel they were declared on, or until the client cancels them. 2050 2051 """ 2052 # AMQP Method Number and Mapping Index 2053 frame_id = 20 2054 index = 0x003C0014 2055 name = 'Basic.Consume' 2056 2057 # Specifies if this is a synchronous AMQP method 2058 synchronous = True 2059 2060 # Valid responses to this method 2061 valid_responses = ['Basic.ConsumeOk'] 2062 2063 # AMQP Method Attributes 2064 __slots__ = ['ticket', 2065 'queue', 2066 'consumer_tag', 2067 'no_local', 2068 'no_ack', 2069 'exclusive', 2070 'nowait', 2071 'arguments'] 2072 2073 # Class Attribute Types 2074 _ticket = 'short' 2075 _queue = 'shortstr' 2076 _consumer_tag = 'shortstr' 2077 _no_local = 'bit' 2078 _no_ack = 'bit' 2079 _exclusive = 'bit' 2080 _nowait = 'bit' 2081 _arguments = 'table' 2082 2083 def __init__(self, ticket=0, queue='', consumer_tag='', no_local=False, 2084 no_ack=False, exclusive=False, nowait=False, 2085 arguments=None): 2086 """Initialize the Basic.Consume class 2087 2088 :param int ticket: Deprecated 2089 :param str queue: 2090 :param str consumer-tag: 2091 :param bool no_local: Do not deliver own messages 2092 :param bool no_ack: No acknowledgement needed 2093 :param bool exclusive: Request exclusive access 2094 :param bool nowait: Do not send a reply method 2095 :param dict arguments: Arguments for declaration 2096 2097 """ 2098 # Deprecated 2099 self.ticket = ticket 2100 2101 self.queue = queue 2102 2103 self.consumer_tag = consumer_tag 2104 2105 # Do not deliver own messages 2106 self.no_local = no_local 2107 2108 # No acknowledgement needed 2109 self.no_ack = no_ack 2110 2111 # Request exclusive access 2112 self.exclusive = exclusive 2113 2114 # Do not send a reply method 2115 self.nowait = nowait 2116 2117 # Arguments for declaration 2118 self.arguments = arguments or dict() 2119 2120 class ConsumeOk(Frame): 2121 """Confirm a new consumer 2122 2123 The server provides the client with a consumer tag, which is used by 2124 the client for methods called on the consumer at a later stage. 2125 2126 """ 2127 # AMQP Method Number and Mapping Index 2128 frame_id = 21 2129 index = 0x003C0015 2130 name = 'Basic.ConsumeOk' 2131 2132 # Specifies if this is a synchronous AMQP method 2133 synchronous = False 2134 2135 # AMQP Method Attributes 2136 __slots__ = ['consumer_tag'] 2137 2138 # Class Attribute Types 2139 _consumer_tag = 'shortstr' 2140 2141 def __init__(self, consumer_tag=''): 2142 """Initialize the Basic.ConsumeOk class 2143 2144 :param str consumer-tag: 2145 2146 """ 2147 self.consumer_tag = consumer_tag 2148 2149 class Cancel(Frame): 2150 """End a queue consumer 2151 2152 This method cancels a consumer. This does not affect already delivered 2153 messages, but it does mean the server will not send any more messages 2154 for that consumer. The client may receive an arbitrary number of 2155 messages in between sending the cancel method and receiving the cancel- 2156 ok reply. 2157 2158 """ 2159 # AMQP Method Number and Mapping Index 2160 frame_id = 30 2161 index = 0x003C001E 2162 name = 'Basic.Cancel' 2163 2164 # Specifies if this is a synchronous AMQP method 2165 synchronous = True 2166 2167 # Valid responses to this method 2168 valid_responses = ['Basic.CancelOk'] 2169 2170 # AMQP Method Attributes 2171 __slots__ = ['consumer_tag', 2172 'nowait'] 2173 2174 # Class Attribute Types 2175 _consumer_tag = 'shortstr' 2176 _nowait = 'bit' 2177 2178 def __init__(self, consumer_tag='', nowait=False): 2179 """Initialize the Basic.Cancel class 2180 2181 :param str consumer_tag: Consumer tag 2182 :param bool nowait: Do not send a reply method 2183 2184 """ 2185 # Consumer tag 2186 self.consumer_tag = consumer_tag 2187 2188 # Do not send a reply method 2189 self.nowait = nowait 2190 2191 class CancelOk(Frame): 2192 """Confirm a cancelled consumer 2193 2194 This method confirms that the cancellation was completed. 2195 2196 """ 2197 # AMQP Method Number and Mapping Index 2198 frame_id = 31 2199 index = 0x003C001F 2200 name = 'Basic.CancelOk' 2201 2202 # Specifies if this is a synchronous AMQP method 2203 synchronous = False 2204 2205 # AMQP Method Attributes 2206 __slots__ = ['consumer_tag'] 2207 2208 # Class Attribute Types 2209 _consumer_tag = 'shortstr' 2210 2211 def __init__(self, consumer_tag=''): 2212 """Initialize the Basic.CancelOk class 2213 2214 :param str consumer_tag: Consumer tag 2215 2216 """ 2217 # Consumer tag 2218 self.consumer_tag = consumer_tag 2219 2220 class Publish(Frame): 2221 """Publish a message 2222 2223 This method publishes a message to a specific exchange. The message 2224 will be routed to queues as defined by the exchange configuration and 2225 distributed to any active consumers when the transaction, if any, is 2226 committed. 2227 2228 """ 2229 # AMQP Method Number and Mapping Index 2230 frame_id = 40 2231 index = 0x003C0028 2232 name = 'Basic.Publish' 2233 2234 # Specifies if this is a synchronous AMQP method 2235 synchronous = False 2236 2237 # AMQP Method Attributes 2238 __slots__ = ['ticket', 2239 'exchange', 2240 'routing_key', 2241 'mandatory', 2242 'immediate'] 2243 2244 # Class Attribute Types 2245 _ticket = 'short' 2246 _exchange = 'shortstr' 2247 _routing_key = 'shortstr' 2248 _mandatory = 'bit' 2249 _immediate = 'bit' 2250 2251 def __init__(self, ticket=0, exchange='', routing_key='', 2252 mandatory=False, immediate=False): 2253 """Initialize the Basic.Publish class 2254 2255 :param int ticket: Deprecated 2256 :param str exchange: 2257 :param str routing_key: Message routing key 2258 :param bool mandatory: Indicate mandatory routing 2259 :param bool immediate: Request immediate delivery 2260 2261 """ 2262 # Deprecated 2263 self.ticket = ticket 2264 2265 self.exchange = exchange 2266 2267 # Message routing key 2268 self.routing_key = routing_key 2269 2270 # Indicate mandatory routing 2271 self.mandatory = mandatory 2272 2273 # Request immediate delivery 2274 self.immediate = immediate 2275 2276 class Return(Frame): 2277 """Return a failed message 2278 2279 This method returns an undeliverable message that was published with 2280 the "immediate" flag set, or an unroutable message published with the 2281 "mandatory" flag set. The reply code and text provide information about 2282 the reason that the message was undeliverable. 2283 2284 """ 2285 # AMQP Method Number and Mapping Index 2286 frame_id = 50 2287 index = 0x003C0032 2288 name = 'Basic.Return' 2289 2290 # Specifies if this is a synchronous AMQP method 2291 synchronous = False 2292 2293 # AMQP Method Attributes 2294 __slots__ = ['reply_code', 2295 'reply_text', 2296 'exchange', 2297 'routing_key'] 2298 2299 # Class Attribute Types 2300 _reply_code = 'short' 2301 _reply_text = 'shortstr' 2302 _exchange = 'shortstr' 2303 _routing_key = 'shortstr' 2304 2305 def __init__(self, reply_code=0, reply_text='', exchange='', 2306 routing_key=''): 2307 """Initialize the Basic.Return class 2308 2309 :param int reply_code: Reply code from server 2310 :param str reply_text: Localised reply text 2311 :param str exchange: 2312 :param str routing_key: Message routing key 2313 2314 """ 2315 # Reply code from server 2316 self.reply_code = reply_code 2317 2318 # Localised reply text 2319 self.reply_text = reply_text 2320 2321 self.exchange = exchange 2322 2323 # Message routing key 2324 self.routing_key = routing_key 2325 2326 class Deliver(Frame): 2327 """Notify the client of a consumer message 2328 2329 This method delivers a message to the client, via a consumer. In the 2330 asynchronous message delivery model, the client starts a consumer using 2331 the Consume method, then the server responds with Deliver methods as 2332 and when messages arrive for that consumer. 2333 2334 """ 2335 # AMQP Method Number and Mapping Index 2336 frame_id = 60 2337 index = 0x003C003C 2338 name = 'Basic.Deliver' 2339 2340 # Specifies if this is a synchronous AMQP method 2341 synchronous = False 2342 2343 # AMQP Method Attributes 2344 __slots__ = ['consumer_tag', 2345 'delivery_tag', 2346 'redelivered', 2347 'exchange', 2348 'routing_key'] 2349 2350 # Class Attribute Types 2351 _consumer_tag = 'shortstr' 2352 _delivery_tag = 'longlong' 2353 _redelivered = 'bit' 2354 _exchange = 'shortstr' 2355 _routing_key = 'shortstr' 2356 2357 def __init__(self, consumer_tag='', delivery_tag=None, 2358 redelivered=False, exchange='', routing_key=''): 2359 """Initialize the Basic.Deliver class 2360 2361 :param str consumer_tag: Consumer tag 2362 :param int/long delivery_tag: Server-assigned delivery tag 2363 :param bool redelivered: Message is being redelivered 2364 :param str exchange: 2365 :param str routing_key: Message routing key 2366 2367 """ 2368 # Consumer tag 2369 self.consumer_tag = consumer_tag 2370 2371 # Server-assigned delivery tag 2372 self.delivery_tag = delivery_tag 2373 2374 # Message is being redelivered 2375 self.redelivered = redelivered 2376 2377 self.exchange = exchange 2378 2379 # Message routing key 2380 self.routing_key = routing_key 2381 2382 class Get(Frame): 2383 """Direct access to a queue 2384 2385 This method provides a direct access to the messages in a queue using a 2386 synchronous dialogue that is designed for specific types of application 2387 where synchronous functionality is more important than performance. 2388 2389 """ 2390 # AMQP Method Number and Mapping Index 2391 frame_id = 70 2392 index = 0x003C0046 2393 name = 'Basic.Get' 2394 2395 # Specifies if this is a synchronous AMQP method 2396 synchronous = True 2397 2398 # Valid responses to this method 2399 valid_responses = ['Basic.GetOk', 'Basic.GetEmpty'] 2400 2401 # AMQP Method Attributes 2402 __slots__ = ['ticket', 2403 'queue', 2404 'no_ack'] 2405 2406 # Class Attribute Types 2407 _ticket = 'short' 2408 _queue = 'shortstr' 2409 _no_ack = 'bit' 2410 2411 def __init__(self, ticket=0, queue='', no_ack=False): 2412 """Initialize the Basic.Get class 2413 2414 :param int ticket: Deprecated 2415 :param str queue: 2416 :param bool no_ack: No acknowledgement needed 2417 2418 """ 2419 # Deprecated 2420 self.ticket = ticket 2421 2422 self.queue = queue 2423 2424 # No acknowledgement needed 2425 self.no_ack = no_ack 2426 2427 class GetOk(Frame): 2428 """Provide client with a message 2429 2430 This method delivers a message to the client following a get method. A 2431 message delivered by 'get-ok' must be acknowledged unless the no-ack 2432 option was set in the get method. 2433 2434 """ 2435 # AMQP Method Number and Mapping Index 2436 frame_id = 71 2437 index = 0x003C0047 2438 name = 'Basic.GetOk' 2439 2440 # Specifies if this is a synchronous AMQP method 2441 synchronous = False 2442 2443 # AMQP Method Attributes 2444 __slots__ = ['delivery_tag', 2445 'redelivered', 2446 'exchange', 2447 'routing_key', 2448 'message_count'] 2449 2450 # Class Attribute Types 2451 _delivery_tag = 'longlong' 2452 _redelivered = 'bit' 2453 _exchange = 'shortstr' 2454 _routing_key = 'shortstr' 2455 _message_count = 'long' 2456 2457 def __init__(self, delivery_tag=None, redelivered=False, exchange='', 2458 routing_key='', message_count=0): 2459 """Initialize the Basic.GetOk class 2460 2461 :param int/long delivery_tag: Server-assigned delivery tag 2462 :param bool redelivered: Message is being redelivered 2463 :param str exchange: 2464 :param str routing_key: Message routing key 2465 :param int/long message_count: Number of messages in queue 2466 2467 """ 2468 # Server-assigned delivery tag 2469 self.delivery_tag = delivery_tag 2470 2471 # Message is being redelivered 2472 self.redelivered = redelivered 2473 2474 self.exchange = exchange 2475 2476 # Message routing key 2477 self.routing_key = routing_key 2478 2479 # Number of messages in queue 2480 self.message_count = message_count 2481 2482 class GetEmpty(Frame): 2483 """Indicate no messages available 2484 2485 This method tells the client that the queue has no messages available 2486 for the client. 2487 2488 """ 2489 # AMQP Method Number and Mapping Index 2490 frame_id = 72 2491 index = 0x003C0048 2492 name = 'Basic.GetEmpty' 2493 2494 # Specifies if this is a synchronous AMQP method 2495 synchronous = False 2496 2497 # AMQP Method Attributes 2498 __slots__ = ['cluster_id'] 2499 2500 # Class Attribute Types 2501 _cluster_id = 'shortstr' 2502 2503 def __init__(self, cluster_id=''): 2504 """Initialize the Basic.GetEmpty class 2505 2506 :param str cluster_id: Deprecated 2507 2508 """ 2509 # Deprecated 2510 self.cluster_id = cluster_id 2511 2512 class Ack(Frame): 2513 """Acknowledge one or more messages 2514 2515 This method acknowledges one or more messages delivered via the Deliver 2516 or Get-Ok methods. The client can ask to confirm a single message or a 2517 set of messages up to and including a specific message. 2518 2519 """ 2520 # AMQP Method Number and Mapping Index 2521 frame_id = 80 2522 index = 0x003C0050 2523 name = 'Basic.Ack' 2524 2525 # Specifies if this is a synchronous AMQP method 2526 synchronous = False 2527 2528 # AMQP Method Attributes 2529 __slots__ = ['delivery_tag', 2530 'multiple'] 2531 2532 # Class Attribute Types 2533 _delivery_tag = 'longlong' 2534 _multiple = 'bit' 2535 2536 def __init__(self, delivery_tag=0, multiple=False): 2537 """Initialize the Basic.Ack class 2538 2539 :param int/long delivery_tag: Server-assigned delivery tag 2540 :param bool multiple: Acknowledge multiple messages 2541 2542 """ 2543 # Server-assigned delivery tag 2544 self.delivery_tag = delivery_tag 2545 2546 # Acknowledge multiple messages 2547 self.multiple = multiple 2548 2549 class Reject(Frame): 2550 """Reject an incoming message 2551 2552 This method allows a client to reject a message. It can be used to 2553 interrupt and cancel large incoming messages, or return untreatable 2554 messages to their original queue. 2555 2556 """ 2557 # AMQP Method Number and Mapping Index 2558 frame_id = 90 2559 index = 0x003C005A 2560 name = 'Basic.Reject' 2561 2562 # Specifies if this is a synchronous AMQP method 2563 synchronous = False 2564 2565 # AMQP Method Attributes 2566 __slots__ = ['delivery_tag', 2567 'requeue'] 2568 2569 # Class Attribute Types 2570 _delivery_tag = 'longlong' 2571 _requeue = 'bit' 2572 2573 def __init__(self, delivery_tag=None, requeue=True): 2574 """Initialize the Basic.Reject class 2575 2576 :param int/long delivery_tag: Server-assigned delivery tag 2577 :param bool requeue: Requeue the message 2578 2579 """ 2580 # Server-assigned delivery tag 2581 self.delivery_tag = delivery_tag 2582 2583 # Requeue the message 2584 self.requeue = requeue 2585 2586 class RecoverAsync(Frame): 2587 """Redeliver unacknowledged messages 2588 2589 This method asks the server to redeliver all unacknowledged messages on 2590 a specified channel. Zero or more messages may be redelivered. This 2591 method is deprecated in favour of the synchronous Recover/Recover-Ok. 2592 2593 """ 2594 # AMQP Method Number and Mapping Index 2595 frame_id = 100 2596 index = 0x003C0064 2597 name = 'Basic.RecoverAsync' 2598 2599 # Specifies if this is a synchronous AMQP method 2600 synchronous = False 2601 2602 # AMQP Method Attributes 2603 __slots__ = ['requeue'] 2604 2605 # Class Attribute Types 2606 _requeue = 'bit' 2607 2608 def __init__(self, requeue=False): 2609 """Initialize the Basic.RecoverAsync class 2610 2611 :param bool requeue: Requeue the message 2612 2613 :raises: DeprecationWarning 2614 2615 """ 2616 # Requeue the message 2617 self.requeue = requeue 2618 2619 # This command is deprecated in AMQP 0-9-1 2620 raise DeprecationWarning(DEPRECATION_WARNING) 2621 2622 class Recover(Frame): 2623 """Redeliver unacknowledged messages 2624 2625 This method asks the server to redeliver all unacknowledged messages on 2626 a specified channel. Zero or more messages may be redelivered. This 2627 method replaces the asynchronous Recover. 2628 2629 """ 2630 # AMQP Method Number and Mapping Index 2631 frame_id = 110 2632 index = 0x003C006E 2633 name = 'Basic.Recover' 2634 2635 # Specifies if this is a synchronous AMQP method 2636 synchronous = True 2637 2638 # Valid responses to this method 2639 valid_responses = ['Basic.RecoverOk'] 2640 2641 # AMQP Method Attributes 2642 __slots__ = ['requeue'] 2643 2644 # Class Attribute Types 2645 _requeue = 'bit' 2646 2647 def __init__(self, requeue=False): 2648 """Initialize the Basic.Recover class 2649 2650 :param bool requeue: Requeue the message 2651 2652 """ 2653 # Requeue the message 2654 self.requeue = requeue 2655 2656 class RecoverOk(Frame): 2657 """Confirm recovery 2658 2659 This method acknowledges a Basic.Recover method. 2660 2661 """ 2662 # AMQP Method Number and Mapping Index 2663 frame_id = 111 2664 index = 0x003C006F 2665 name = 'Basic.RecoverOk' 2666 2667 # Specifies if this is a synchronous AMQP method 2668 synchronous = False 2669 2670 class Nack(Frame): 2671 # AMQP Method Number and Mapping Index 2672 frame_id = 120 2673 index = 0x003C0078 2674 name = 'Basic.Nack' 2675 2676 # Specifies if this is a synchronous AMQP method 2677 synchronous = False 2678 2679 # AMQP Method Attributes 2680 __slots__ = ['delivery_tag', 2681 'multiple', 2682 'requeue'] 2683 2684 # Class Attribute Types 2685 _delivery_tag = 'longlong' 2686 _multiple = 'bit' 2687 _requeue = 'bit' 2688 2689 def __init__(self, delivery_tag=0, multiple=False, requeue=True): 2690 """Initialize the Basic.Nack class 2691 2692 :param int/long delivery_tag: Server-assigned delivery tag 2693 :param bool multiple: 2694 :param bool requeue: 2695 2696 """ 2697 # Server-assigned delivery tag 2698 self.delivery_tag = delivery_tag 2699 2700 self.multiple = multiple 2701 2702 self.requeue = requeue 2703 2704 class Properties(PropertiesBase): 2705 """Content Properties""" 2706 2707 name = 'Basic.Properties' 2708 2709 __slots__ = ['content_type', 2710 'content_encoding', 2711 'headers', 2712 'delivery_mode', 2713 'priority', 2714 'correlation_id', 2715 'reply_to', 2716 'expiration', 2717 'message_id', 2718 'timestamp', 2719 'message_type', 2720 'user_id', 2721 'app_id', 2722 'cluster_id'] 2723 2724 # Flag Values 2725 flags = {'content_type': 32768, 2726 'content_encoding': 16384, 2727 'headers': 8192, 2728 'delivery_mode': 4096, 2729 'priority': 2048, 2730 'correlation_id': 1024, 2731 'reply_to': 512, 2732 'expiration': 256, 2733 'message_id': 128, 2734 'timestamp': 64, 2735 'message_type': 32, 2736 'user_id': 16, 2737 'app_id': 8, 2738 'cluster_id': 4} 2739 2740 # Class Attribute Types 2741 _content_type = 'shortstr' 2742 _content_encoding = 'shortstr' 2743 _headers = 'table' 2744 _delivery_mode = 'octet' 2745 _priority = 'octet' 2746 _correlation_id = 'shortstr' 2747 _reply_to = 'shortstr' 2748 _expiration = 'shortstr' 2749 _message_id = 'shortstr' 2750 _timestamp = 'timestamp' 2751 _message_type = 'shortstr' 2752 _user_id = 'shortstr' 2753 _app_id = 'shortstr' 2754 _cluster_id = 'shortstr' 2755 2756 frame_id = 60 2757 index = 0x003C 2758 2759 def __init__(self, content_type='', content_encoding='', headers=None, 2760 delivery_mode=None, priority=None, correlation_id='', 2761 reply_to='', expiration='', message_id='', timestamp=None, 2762 message_type='', user_id='', app_id='', cluster_id=''): 2763 """Initialize the Basic.Properties class 2764 2765 Note that the AMQP property type is named message_type as to 2766 not conflict with the Python type keyword 2767 2768 :param str content_type: MIME content type 2769 :param str content_encoding: MIME content encoding 2770 :param dict headers: Message header field table 2771 :param int delivery_mode: Non-persistent (1) or persistent (2) 2772 :param int priority: Message priority, 0 to 9 2773 :param str correlation_id: Application correlation identifier 2774 :param str reply_to: Address to reply to 2775 :param str expiration: Message expiration specification 2776 :param str message_id: Application message identifier 2777 :param struct_time timestamp: Message timestamp 2778 :param str message_type: Message type name 2779 :param str user_id: Creating user id 2780 :param str app_id: Creating application id 2781 :param str cluster_id: Deprecated 2782 2783 """ 2784 # MIME content type 2785 self.content_type = content_type 2786 2787 # MIME content encoding 2788 self.content_encoding = content_encoding 2789 2790 # Message header field table 2791 self.headers = headers 2792 2793 # Non-persistent (1) or persistent (2) 2794 self.delivery_mode = delivery_mode 2795 2796 # Message priority, 0 to 9 2797 self.priority = priority 2798 2799 # Application correlation identifier 2800 self.correlation_id = correlation_id 2801 2802 # Address to reply to 2803 self.reply_to = reply_to 2804 2805 # Message expiration specification 2806 self.expiration = expiration 2807 2808 # Application message identifier 2809 self.message_id = message_id 2810 2811 # Message timestamp 2812 self.timestamp = timestamp 2813 2814 # Message type name 2815 self.message_type = message_type 2816 2817 # Creating user id 2818 self.user_id = user_id 2819 2820 # Creating application id 2821 self.app_id = app_id 2822 2823 # Deprecated 2824 self.cluster_id = cluster_id 2825 2826 2827class Tx(object): 2828 """Work with transactions 2829 2830 The Tx class allows publish and ack operations to be batched into atomic 2831 units of work. The intention is that all publish and ack requests issued 2832 within a transaction will complete successfully or none of them will. 2833 Servers SHOULD implement atomic transactions at least where all publish or 2834 ack requests affect a single queue. Transactions that cover multiple 2835 queues may be non-atomic, given that queues can be created and destroyed 2836 asynchronously, and such events do not form part of any transaction. 2837 Further, the behaviour of transactions with respect to the immediate and 2838 mandatory flags on Basic.Publish methods is not defined. 2839 2840 """ 2841 __slots__ = [] 2842 2843 # AMQP Class Number and Mapping Index 2844 frame_id = 90 2845 index = 0x005A0000 2846 2847 class Select(Frame): 2848 """Select standard transaction mode 2849 2850 This method sets the channel to use standard transactions. The client 2851 must use this method at least once on a channel before using the Commit 2852 or Rollback methods. 2853 2854 """ 2855 # AMQP Method Number and Mapping Index 2856 frame_id = 10 2857 index = 0x005A000A 2858 name = 'Tx.Select' 2859 2860 # Specifies if this is a synchronous AMQP method 2861 synchronous = True 2862 2863 # Valid responses to this method 2864 valid_responses = ['Tx.SelectOk'] 2865 2866 class SelectOk(Frame): 2867 """Confirm transaction mode 2868 2869 This method confirms to the client that the channel was successfully 2870 set to use standard transactions. 2871 2872 """ 2873 # AMQP Method Number and Mapping Index 2874 frame_id = 11 2875 index = 0x005A000B 2876 name = 'Tx.SelectOk' 2877 2878 # Specifies if this is a synchronous AMQP method 2879 synchronous = False 2880 2881 class Commit(Frame): 2882 """Commit the current transaction 2883 2884 This method commits all message publications and acknowledgments 2885 performed in the current transaction. A new transaction starts 2886 immediately after a commit. 2887 2888 """ 2889 # AMQP Method Number and Mapping Index 2890 frame_id = 20 2891 index = 0x005A0014 2892 name = 'Tx.Commit' 2893 2894 # Specifies if this is a synchronous AMQP method 2895 synchronous = True 2896 2897 # Valid responses to this method 2898 valid_responses = ['Tx.CommitOk'] 2899 2900 class CommitOk(Frame): 2901 """Confirm a successful commit 2902 2903 This method confirms to the client that the commit succeeded. Note that 2904 if a commit fails, the server raises a channel exception. 2905 2906 """ 2907 # AMQP Method Number and Mapping Index 2908 frame_id = 21 2909 index = 0x005A0015 2910 name = 'Tx.CommitOk' 2911 2912 # Specifies if this is a synchronous AMQP method 2913 synchronous = False 2914 2915 class Rollback(Frame): 2916 """Abandon the current transaction 2917 2918 This method abandons all message publications and acknowledgments 2919 performed in the current transaction. A new transaction starts 2920 immediately after a rollback. Note that unacked messages will not be 2921 automatically redelivered by rollback; if that is required an explicit 2922 recover call should be issued. 2923 2924 """ 2925 # AMQP Method Number and Mapping Index 2926 frame_id = 30 2927 index = 0x005A001E 2928 name = 'Tx.Rollback' 2929 2930 # Specifies if this is a synchronous AMQP method 2931 synchronous = True 2932 2933 # Valid responses to this method 2934 valid_responses = ['Tx.RollbackOk'] 2935 2936 class RollbackOk(Frame): 2937 """Confirm successful rollback 2938 2939 This method confirms to the client that the rollback succeeded. Note 2940 that if an rollback fails, the server raises a channel exception. 2941 2942 """ 2943 # AMQP Method Number and Mapping Index 2944 frame_id = 31 2945 index = 0x005A001F 2946 name = 'Tx.RollbackOk' 2947 2948 # Specifies if this is a synchronous AMQP method 2949 synchronous = False 2950 2951 2952class Confirm(object): 2953 __slots__ = [] 2954 2955 # AMQP Class Number and Mapping Index 2956 frame_id = 85 2957 index = 0x00550000 2958 2959 class Select(Frame): 2960 # AMQP Method Number and Mapping Index 2961 frame_id = 10 2962 index = 0x0055000A 2963 name = 'Confirm.Select' 2964 2965 # Specifies if this is a synchronous AMQP method 2966 synchronous = True 2967 2968 # Valid responses to this method 2969 valid_responses = ['Confirm.SelectOk'] 2970 2971 # AMQP Method Attributes 2972 __slots__ = ['nowait'] 2973 2974 # Class Attribute Types 2975 _nowait = 'bit' 2976 2977 def __init__(self, nowait=False): 2978 """Initialize the Confirm.Select class 2979 2980 :param bool nowait: Do not send a reply method 2981 2982 """ 2983 # Do not send a reply method 2984 self.nowait = nowait 2985 2986 class SelectOk(Frame): 2987 # AMQP Method Number and Mapping Index 2988 frame_id = 11 2989 index = 0x0055000B 2990 name = 'Confirm.SelectOk' 2991 2992 # Specifies if this is a synchronous AMQP method 2993 synchronous = False 2994 2995# AMQP Class.Method Index Mapping 2996INDEX_MAPPING = {0x000A000A: Connection.Start, 2997 0x000A000B: Connection.StartOk, 2998 0x000A0014: Connection.Secure, 2999 0x000A0015: Connection.SecureOk, 3000 0x000A001E: Connection.Tune, 3001 0x000A001F: Connection.TuneOk, 3002 0x000A0028: Connection.Open, 3003 0x000A0029: Connection.OpenOk, 3004 0x000A0032: Connection.Close, 3005 0x000A0033: Connection.CloseOk, 3006 0x000A003C: Connection.Blocked, 3007 0x000A003D: Connection.Unblocked, 3008 0x0014000A: Channel.Open, 3009 0x0014000B: Channel.OpenOk, 3010 0x00140014: Channel.Flow, 3011 0x00140015: Channel.FlowOk, 3012 0x00140028: Channel.Close, 3013 0x00140029: Channel.CloseOk, 3014 0x0028000A: Exchange.Declare, 3015 0x0028000B: Exchange.DeclareOk, 3016 0x00280014: Exchange.Delete, 3017 0x00280015: Exchange.DeleteOk, 3018 0x0028001E: Exchange.Bind, 3019 0x0028001F: Exchange.BindOk, 3020 0x00280028: Exchange.Unbind, 3021 0x00280033: Exchange.UnbindOk, 3022 0x0032000A: Queue.Declare, 3023 0x0032000B: Queue.DeclareOk, 3024 0x00320014: Queue.Bind, 3025 0x00320015: Queue.BindOk, 3026 0x0032001E: Queue.Purge, 3027 0x0032001F: Queue.PurgeOk, 3028 0x00320028: Queue.Delete, 3029 0x00320029: Queue.DeleteOk, 3030 0x00320032: Queue.Unbind, 3031 0x00320033: Queue.UnbindOk, 3032 0x003C000A: Basic.Qos, 3033 0x003C000B: Basic.QosOk, 3034 0x003C0014: Basic.Consume, 3035 0x003C0015: Basic.ConsumeOk, 3036 0x003C001E: Basic.Cancel, 3037 0x003C001F: Basic.CancelOk, 3038 0x003C0028: Basic.Publish, 3039 0x003C0032: Basic.Return, 3040 0x003C003C: Basic.Deliver, 3041 0x003C0046: Basic.Get, 3042 0x003C0047: Basic.GetOk, 3043 0x003C0048: Basic.GetEmpty, 3044 0x003C0050: Basic.Ack, 3045 0x003C005A: Basic.Reject, 3046 0x003C0064: Basic.RecoverAsync, 3047 0x003C006E: Basic.Recover, 3048 0x003C006F: Basic.RecoverOk, 3049 0x003C0078: Basic.Nack, 3050 0x005A000A: Tx.Select, 3051 0x005A000B: Tx.SelectOk, 3052 0x005A0014: Tx.Commit, 3053 0x005A0015: Tx.CommitOk, 3054 0x005A001E: Tx.Rollback, 3055 0x005A001F: Tx.RollbackOk, 3056 0x0055000A: Confirm.Select, 3057 0x0055000B: Confirm.SelectOk} 3058