Beispiel #1
0
def test_visibility_timeout(sqs, random_string):
    try:
        create_standard_queue(sqs, random_string, visibility_timeout=1)
        create_fifo_queue(sqs, random_string + ".fifo", visibility_timeout=1)
    finally:
        try:
            delete_queue(sqs, random_string)
        except Exception:
            pass
        try:
            delete_queue(sqs, random_string + ".fifo")
        except Exception:
            pass
Beispiel #2
0
def queue_name_with_redrive(sqs_session, sqs, random_string):
    # dead letter queue_name
    queue = random_string
    dead_queue = random_string + "_dead"

    create_standard_queue(sqs, dead_queue)

    # standard queue_name
    # 1 is the minimal value for redrive, and means
    # "put this to the dead letter queue_name after two failed attempts"
    create_standard_queue(sqs, queue, redrive_policy=sqs.redrive_policy(dead_queue, 1))

    yield queue, dead_queue

    # delete all the queues
    delete_queue(sqs, queue)
    delete_queue(sqs, dead_queue)
Beispiel #3
0
def test_message_retention_period(sqs_session, sqs, random_string):
    if isinstance(sqs_session, MemorySession):
        pytest.skip("Message Retention id not implemented with MemorySession")

    try:
        create_standard_queue(sqs, random_string, message_retention_period=600)
        create_fifo_queue(sqs,
                          random_string + ".fifo",
                          message_retention_period=600)
    finally:
        try:
            delete_queue(sqs, random_string)
        except Exception:
            pass
        try:
            delete_queue(sqs, random_string + ".fifo")
        except Exception:
            pass
Beispiel #4
0
import uuid

from sqs_workers import SQSEnv, create_standard_queue, delete_queue

from nifi.flowfile import FlowFile
from nifi.sqs_workers import NiFiQueue

# This environment will use AWS
from sqs_workers.shutdown_policies import MaxTasksShutdown

sqs = SQSEnv()

# Create a new queue.
queue_name = str(uuid.uuid4())
create_standard_queue(sqs, queue_name)

# Get the queue object
queue = sqs.queue(queue_name, NiFiQueue)


@queue.processor("ping")
def ping(flowfile: FlowFile):
    print("Ping...")


@queue.processor("ping/success")
def pong(flowfile: FlowFile):
    print("Pong...")


# Start PingPong
Beispiel #5
0
def queue_name2(sqs_session, sqs, random_string):
    # type: (SQSEnv) -> string
    create_standard_queue(sqs, random_string + "_2")
    yield random_string + "_2"
    delete_queue(sqs, random_string + "_2")
Beispiel #6
0
def writePidFile():
    pid = str(os.getpid())
    f = open('.pid', 'w')
    f.write(pid)
    f.close()


writePidFile()

# This environment will use AWS requisites from ~/.aws/ directory
sqs = SQSEnv()

# Create a new queue.
# Note that you can use the AWS web interface for the same action as well, the
# web interface provides more options. You only need to do it once.
create_standard_queue(sqs, "emails")

# Get the queue object
queue = sqs.queue("emails")


class ScheduledShutdown(object):
    """
    Shutdown worker if it's idle for certain time (set in seconds)
    """
    def __init__(self):
        pass

    def update_state(self, batch_processing_result):
        pass