Exemple #1
0
    def get_hook(self) -> SqsHook:
        """Create and return an SqsHook"""
        if self.hook:
            return self.hook

        self.hook = SqsHook(aws_conn_id=self.aws_conn_id)
        return self.hook
Exemple #2
0
    def execute(self, context: 'Context'):
        """
        Publish the message to SQS queue

        :param context: the context object
        :return: dict with information about the message sent
            For details of the returned dict see :py:meth:`botocore.client.SQS.send_message`
        :rtype: dict
        """
        hook = SqsHook(aws_conn_id=self.aws_conn_id)

        result = hook.send_message(
            queue_url=self.sqs_queue,
            message_body=self.message_content,
            delay_seconds=self.delay_seconds,
            message_attributes=self.message_attributes,
        )

        self.log.info('result is send_message is %s', result)

        return result
Exemple #3
0
def delete_queue_fn(queue_url):
    """This is a Python function that deletes an SQS queue"""
    hook = SqsHook()
    hook.get_conn().delete_queue(QueueUrl=queue_url)
Exemple #4
0
def create_queue_fn():
    """This is a Python function that creates an SQS queue"""
    hook = SqsHook()
    result = hook.create_queue(queue_name=QUEUE_NAME)
    return result['QueueUrl']
Exemple #5
0
def delete_queue_fn(queue_url):
    """Delete the example queue"""
    hook = SqsHook()
    hook.get_conn().delete_queue(QueueUrl=queue_url)
Exemple #6
0
def create_queue_fn():
    """Create the example queue"""
    hook = SqsHook()
    result = hook.create_queue(queue_name=QUEUE_NAME)
    return result['QueueUrl']