File tree Expand file tree Collapse file tree 8 files changed +47
-22
lines changed Expand file tree Collapse file tree 8 files changed +47
-22
lines changed Original file line number Diff line number Diff line change 11# Changelog
22All notable changes to this project will be documented in this file.
33
4- ## [ 1.6.4 ] - 2025-08-19
4+ ## [ 1.7.0 ] - 2025-08-19
55### Added
66- Ability to specify a custom job class for publishing via ` publishing_job_class_callable ` config.
77- Ability to specify a default queue for publishing jobs via ` default_publishing_job_queue ` config.
Original file line number Diff line number Diff line change 88PATH
99 remote: .
1010 specs:
11- rabbit_messaging (1.6.4 )
11+ rabbit_messaging (1.7.0 )
1212 bunny (~> 2.0 )
1313 kicks
1414
Original file line number Diff line number Diff line change @@ -169,11 +169,27 @@ def configure
169169 config . validate!
170170 end
171171
172- def publish ( message_options , custom_queue_name : nil )
173- # Extract custom_queue_name from message_options for backward compatibility
174- custom_queue_name ||= message_options [ :custom_queue_name ]
175-
176- message = Publishing ::Message . new ( message_options )
172+ def publish (
173+ routing_key : nil ,
174+ event : nil ,
175+ data : { } ,
176+ exchange_name : [ ] ,
177+ confirm_select : true ,
178+ realtime : false ,
179+ headers : { } ,
180+ message_id : nil ,
181+ custom_queue_name : nil
182+ )
183+ message = Publishing ::Message . new (
184+ routing_key : routing_key ,
185+ event : event ,
186+ data : data ,
187+ exchange_name : exchange_name ,
188+ confirm_select : confirm_select ,
189+ realtime : realtime ,
190+ headers : headers ,
191+ message_id : message_id ,
192+ )
177193 publish_job_callable = config . publishing_job_class_callable || Publishing ::Job
178194 queue_name = custom_queue_name || default_queue_name
179195
Original file line number Diff line number Diff line change 55module Rabbit ::Publishing
66 class Job < ActiveJob ::Base
77 def perform ( message )
8- Rabbit ::Publishing . publish ( Message . new ( message ) )
8+ Rabbit ::Publishing . publish ( Message . new ( ** message ) )
99 end
1010 end
1111end
Original file line number Diff line number Diff line change @@ -9,15 +9,24 @@ class Message
99 alias_method :confirm_select? , :confirm_select
1010 alias_method :realtime? , :realtime
1111
12- def initialize ( attributes = { } )
13- self . routing_key = attributes [ :routing_key ]
14- self . event = attributes [ :event ] &.to_s
15- self . data = attributes . fetch ( :data , { } )
16- self . exchange_name = Array ( attributes . fetch ( :exchange_name , [ ] ) )
17- self . confirm_select = attributes . fetch ( :confirm_select , true )
18- self . realtime = attributes . fetch ( :realtime , false )
19- self . headers = attributes . fetch ( :headers , { } )
20- self . message_id = attributes [ :message_id ]
12+ def initialize (
13+ routing_key : nil ,
14+ event : nil ,
15+ data : { } ,
16+ exchange_name : [ ] ,
17+ confirm_select : true ,
18+ realtime : false ,
19+ headers : { } ,
20+ message_id : nil
21+ )
22+ self . routing_key = routing_key
23+ self . event = event &.to_s
24+ self . data = data
25+ self . exchange_name = Array ( exchange_name )
26+ self . confirm_select = confirm_select
27+ self . realtime = realtime
28+ self . headers = headers
29+ self . message_id = message_id
2130 end
2231
2332 def to_hash
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
33module Rabbit
4- VERSION = "1.6.4 "
4+ VERSION = "1.7.0 "
55end
Original file line number Diff line number Diff line change 22
33describe Rabbit ::Publishing ::Message do
44 describe "basic_publish_args" do
5- subject ( :message ) { described_class . new ( attributes ) }
5+ subject ( :message ) { described_class . new ( ** attributes ) }
66
77 context "rounting key not specified" do
88 let ( :attributes ) { Hash [ event : :ping ] }
Original file line number Diff line number Diff line change 8080 test_group_id.test_project_id.some_exchange / some_queue / {"foo":"bar"} / some_event / \
8181 confirm: ...world"}
8282 MSG
83- described_class . publish ( message_options , **additional_params )
83+ described_class . publish ( ** message_options , **additional_params )
8484 end
8585
8686 after do
134134 confirm: {"hello":"world"}
135135 MSG
136136
137- expect { described_class . publish ( message_options ) } . not_to raise_error
137+ expect { described_class . publish ( ** message_options ) } . not_to raise_error
138138 end
139139
140140 it "raises the last exception after max retries" do
141141 allow ( channel ) . to receive ( :basic_publish ) . and_raise ( Bunny ::ConnectionClosedError . new ( "" ) )
142142
143- expect { described_class . publish ( message_options ) }
143+ expect { described_class . publish ( ** message_options ) }
144144 . to raise_error ( Bunny ::ConnectionClosedError )
145145 end
146146 end
You can’t perform that action at this time.
0 commit comments