@@ -72,11 +72,37 @@ deduplicate_message(Config) ->
7272 bind_new_exchange (Channel , <<" test" >>, <<" test" >>),
7373
7474 % % Deduplication header present
75+ % % String
7576 publish_message (Channel , <<" test" >>, " deduplicate-this" ),
7677 publish_message (Channel , <<" test" >>, " deduplicate-this" ),
7778
78- {# 'basic.get_ok' {}, _ } = amqp_channel :call (Channel , Get ),
79+ {# 'basic.get_ok' {delivery_tag = Tag1 }, _ } = amqp_channel :call (Channel , Get ),
80+ # 'basic.get_empty' {} = amqp_channel :call (Channel , Get ),
81+ amqp_channel :cast (Channel , # 'basic.ack' {delivery_tag = Tag1 }),
82+
83+ % % Integer
84+ publish_message (Channel , <<" test" >>, 42 ),
85+ publish_message (Channel , <<" test" >>, 42 ),
86+
87+ {# 'basic.get_ok' {delivery_tag = Tag2 }, _ } = amqp_channel :call (Channel , Get ),
88+ # 'basic.get_empty' {} = amqp_channel :call (Channel , Get ),
89+ amqp_channel :cast (Channel , # 'basic.ack' {delivery_tag = Tag2 }),
90+
91+ % % Float
92+ publish_message (Channel , <<" test" >>, 4.2 ),
93+ publish_message (Channel , <<" test" >>, 4.2 ),
94+
95+ {# 'basic.get_ok' {delivery_tag = Tag3 }, _ } = amqp_channel :call (Channel , Get ),
96+ # 'basic.get_empty' {} = amqp_channel :call (Channel , Get ),
97+ amqp_channel :cast (Channel , # 'basic.ack' {delivery_tag = Tag3 }),
98+
99+ % % None/null/nil/void/undefined
100+ publish_message (Channel , <<" test" >>, undefined ),
101+ publish_message (Channel , <<" test" >>, undefined ),
102+
103+ {# 'basic.get_ok' {delivery_tag = Tag4 }, _ } = amqp_channel :call (Channel , Get ),
79104 # 'basic.get_empty' {} = amqp_channel :call (Channel , Get ),
105+ amqp_channel :cast (Channel , # 'basic.ack' {delivery_tag = Tag4 }),
80106
81107 % % Deduplication header absent
82108 publish_message (Channel , <<" test" >>),
@@ -173,7 +199,13 @@ publish_message(Ch, Ex) ->
173199 amqp_channel :cast (Ch , Publish , Msg ).
174200
175201publish_message (Ch , Ex , D ) ->
176- Props = # 'P_basic' {headers = [{<<" x-deduplication-header" >>, longstr , D }]},
202+ Type = case D of
203+ D when is_integer (D ) -> long ;
204+ D when is_float (D ) -> float ;
205+ D when is_list (D ) -> longstr ;
206+ undefined -> void
207+ end ,
208+ Props = # 'P_basic' {headers = [{<<" x-deduplication-header" >>, Type , D }]},
177209 Publish = # 'basic.publish' {exchange = Ex , routing_key = <<" #" >>},
178210 Msg = # amqp_msg {props = Props , payload = <<" payload" >>},
179211 amqp_channel :cast (Ch , Publish , Msg ).
0 commit comments