Skip to content

Commit

Permalink
Keep 3.13.x compatible callback functions
Browse files Browse the repository at this point in the history
  • Loading branch information
LoisSotoLopez committed Oct 2, 2024
1 parent 4f328ce commit c8b2db3
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
- '1.16.3'
rmqref:
- v3.13.x
- v4.0.x
steps:
- uses: actions/checkout@v4
- name: Install Erlang and Elixir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,64 @@ defmodule RabbitMQMessageDeduplication.Queue do
passthrough1(state, do: set_queue_mode(term, qs))
end

#
# Compatibility with 3.13.x
#
@impl :rabbit_backing_queue
def publish(message, properties, boolean, pid, flow,
state = dqstate(queue_state: qs)) do
passthrough1(state) do
publish(message, properties, boolean, pid, flow, qs)
end
end

@impl :rabbit_backing_queue
def batch_publish(batch, pid, flow, state = dqstate(queue_state: qs)) do
passthrough1(state, do: batch_publish(batch, pid, flow, qs))
end

# Optimization for cases in which the queue is empty and the message
# is delivered straight to the client. Acknowledgement is enabled.
@impl :rabbit_backing_queue
def publish_delivered(message, properties, pid, flow, state) do
dqstate(queue_state: qs) = state

{ack_tag, state} = passthrough2(state) do
publish_delivered(message, properties, pid, flow, qs)
end

if dedup_queue?(state) do
head = Common.message_header(message, "x-deduplication-header")
{dqack(tag: ack_tag, header: head), state}
else
{ack_tag, state}
end
end

@impl :rabbit_backing_queue
def batch_publish_delivered(batch, pid, flow, state) do
dqstate(queue_state: qs) = state

passthrough2(state) do
batch_publish_delivered(batch, pid, flow, qs)
end
end

@impl :rabbit_backing_queue
def discard(msg_id, pid, flow, state = dqstate(queue_state: qs)) do
passthrough1(state, do: discard(msg_id, pid, flow, qs))
end

@impl :rabbit_backing_queue
def set_ram_duration_target(duration, state = dqstate(queue_state: qs)) do
passthrough1(state, do: set_ram_duration_target(duration, qs))
end

@impl :rabbit_backing_queue
def ram_duration(state = dqstate(queue_state: qs)) do
passthrough2(state, do: ram_duration(qs))
end

# Utility functions

# Enable/disable queue-level deduplication
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defmodule RabbitMQ.MessageDeduplicationPlugin.Mixfile do
extra_applications: [:rabbit],
mod: {RabbitMQMessageDeduplication, []},
registered: [RabbitMQMessageDeduplication],
broker_version_requirements: ["4.0.0"]
broker_version_requirements: ["3.13.0-3.13.x", "4.0.0-4.0.x"]
]
end

Expand Down

0 comments on commit c8b2db3

Please sign in to comment.