Initiates the establishment of a link over which messages can be received (aka a subscription). There are two patterns of use: (1) A connection can be passed as the first argument, in which case the link is established on that connection. In this case
(
self,
context: Union[Connection, Url, str],
source: Optional[str] = None,
target: Optional[str] = None,
name: Optional[str] = None,
dynamic: bool = False,
handler: Optional[Handler] = None,
options: Optional[Union[ReceiverOption, List[ReceiverOption], LinkOption, List[LinkOption]]] = None
)
| 1485 | return snd |
| 1486 | |
| 1487 | def create_receiver( |
| 1488 | self, |
| 1489 | context: Union[Connection, Url, str], |
| 1490 | source: Optional[str] = None, |
| 1491 | target: Optional[str] = None, |
| 1492 | name: Optional[str] = None, |
| 1493 | dynamic: bool = False, |
| 1494 | handler: Optional[Handler] = None, |
| 1495 | options: Optional[Union[ReceiverOption, List[ReceiverOption], LinkOption, List[LinkOption]]] = None |
| 1496 | ) -> 'Receiver': |
| 1497 | """ |
| 1498 | Initiates the establishment of a link over which messages can |
| 1499 | be received (aka a subscription). |
| 1500 | |
| 1501 | There are two patterns of use: |
| 1502 | |
| 1503 | (1) A connection can be passed as the first argument, in which |
| 1504 | case the link is established on that connection. In this case |
| 1505 | the source address can be specified as the second argument (or |
| 1506 | as a keyword argument). The target address can also be specified |
| 1507 | if desired. |
| 1508 | |
| 1509 | (2) Alternatively a URL can be passed as the first argument. In |
| 1510 | this case a new connection will be established on which the link |
| 1511 | will be attached. If a path is specified and the source is not, |
| 1512 | then the path of the URL is used as the target address. |
| 1513 | |
| 1514 | The name of the link may be specified if desired, otherwise a |
| 1515 | unique name will be generated. |
| 1516 | |
| 1517 | Various :class:`LinkOption` s can be specified to further control the |
| 1518 | attachment. |
| 1519 | |
| 1520 | :param context: A connection object or a URL. |
| 1521 | :param source: Address of source node. |
| 1522 | :param target: Address of target node. |
| 1523 | :param name: Receiver name. |
| 1524 | :param dynamic: If ``True``, indicates dynamic creation of the receiver. |
| 1525 | :param handler: Event handler for this receiver. |
| 1526 | :param options: A single option, or a list of receiver options |
| 1527 | |
| 1528 | :return: New receiver instance. |
| 1529 | """ |
| 1530 | if isinstance(context, str): |
| 1531 | context = Url(context) |
| 1532 | if isinstance(context, Url) and not source: |
| 1533 | source = context.path |
| 1534 | session = self._get_session(context) |
| 1535 | rcv = session.receiver(name or self._get_id(session.connection.container, source, target)) |
| 1536 | if source: |
| 1537 | rcv.source.address = source |
| 1538 | if dynamic: |
| 1539 | rcv.source.dynamic = True |
| 1540 | if target: |
| 1541 | rcv.target.address = target |
| 1542 | if handler is not None: |
| 1543 | rcv.handler = handler |
| 1544 | _apply_link_options(options, rcv) |
no test coverage detected