Skip to content

V1.5.0

Latest

Choose a tag to compare

@Dimakoua Dimakoua released this 15 May 23:08
· 4 commits to master since this release

HareMq 1.5.0 Release Notes

New Features

Batch Consumer Support

Consumers can now accumulate and process multiple messages at once using two new options:

Option Default Description
batch_size 1 Number of messages to accumulate before dispatching to consume/2
batch_timeout_ms 5000 Milliseconds to wait before flushing a partial batch

When batch_size > 1, implement consume/2 instead of consume/1:

defmodule MyApp.BatchConsumer do
  use HareMq.Consumer,
    queue_name: "my_queue",
    batch_size: 10,
    batch_timeout_ms: 2000

  def consume(messages, :batch) do
    IO.puts("Received batch of #{length(messages)} messages")
    :ok
  end
end

How it works:

  • The consumer buffers incoming messages until batch_size messages are received or batch_timeout_ms elapses, whichever comes first.
  • prefetch_count is automatically set to at least batch_size to ensure the broker delivers enough messages.
  • Returning :ok or {:ok, _} individually acknowledges every message in the batch.
  • Returning :error or {:error, _} triggers the retry/dead-letter flow for each message independently.
  • Pending batch messages are nack'd if the consumer process crashes or terminates.

Feature compatibility:

Batch processing integrates with all existing HareMq features:

  • Retry & Delay Cascade — Each message in a failed batch is independently routed through the retry flow with its own delay and retry count.
  • Dead-lettering — Individual messages that exceed retry_limit are moved to the .dead queue.
  • Auto-scalingHareMq.DynamicConsumer supports batch_size. The AutoScaler scales worker processes based on queue depth as usual.
  • Stream Queuesbatch_size works with stream: true for high-performance log processing.

Tests

  • Added integration test suite HareMq.Consumer.BatchTest covering:
    • Full batch dispatch when batch_size is reached.
    • Partial batch flush triggered by batch_timeout_ms.
    • Batch processing on stream queues.
    • Per-message retry republishing when a batch returns :error.
    • Verification that failed batch messages appear in the delay queue.

Upgrade Notes

Update your dependency in mix.exs:

{:hare_mq, "~> 1.5.0"}

Existing consumers that implement consume/1 continue to work without any changes. Batch processing is opt-in via batch_size.

Full Changelog: v1.4.0...v1.5.0