Skip to content

Commit

Permalink
Merge pull request #120 from mjayprateek/alpha_features_readme
Browse files Browse the repository at this point in the history
Updating README with alpha features
  • Loading branch information
mjayprateek committed Nov 8, 2019
2 parents 75547cc + d341be0 commit 16de939
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,39 @@ All Ziggurat configs should be in your `clonfig` `config.edn` under the `:ziggur
* jobs - The number of consumers that should be reading from the retry queues and the prefetch count of each consumer
* http-server - Ziggurat starts an http server by default and gives apis for ping health-check and deadset management. This defines the port and the number of threads of the http server.

## Alpha (Experimental) Features
Ziggurat 2.12.6 introduces a few configurations to enable the following:
- Add a delay (configurable) in processing the messages from RabbitMQ channels
- Add exponential backoff retry strategy for processing messages from RabbitMQ channels

Both of these features can be enabled by providing the following flags in `config.edn`.

```
:stream-router {:default {:application-id "test"
:bootstrap-servers "localhost:9092"
:stream-threads-count [1 :int]
:origin-topic "topic"
:upgrade-from "1.1"
:channels {:channel {:worker-count [10 :int]
:retry {:count [5 :int]
:enabled [true :bool]}}
:with-delay {:worker-count [10 :int]
:retry {:count [5 :int]
:enabled [true :bool]}
:channel-delay-ms [1000 :int]}
:with-custom-timeout {:worker-count [10 :int]
:retry {:count [5 :int]
:enabled [true :bool]
:queue-timeout-ms [2000 :int]}}
:with-exponential-retry {:worker-count [10 :int]
:retry {:count [5 :int]
:enabled [true :bool]
:queue-timeout-ms [1000 :int]
:exponential-backoff-enabled [true :bool]}}}}}
```
_Note: Alpha features are experimental features and SHOULD NOT be used until they're stable._


## Contribution
- For dev setup and contributions please refer to CONTRIBUTING.md

Expand Down
6 changes: 4 additions & 2 deletions src/ziggurat/messaging/producer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@
(int (* (- (Math/pow 2 (- retry-count message-retry-count)) 1) queue-timeout-ms)))

(defn get-queue-timeout-ms [topic-entity channel message]
"Get queue timeout from config. It will use channel queue-timeout-ms if defined, otherwise it will use rabbitmq delay queue-timeout-ms.
If exponential-backoff-enabled is true, queue-timeout-ms will be exponential with formula (2^n)-1, n is message retry-count."
"Get queue timeout from config. It will use channel `queue-timeout-ms` if defined, otherwise it will use rabbitmq delay `queue-timeout-ms`.
If `exponential-backoff-enabled` is true, `queue-timeout-ms` will be exponential with formula `(2^n)-1`, where `n` is message retry-count.
_NOTE: Exponential backoff for channel retries is an experimental feature. It should not be used until released in a stable version._"
(let [queue-timeout-ms (-> (rabbitmq-config) :delay :queue-timeout-ms)
channel-queue-timeout-ms (get-channel-retry-queue-timeout-ms topic-entity channel)
exponential-backoff-enabled (channel-retries-exponential-backoff-enabled topic-entity channel)]
Expand Down

0 comments on commit 16de939

Please sign in to comment.