|
39 | 39 | (raise 10))))
|
40 | 40 |
|
41 | 41 | Optional arguments:
|
42 |
| - :client - the SQS client, which is the instance of cognitect.aws.client.Client. |
43 |
| - if missing, cognitect.aws.client.api/client would be called. |
44 |
| - :num-workers - the number of workers processing messages concurrently. |
45 |
| - default: (Runtime/availableProcessors) - 1 |
46 |
| - :num-receivers - the number of receivers polling from sqs. |
47 |
| - default: (num-workers / 10) because each receiver is able to receive |
48 |
| - up to 10 messages at a time. |
49 |
| - :message-channel-size - the number of messages to prefetch from sqs. |
50 |
| - default: 20 * num-receivers |
51 |
| - :receive-limit - the number of messages to receive at a time. 1 to 10. |
52 |
| - default: 10 |
53 |
| - :consume-limit - the number of processing messages at the same time. 0 to 1024 |
54 |
| - If the consume run asynchronously, for instance inside go block, |
55 |
| - you may want to use this option. |
56 |
| - default: 0, which means gluttony doesn't care about how many message |
57 |
| - are processed simultaneously. |
58 |
| - :long-polling-duration - the duration (in seconds) for which the call waits for a message to |
59 |
| - arrive in the queue before returning. 0 to 20. |
60 |
| - default: 20 |
61 |
| - :exceptional-poll-delay-ms - when an Exception is received while polling, receiver wait for the |
62 |
| - number of ms until polling again. |
63 |
| - default: 10000 (10 seconds). |
64 |
| - :heartbeat - the duration (in seconds) for which the consumer extends message |
65 |
| - visibility if the message is being processed. 1 to 43199. |
66 |
| - default: nil |
67 |
| - If it isn't set, heartbeat doesn't work. |
68 |
| - If it's set, :heartbeat-timeout is required. |
69 |
| - Refer to AWS documents for more detail: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/working-with-messages.html |
70 |
| - If you set this option and :consume-limit, recommend to make |
71 |
| - :consume-limit bigger than :message-channel-size so as not to block |
72 |
| - heartbeat requests. |
73 |
| - :heartbeat-timeout - the timeout (in seconds) of heartbeat. |
74 |
| - If your consume function doesn't call respond or raise within heartbeat |
75 |
| - timeout, the consumer doesn't extend message visibility any more. |
76 |
| - 2 to 43200. |
77 |
| - default: nil |
78 |
| - :heartbeat-timeout must be longer than :heartbeat. |
| 42 | + :client - the SQS client, which is the instance of cognitect.aws.client.Client. |
| 43 | + if missing, cognitect.aws.client.api/client would be called. |
| 44 | + :num-workers - the number of workers processing messages concurrently. |
| 45 | + default: (Runtime/availableProcessors) - 1 |
| 46 | + :num-receivers - the number of receivers polling from sqs. |
| 47 | + default: (num-workers / 10) because each receiver is able to receive |
| 48 | + up to 10 messages at a time. |
| 49 | + :message-channel-size - the number of messages to prefetch from sqs. |
| 50 | + default: 20 * num-receivers |
| 51 | + :receive-limit - the number of messages to receive at a time. 1 to 10. |
| 52 | + default: 10 |
| 53 | + :consume-limit - the number of processing messages at the same time. 0 to 1024 |
| 54 | + If the consume run asynchronously, for instance inside go block, |
| 55 | + you may want to use this option. |
| 56 | + default: 0, which means gluttony doesn't care about how many message |
| 57 | + are processed simultaneously. |
| 58 | + :long-polling-duration - the duration (in seconds) for which the call waits for a message to |
| 59 | + arrive in the queue before returning. 0 to 20. |
| 60 | + default: 20 |
| 61 | + :exceptional-poll-delay-ms - when an Exception is received while polling, receiver wait for the |
| 62 | + number of ms until polling again. |
| 63 | + default: 10000 (10 seconds). |
| 64 | + :heartbeat - the duration (in seconds) for which the consumer extends message |
| 65 | + visibility if the message is being processed. 1 to 43199. |
| 66 | + default: nil |
| 67 | + If it isn't set, heartbeat doesn't work. |
| 68 | + If it's set, :heartbeat-timeout is required. |
| 69 | + Refer to AWS documents for more detail: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/working-with-messages.html |
| 70 | + If you set this option and :consume-limit, recommend to make |
| 71 | + :consume-limit bigger than :message-channel-size so as not to block |
| 72 | + heartbeat requests. |
| 73 | + :heartbeat-timeout - the timeout (in seconds) of heartbeat. |
| 74 | + If your consume function doesn't call respond or raise within heartbeat |
| 75 | + timeout, the consumer doesn't extend message visibility any more. |
| 76 | + 2 to 43200. |
| 77 | + default: nil |
| 78 | + :heartbeat-timeout must be longer than :heartbeat. |
| 79 | + :visibility-timeout-in-heartbeat - control visibility timeout (in seconds) in heartbeat. |
| 80 | + default: :heartbeat + 1 |
| 81 | + :visibility-timeout-in-heartbeat must be longer than :heartbeat. |
79 | 82 | Output:
|
80 | 83 | a instance of gluttony.record.consumer.Consumer"
|
81 | 84 | ^Consumer [queue-url consume & [opts]]
|
|
96 | 99 | 20)
|
97 | 100 | exceptional-poll-delay-ms (or (:exceptional-poll-delay-ms opts)
|
98 | 101 | 10000)
|
| 102 | + visibility-timeout-in-heartbeat (or (:visibility-timeout-in-heartbeat opts) |
| 103 | + (when (:heartbeat opts) |
| 104 | + (inc (:heartbeat opts)))) |
99 | 105 | consumer (c/new-consumer {:queue-url queue-url
|
100 | 106 | :consume consume
|
101 | 107 | :client client
|
|
109 | 115 | :exceptional-poll-delay-ms exceptional-poll-delay-ms
|
110 | 116 | :heartbeat (:heartbeat opts)
|
111 | 117 | :heartbeat-timeout (:heartbeat-timeout opts)
|
| 118 | + :visibility-timeout-in-heartbeat visibility-timeout-in-heartbeat |
112 | 119 | :receiver-enabled (atom true)})]
|
113 | 120 | (p/-start consumer)))
|
114 | 121 |
|
|
0 commit comments