def parse_link_options(self):
        """
        Prepare link options

        :return: list of link options
        :rtype: list
        """
        link_opts = super(Recv, self).parse_link_options()
        if self.opts.link_durable:
            link_opts.append(proton.reactor.DurableSubscription())
        if self.opts.recv_browse:
            link_opts.append(proton.reactor.Copy())
        if self.opts.recv_consume:
            link_opts.append(proton.reactor.Move())
        if self.opts.recv_filter:
            link_opts.append(
                proton.reactor.Filter(
                    utils.prepare_flat_map(self.opts.recv_filter)))
        if self.opts.recv_selector is not None:
            link_opts.append(proton.reactor.Selector(self.opts.recv_selector))
        if self.opts.link_dynamic_node_properties:
            link_opts.append(
                proton.reactor.DynamicNodeProperties(
                    utils.prepare_flat_map(
                        self.opts.link_dynamic_node_properties)))
        return link_opts
Beispiel #2
0
    def prepare_map_content(self):
        """
        prepares map content

        :return: flat map constructed from options map items
        :rtype: dict
        """
        content = {}
        if self.opts.msg_map_items != ['']:
            content = utils.prepare_flat_map(self.opts.msg_map_items, self.opts.content_type)
        return content
Beispiel #3
0
    def prepare_message(self):
        """
        compose and return the message

        :return: message to be sent
        :rtype: proton.Message
        """

        msg = proton.Message()
        msg_content, msg_content_type = self.prepare_content()

        if self.opts.msg_durable.lower(
        ) == "yes" or self.opts.msg_durable.lower() == "true":
            msg.durable = True
        if self.opts.msg_priority is not None:
            msg.priority = self.opts.msg_priority
        if self.opts.msg_id is not None:
            msg.id = self.opts.msg_id
        if self.opts.msg_correlation_id is not None:
            msg.correlation_id = self.opts.msg_correlation_id
        if self.opts.msg_user_id is not None:
            msg.user_id = self.opts.msg_user_id.encode('utf-8')
        if self.opts.msg_group_id is not None:
            msg.group_id = self.opts.msg_group_id.encode('utf-8')
        if self.opts.msg_group_seq:
            msg.group_sequence = self.opts.msg_group_seq
        if self.opts.msg_reply_to is not None:
            msg.reply_to = self.opts.msg_reply_to
        if self.opts.msg_subject is not None:
            msg.subject = self.opts.msg_subject
        if self.opts.msg_ttl is not None:
            msg.ttl = self.opts.msg_ttl / 1000
        if self.opts.msg_content_type is not None:
            msg.content_type = self.opts.msg_content_type
        if self.opts.msg_address is not None:
            msg.address = self.opts.msg_address
        else:
            msg.content_type = msg_content_type
        msg.properties = utils.prepare_flat_map(self.opts.msg_properties)
        msg.body = msg_content

        return msg