API reference
rmqaio
Config
dataclass
Configuration for rmqaio library.
Attributes:
-
log_sanitize(bool) –Flag indicating whether to sanitize logs by replacing user data with
<hidden>. -
log_data_truncate_size(int) –Maximum size of data to log before truncation.
Source code in rmqaio/rmqaio.py
Repeat
Represents a fixed delay value for retry operations.
Supports hashing and equality comparison, making it suitable for use as a dictionary key or in sets.
Attributes:
-
value–The value to repeat.
Examples:
Source code in rmqaio/rmqaio.py
__init__
RetryPolicy
dataclass
Defines retry policy for handling exceptions and retries.
Attributes:
-
delays(Delay) –A sequence of delays (in seconds) for attempts.
-
exc_filter(tuple[type[Exception], ...] | Callable[[Exception], bool]) –A tuple of exception types or a callable function to filter which exceptions should be retried.
Source code in rmqaio/rmqaio.py
is_retryable
Determine if an exception is retryable.
Parameters:
-
e(Exception) –The exception to check.
Returns:
-
bool–Trueif the exception is retryable,Falseotherwise. -
bool–Delegates to
exc_filtercallable if provided.
Source code in rmqaio/rmqaio.py
ConnectionState
Bases: StrEnum
Enum for representing the state of a connection.
Source code in rmqaio/rmqaio.py
INITIAL
class-attribute
instance-attribute
Connection is created and ready to open.
CONNECTING
class-attribute
instance-attribute
Connection is in the process of being established.
CONNECTED
class-attribute
instance-attribute
Connection is established and operational.
REFRESHING
class-attribute
instance-attribute
Connection is in the process of being refreshed.
CLOSING
class-attribute
instance-attribute
Connection is in the process of being closed.
ConnectionProtocol
Bases: Protocol
Protocol describing a RabbitMQ connection interface.
Source code in rmqaio/rmqaio.py
Connection
RabbitMQ connection with automatic reconnection on connection loss.
Attributes:
-
id(str) –Connection Id.
-
url(str) –Connection URL to RabbitMQ.
-
ssl_context(SSLContext | None) –SSL context for TLS connections.
-
open_retry_policy(RetryPolicy | None) –Policy for first connection attempts.
-
reopen_retry_policy(RetryPolicy | None) –Policy for reconnection attempts.
-
is_open(bool) –Whether connection is open and operational.
-
is_closed(bool) –Whether connection is closed.
Examples:
>>> conn = Connection("amqp://localhost")
>>> await conn.open()
>>> channel = await conn.channel()
>>> await conn.close()
Source code in rmqaio/rmqaio.py
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 | |
open_retry_policy
property
Reconnection policy for handling first connection errors.
reopen_retry_policy
property
Reconnection policy for handling reconnection errors.
__init__
__init__(
url: str,
ssl_context: SSLContext | None = None,
open_retry_policy: RetryPolicy | None = None,
reopen_retry_policy: RetryPolicy | None = None,
)
Initialize connection.
Parameters:
-
url(str) –AMQP connection URL (e.g., "amqp://localhost").
-
ssl_context(SSLContext | None, default:None) –Optional SSL context for TLS connections.
-
open_retry_policy(RetryPolicy | None, default:None) –Reconnection policy for handling first connection errors.
-
reopen_retry_policy(RetryPolicy | None, default:None) –Reconnection policy for handling reconnection errors.
Source code in rmqaio/rmqaio.py
open
async
Open connection to RabbitMQ.
Establishes connection to RabbitMQ broker. If connection is lost, automatically attempts to reconnect based on retry policy.
Parameters:
-
timeout(Number | None, default:None) –Operation timeout in seconds.
Source code in rmqaio/rmqaio.py
refresh
async
Refresh the underlying connection by reopening it.
Parameters:
-
timeout(Number | None, default:None) –Operation timeout in seconds.
Source code in rmqaio/rmqaio.py
close
async
Gracefully closes the connection and all associated channels.
Parameters:
-
timeout(Number | None, default:None) –Operation timeout in seconds.
Source code in rmqaio/rmqaio.py
new_channel
async
Create a new channel.
Parameters:
-
timeout(Number | None, default:None) –Operation timeout in seconds.
Returns:
-
AbstractChannel–A new RabbitMQ channel.
Source code in rmqaio/rmqaio.py
channel
async
Get or create a channel.
Parameters:
-
timeout(Number | None, default:None) –Operation timeout in seconds.
Returns:
-
AbstractChannel–An open RabbitMQ channel.
Source code in rmqaio/rmqaio.py
set_callback
Set a callback for connection events.
Parameters:
-
name(str) –Unique name to identify the callback.
-
callback(Callable[[ConnectionState, ConnectionState], Awaitable]) –Callable to execute on event.
If a callback with this name is already registered, it will be overridden.
Source code in rmqaio/rmqaio.py
remove_callback
async
SharedConnection
Connection wrapper that shares a single underlying connection.
Instances created with identical parameters share the same Connection object.
The underlying connection is closed only when all shared references are released.
Attributes:
-
url(str) –Connection URL to RabbitMQ.
-
ssl_context(SSLContext | None) –SSL context for TLS connections.
-
open_retry_policy(RetryPolicy | None) –Policy for first connection attempts.
-
reopen_retry_policy(RetryPolicy | None) –Policy for reconnection attempts.
-
is_open(bool) –Whether connection is open and operational.
-
is_closed(bool) –Whether connection is closed.
Examples:
>>> conn1 = SharedConnection("amqp://localhost")
>>> conn2 = SharedConnection("amqp://localhost")
>>> # conn1 and conn2 share the same underlying connection
Source code in rmqaio/rmqaio.py
767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 | |
open_retry_policy
property
Reconnection policy for handling first connection errors.
reopen_retry_policy
property
Reconnection policy for handling reconnection errors.
__init__
__init__(
url: str,
ssl_context: SSLContext | None = None,
open_retry_policy: RetryPolicy | None = None,
reopen_retry_policy: RetryPolicy | None = None,
)
Initialize SharedConnection.
Parameters:
-
url(str) –AMQP connection URL (e.g., "amqp://localhost").
-
ssl_context(SSLContext | None, default:None) –Optional SSL context for TLS connections.
-
open_retry_policy(RetryPolicy | None, default:None) –Reconnection policy for handling first connection errors.
-
reopen_retry_policy(RetryPolicy | None, default:None) –Reconnection policy for handling reconnection errors.
Source code in rmqaio/rmqaio.py
open
async
Open connection to RabbitMQ.
Establishes connection to RabbitMQ broker. If connection is lost, automatically attempts to reconnect based on retry policy.
Parameters:
-
timeout(Number | None, default:None) –Operation timeout in seconds.
Raises:
-
Exception–If connection fails, is closed, or reopened after close.
Source code in rmqaio/rmqaio.py
refresh
async
Refresh the underlying connection by reopening it.
Parameters:
-
timeout(Number | None, default:None) –Operation timeout in seconds.
close
async
Gracefully closes the connection and all associated channels.
Parameters:
-
timeout(Number | None, default:None) –Operation timeout in seconds.
Source code in rmqaio/rmqaio.py
new_channel
async
Create a new channel.
Parameters:
-
timeout(Number | None, default:None) –Operation timeout in seconds.
Returns:
-
AbstractChannel–A new RabbitMQ channel.
Source code in rmqaio/rmqaio.py
channel
async
Get or create a channel.
Parameters:
-
timeout(Number | None, default:None) –Operation timeout in seconds.
Returns:
-
AbstractChannel–An open RabbitMQ channel.
Source code in rmqaio/rmqaio.py
set_callback
Set a callback for connection events.
Parameters:
-
name(str) –Unique name to identify the callback.
-
callback(Callable[[ConnectionState, ConnectionState], Awaitable]) –Callable to execute on event.
If a callback with this name is already registered, it will be overridden.
Source code in rmqaio/rmqaio.py
remove_callback
async
DefaultExchangeSpec
dataclass
Default exchange specification.
Attributes:
-
name(Literal['']) –Always empty string.
-
kind(Literal['default']) –Always "default".
-
type(ExchangeType) –Exchange type.
Source code in rmqaio/rmqaio.py
BaseExchangeArgs
dataclass
Base exchange arguments.
Attributes:
-
alternate_exchange(str | None) –Alternate exchange name.
-
internal(bool | None) –Whether exchange is internal.
-
custom(dict[str, Any] | None) –Custom arguments.
Source code in rmqaio/rmqaio.py
BaseExchangeSpec
dataclass
Base exchange specification.
Attributes:
-
name(str) –Exchange name.
-
kind(str) –Exchange kind ("normal" or "read-only").
-
type(str) –Exchange type.
-
durable(bool) –Whether exchange is durable.
-
auto_delete(bool) –Whether to delete when no longer used.
-
internal(bool) –Whether exchange is internal.
-
arguments(BaseExchangeArgs) –Exchange arguments.
Source code in rmqaio/rmqaio.py
ExchangeArgs
dataclass
Bases: BaseExchangeArgs
Exchange arguments.
Inherits all attributes from BaseExchangeArgs.
Source code in rmqaio/rmqaio.py
ExchangeSpec
dataclass
Bases: BaseExchangeSpec
Exchange specification.
Attributes:
-
kind(Literal['normal', 'read-only']) –Always "normal" or "read-only".
-
type(ExchangeType) –Exchange type.
-
arguments(ExchangeArgs) –Exchange arguments.
Source code in rmqaio/rmqaio.py
BaseQueueSpec
dataclass
Base queue specification.
Attributes:
-
name(str) –Queue name.
-
kind(str) –Queue kind ("normal" or "read-only").
-
durable(bool) –Whether queue is durable.
-
exclusive(bool) –Whether queue is exclusive.
-
auto_delete(bool) –Whether to delete when no longer used.
-
arguments(BaseQueueArgs) –Queue arguments.
Source code in rmqaio/rmqaio.py
QueueArgs
dataclass
Bases: BaseQueueArgs
Queue arguments.
Attributes:
-
queue_type(QueueType) –Queue type (defaults to "classic").
Inherits all attributes from BaseQueueArgs.
Source code in rmqaio/rmqaio.py
QueueSpec
dataclass
Bases: BaseQueueSpec
Queue specification.
Attributes:
-
kind(Literal['normal', 'read-only']) –Always "normal" or "read-only".
-
arguments(QueueArgs) –Queue arguments.
Source code in rmqaio/rmqaio.py
BindSpec
dataclass
Binding specification.
Attributes:
-
src(str) –Source exchange or queue.
-
dst(str) –Destination exchange or queue.
-
routing_key(str) –Routing key.
-
kind(Literal['exchange', 'queue']) –Type of binding ("exchange" or "queue").
Source code in rmqaio/rmqaio.py
ConsumerArgs
dataclass
Consumer arguments.
Attributes:
-
priority(int | None) –Consumer priority.
-
cancel_on_ha_failover(bool | None) –Cancel on HA failover.
-
custom(dict[str, Any] | None) –Custom arguments.
Source code in rmqaio/rmqaio.py
ConsumerSpec
dataclass
Consumer specification.
Attributes:
-
queue(str) –Queue name.
-
callback(Callable[[AbstractChannel, DeliveredMessage], Awaitable]) –Async callback to process messages.
-
prefetch_count(int | None) –Maximum unacknowledged messages.
-
prefetch_size(int | None) –Maximum unacknowledged bytes.
-
auto_ack(bool) –Auto acknowledge messages.
-
exclusive(bool) –Exclusive consumer.
-
arguments(ConsumerArgs) –Consumer arguments.
Source code in rmqaio/rmqaio.py
Consumer
dataclass
Consumer instance.
Attributes:
-
spec(ConsumerSpec) –Consumer specification.
-
consumer_tag(str) –Consumer tag from broker.
-
channel(AbstractChannel) –AMQP channel for this consumer.
Source code in rmqaio/rmqaio.py
Topology
dataclass
Topology of RabbitMQ entities.
Attributes:
-
exchanges(UniqueList[BaseExchangeSpec]) –List of exchange specifications.
-
queues(UniqueList[BaseQueueSpec]) –List of queue specifications.
-
bindings(UniqueList[BindSpec]) –List of binding specifications.
-
consumers(UniqueList[ConsumerSpec]) –List of consumer specifications.
Source code in rmqaio/rmqaio.py
Ops
RabbitMQ operations handler.
Provides high-level operations for managing exchanges, queues, bindings, and consuming messages.
Attributes:
-
conn–Connection to RabbitMQ.
-
timeout–Default operation timeout.
Source code in rmqaio/rmqaio.py
1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 | |
__init__
Initialize Ops.
Parameters:
-
conn(ConnectionProtocol) –Connection to RabbitMQ.
-
timeout(Number | None, default:None) –Default operation timeout.
Source code in rmqaio/rmqaio.py
apply_topology
async
apply_topology(
topology: Topology,
consume: bool | None = None,
restore: bool | None = None,
force: bool | None = None,
)
Apply entire topology declaration.
Parameters:
-
topology(Topology) –Topology to apply.
-
consume(bool | None, default:None) –If
True, start consuming according to the topology. -
restore(bool | None, default:None) –If
True, restore on reconnect.
Source code in rmqaio/rmqaio.py
check_exists
async
Check if subj exists.
Parameters:
-
spec(BaseExchangeSpec | BaseQueueSpec) –Specification to check.
-
timeout(Number | None, default:None) –Operation timeout in seconds. If
None, uses the default timeout.
Returns:
-
bool–True if the subj exists, False otherwise.
Source code in rmqaio/rmqaio.py
declare
async
declare(
spec: BaseExchangeSpec | BaseQueueSpec,
timeout: Number | None = None,
restore: bool | None = None,
force: bool | None = None,
)
Declare subj.
Parameters:
-
restore(bool | None, default:None) –If
True, automatically redeclare subj after reconnection. -
force(bool | None, default:None) –If
True, delete and redeclare subj if declaration fails due to parameter mismatch. -
timeout(Number | None, default:None) –Operation timeout. If
None, uses the default timeout.
Source code in rmqaio/rmqaio.py
delete
async
Delete subj.
Parameters:
-
timeout(Number | None, default:None) –Operation timeout. If
None, uses the default timeout.
Raises:
-
Exception–If deleting fails.
Source code in rmqaio/rmqaio.py
check_exchange_exists
async
Check if exchange exists.
Parameters:
-
name(str) –Exchange name.
-
timeout(Number | None, default:None) –Operation timeout in seconds. If
None, uses the default timeout.
Returns:
-
bool–True if the exchange exists, False otherwise.
Source code in rmqaio/rmqaio.py
exchange_declare
async
exchange_declare(
spec: BaseExchangeSpec,
timeout: Number | None = None,
restore: bool | None = None,
force: bool | None = None,
)
Declare the exchange.
Parameters:
-
timeout(Number | None, default:None) –Operation timeout in seconds. If
None, uses the default timeout. -
restore(bool | None, default:None) –If
True, automatically redeclare the exchange after reconnection. -
force(bool | None, default:None) –If
True, delete and redeclare the exchange if declaration fails due to parameter mismatch.
Raises:
-
Exception–If declaring fails.
Source code in rmqaio/rmqaio.py
exchange_delete
async
Delete exchange.
Parameters:
-
name(str) –Exchange name.
-
timeout(Number | None, default:None) –Operation timeout. If
None, uses the default timeout.
Source code in rmqaio/rmqaio.py
check_queue_exists
async
Check if queue exists.
Parameters:
-
name(str) –Queue name.
-
timeout(Number | None, default:None) –Operation timeout. If
None, uses the default timeout.
Returns:
-
bool–True if the queue exists, False otherwise.
Source code in rmqaio/rmqaio.py
queue_declare
async
queue_declare(
spec: BaseQueueSpec,
timeout: Number | None = None,
restore: bool | None = None,
force: bool | None = None,
)
Declare queue.
Parameters:
-
spec(BaseQueueSpec) –Queue specification.
-
timeout(Number | None, default:None) –Operation timeout. If
None, uses the default timeout. -
restore(bool | None, default:None) –Restore this binding on connection issue.
-
force(bool | None, default:None) –Force redeclare queue if it has already been declared with different parameters.
Raises:
-
Exception–If declaring fails.
Source code in rmqaio/rmqaio.py
queue_delete
async
Delete queue.
Parameters:
-
name(str) –Queue name.
-
timeout(Number | None, default:None) –Operation timeout. If
None, uses the default timeout.
Source code in rmqaio/rmqaio.py
bind
async
Bind item to exchange.
Parameters:
-
spec(BindSpec) –Bind specification.
-
timeout(Number | None, default:None) –Operation timeout. If
None, uses the default timeout. -
restore(bool | None, default:None) –Restore this binding on connection issue.
Source code in rmqaio/rmqaio.py
unbind
async
Unbind item from exchange.
Parameters:
-
spec(BindSpec) –Bind specification.
-
timeout(Number | None, default:None) –Operation timeout. If
None, uses the default timeout.
Source code in rmqaio/rmqaio.py
publish
async
publish(
exchange: str,
data: bytes,
routing_key: str,
properties: dict | None = None,
mandatory: bool = False,
timeout: Number | None = None,
)
Publish data to the exchange.
Parameters:
-
exchange(str) –Exchange name.
-
data(bytes) –Data to publish.
-
routing_key(str) –Routing key for message delivery.
-
properties(dict | None, default:None) –Optional RabbitMQ message properties.
-
mandatory(bool, default:False) –If
True, return unroutable message to publisher. -
timeout(Number | None, default:None) –Operation timeout in seconds. If
None, uses the default timeout.
Source code in rmqaio/rmqaio.py
consume
async
consume(
spec: ConsumerSpec,
timeout: Number | None = None,
restore: bool | None = None,
) -> Consumer
Consume queue.
Parameters:
-
spec(ConsumerSpec) –Spec.
-
timeout(Number | None, default:None) –Operation timeout. If
None, uses the default timeout. -
restore(bool | None, default:None) –Restore consuming on connection issue.
Returns:
-
Consumer(Consumer) –The active consumer instance.
Source code in rmqaio/rmqaio.py
stop_consume
async
Stop consume.
Parameters:
-
consumer_tag(str | None, default:None) –Consumer tag. If
None, stop all consumers. -
timeout(Number | None, default:None) –Operation timeout. If
None, uses the default timeout.
Source code in rmqaio/rmqaio.py
DefaultExchange
dataclass
Default exchange wrapper.
Attributes:
-
spec(DefaultExchangeSpec) –Default exchange specification.
-
ops(Ops) –Ops instance.
Source code in rmqaio/rmqaio.py
publish
async
publish(
data: bytes,
routing_key: str,
properties: dict | None = None,
mandatory: bool = False,
timeout: Number | None = None,
)
Publish data to the default exchange.
Parameters:
-
data(bytes) –Data to publish.
-
routing_key(str) –Routing key for message delivery.
-
properties(dict | None, default:None) –Optional RabbitMQ message properties.
-
mandatory(bool, default:False) –If
True, return unroutable message to publisher. -
timeout(Number | None, default:None) –Operation timeout in seconds. If
None, uses the default timeout.
Source code in rmqaio/rmqaio.py
Exchange
dataclass
Exchange wrapper.
Attributes:
-
spec(BaseExchangeSpec) –Exchange specification.
-
ops(Ops) –Ops instance.
Source code in rmqaio/rmqaio.py
2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 | |
check_exists
async
Check if exchange exists.
Parameters:
-
timeout(Number | None, default:None) –Operation timeout in seconds. If
None, uses the default timeout.
Returns:
-
bool–True if the exchange exists, False otherwise.
Source code in rmqaio/rmqaio.py
declare
async
Declare exchange.
Parameters:
-
timeout(Number | None, default:None) –Operation timeout in seconds. If
None, uses the default timeout. -
restore(bool | None, default:None) –Restore this exchange on connection issue.
-
force(bool | None, default:None) –Force redeclare if already declared with different parameters.
Source code in rmqaio/rmqaio.py
delete
async
Delete exchange.
Parameters:
-
timeout(Number | None, default:None) –Operation timeout. If
None, uses the default timeout.
bind
async
bind(
exchange: str,
routing_key: str,
timeout: Number | None = None,
restore: bool | None = None,
)
Bind this exchange to another exchange.
Parameters:
-
exchange(str) –Exchange name.
-
routing_key(str) –Routing key to bind.
-
timeout(Number | None, default:None) –Operation timeout. If
None, uses the default timeout. -
restore(bool | None, default:None) –Restore this binding on connection issue.
Source code in rmqaio/rmqaio.py
unbind
async
Unbind this exchange from another exchange.
Parameters:
-
exchange(str) –Exchange name.
-
routing_key(str) –Routing key to unbind.
-
timeout(Number | None, default:None) –Operation timeout. If
None, uses the default timeout.
Source code in rmqaio/rmqaio.py
publish
async
publish(
data: bytes,
routing_key: str,
properties: dict | None = None,
mandatory: bool = False,
timeout: Number | None = None,
)
Publish data to the exchange.
Parameters:
-
data(bytes) –Data to publish.
-
routing_key(str) –Routing key for message delivery.
-
properties(dict | None, default:None) –Optional RabbitMQ message properties.
-
mandatory(bool, default:False) –If
True, return unroutable message to publisher. -
timeout(Number | None, default:None) –Operation timeout in seconds. If
None, uses the default timeout.
Source code in rmqaio/rmqaio.py
Queue
dataclass
Queue wrapper.
Attributes:
-
spec(BaseQueueSpec) –Queue specification.
-
ops(Ops) –Ops instance.
Source code in rmqaio/rmqaio.py
2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 | |
check_exists
async
Check if queue exists.
Parameters:
-
timeout(Number | None, default:None) –Operation timeout in seconds. If
None, uses the default timeout.
Returns:
-
bool–True if the queue exists, False otherwise.
Source code in rmqaio/rmqaio.py
declare
async
Declare queue.
Parameters:
-
timeout(Number | None, default:None) –Operation timeout in seconds. If
None, uses the default timeout. -
restore(bool | None, default:None) –Restore this queue on connection issue.
-
force(bool | None, default:None) –Force redeclare if already declared with different parameters.
Source code in rmqaio/rmqaio.py
delete
async
Delete queue.
Parameters:
-
timeout(Number | None, default:None) –Operation timeout. If
None, uses the default timeout.
bind
async
bind(
exchange: str,
routing_key: str,
timeout: Number | None = None,
restore: bool | None = None,
)
Bind queue to exchange.
Parameters:
-
exchange(str) –Exchange name.
-
routing_key(str) –Routing key to bind.
-
timeout(Number | None, default:None) –Operation timeout. If
None, uses the default timeout. -
restore(bool | None, default:None) –Restore this binding on connection issue.
Source code in rmqaio/rmqaio.py
unbind
async
Unbind queue from exchange.
Parameters:
-
exchange(str) –Exchange name.
-
routing_key(str) –Routing key to unbind.
-
timeout(Number | None, default:None) –Operation timeout. If
None, uses the default timeout.
Source code in rmqaio/rmqaio.py
consume
async
consume(
callback: Callable[
[AbstractChannel, DeliveredMessage], Awaitable
],
prefetch_count: int | None = None,
prefetch_size: int | None = None,
auto_ack: bool = True,
exclusive: bool = False,
consumer_tag: str | None = None,
arguments: ConsumerArgs | None = None,
timeout: Number | None = None,
restore: bool | None = None,
) -> Consumer
Start consuming messages from queue.
Parameters:
-
callback(Callable[[AbstractChannel, DeliveredMessage], Awaitable]) –Async callback function to handle messages.
-
prefetch_count(int | None, default:None) –Maximum number of unacknowledged messages.
-
prefetch_size(int | None, default:None) –Maximum number of unacknowledged bytes.
-
auto_ack(bool, default:True) –If True, automatically acknowledge messages.
-
exclusive(bool, default:False) –If True, create exclusive consumer.
-
consumer_tag(str | None, default:None) –Custom consumer tag.
-
arguments(ConsumerArgs | None, default:None) –Consumer arguments.
-
timeout(Number | None, default:None) –Operation timeout in seconds.
-
restore(bool | None, default:None) –If True, restore consumer on reconnect.
Returns:
-
Consumer(Consumer) –Active consumer instance.
Source code in rmqaio/rmqaio.py
stop_consume
async
Stop consume.
Parameters:
-
consumer_tag(str | None, default:None) –Consumer tag. If
None, stop all consumers. -
timeout(Number | None, default:None) –Operation timeout. If
None, uses the default timeout.
Source code in rmqaio/rmqaio.py
retry
retry(
retry_policy: RetryPolicy,
*,
msg: str | None = None,
on_error: Callable[[Exception], Awaitable] | None = None
)
Create a retry decorator for async functions.
The decorated coroutine will be retried using the provided delay
sequence if the raised exception matches exc_filter.
Parameters:
-
retry_policy(RetryPolicy) –Retry policy.
-
msg(str | None, default:None) –Optional message to log before retrying. If not provided, the function object is logged.
-
on_error(Callable[[Exception], Awaitable] | None, default:None) –Optional async callback executed after a retryable exception is caught and before sleeping.
Returns:
-
–
Decorator for async functions.