@@ -29,7 +29,8 @@ groups() ->
2929 autodelete_amqp091_dest_on_confirm ,
3030 autodelete_amqp091_dest_on_publish ,
3131 simple_amqp10_dest ,
32- simple_amqp10_src
32+ simple_amqp10_src ,
33+ message_prop_conversion
3334 ]},
3435 {with_map_config , [], [
3536 simple ,
@@ -168,6 +169,116 @@ simple_amqp10_src(Config) ->
168169 ok
169170 end ).
170171
172+ message_prop_conversion (Config ) ->
173+ MapConfig = ? config (map_config , Config ),
174+ Src = ? config (srcq , Config ),
175+ Dest = ? config (destq , Config ),
176+ ok = rabbit_ct_broker_helpers :rpc (Config ,
177+ 0 ,
178+ application ,
179+ set_env ,
180+ [rabbitmq_shovel , convert_amqp10_props_to_amqp091 , true ]),
181+ with_session (Config ,
182+ fun (Sess ) ->
183+ shovel_test_utils :set_param (
184+ Config ,
185+ <<" test" >>, [{<<" src-protocol" >>, <<" amqp10" >>},
186+ {<<" src-address" >>, Src },
187+ {<<" dest-protocol" >>, <<" amqp091" >>},
188+ {<<" dest-queue" >>, Dest },
189+ {<<" add-forward-headers" >>, true },
190+ {<<" dest-add-timestamp-header" >>, true },
191+ {<<" publish-properties" >>,
192+ case MapConfig of
193+ true -> #{<<" cluster_id" >> => <<" x" >>};
194+ _ -> [{<<" cluster_id" >>, <<" x" >>}]
195+ end }
196+ ]),
197+ LinkName = <<" dynamic-sender-" , Dest /binary >>,
198+ Tag = <<" tag1" >>,
199+ Payload = <<" payload" >>,
200+ {ok , Sender } = amqp10_client :attach_sender_link (Sess , LinkName , Src ,
201+ unsettled , unsettled_state ),
202+ ok = await_amqp10_event (link , Sender , attached ),
203+ Headers = #{durable => true , priority => 3 , ttl => 180000 },
204+ Msg = amqp10_msg :set_headers (Headers ,
205+ amqp10_msg :new (Tag , Payload , false )),
206+ Msg2 = amqp10_msg :set_properties (#{
207+ message_id => <<" message-id" >>,
208+ user_id => <<" guest" >>,
209+ to => <<" to" >>,
210+ subject => <<" subject" >>,
211+ reply_to => <<" reply-to" >>,
212+ correlation_id => <<" correlation-id" >>,
213+ content_type => <<" content-type" >>,
214+ content_encoding => <<" content-encoding" >>,
215+ % absolute_expiry_time => 123456789,
216+ creation_time => 123456789 ,
217+ group_id => <<" group-id" >>,
218+ group_sequence => 123 ,
219+ reply_to_group_id => <<" reply-to-group-id" >>
220+ }, Msg ),
221+ Msg3 = amqp10_msg :set_application_properties (#{
222+ <<" x-binary" >> => <<" binary" >>,
223+ <<" x-int" >> => 33 ,
224+ <<" x-negative-int" >> => - 33 ,
225+ <<" x-float" >> => 1.3 ,
226+ <<" x-true" >> => true ,
227+ <<" x-false" >> => false
228+ }, Msg2 ),
229+ ok = amqp10_client :send_msg (Sender , Msg3 ),
230+ receive
231+ {amqp10_disposition , {accepted , Tag }} -> ok
232+ after 3000 ->
233+ exit (publish_disposition_not_received )
234+ end ,
235+ amqp10_client :detach_link (Sender ),
236+ Channel = rabbit_ct_client_helpers :open_channel (Config ),
237+ {# 'basic.get_ok' {}, # amqp_msg {payload = Payload , props = # 'P_basic' {
238+ content_type = ReceivedContentType ,
239+ content_encoding = ReceivedContentEncoding ,
240+ headers = Headers2 ,
241+ delivery_mode = ReceivedDeliveryMode ,
242+ priority = ReceivedPriority ,
243+ correlation_id = ReceivedCorrelationId ,
244+ reply_to = ReceivedReplyTo ,
245+ expiration = ReceivedExpiration ,
246+ message_id = ReceivedMessageId ,
247+ timestamp = ReceivedTimestamp ,
248+ type = _ReceivedType ,
249+ user_id = ReceivedUserId ,
250+ app_id = _ReceivedAppId ,
251+ cluster_id = _ReceivedClusterId
252+ }}} = amqp_channel :call (Channel , # 'basic.get' {queue = Dest , no_ack = true }),
253+
254+ ? assertEqual (<<" payload" >>, Payload ),
255+ ? assertEqual (2 , ReceivedDeliveryMode ),
256+ ? assertEqual ({longstr , <<" binary" >>}, rabbit_misc :table_lookup (Headers2 , <<" x-binary" >>)),
257+ ? assertEqual ({long , 33 }, rabbit_misc :table_lookup (Headers2 , <<" x-int" >>)),
258+ ? assertEqual ({long , - 33 }, rabbit_misc :table_lookup (Headers2 , <<" x-negative-int" >>)),
259+ ? assertEqual ({double , 1.3 }, rabbit_misc :table_lookup (Headers2 , <<" x-float" >>)),
260+ ? assertEqual ({bool , true }, rabbit_misc :table_lookup (Headers2 , <<" x-true" >>)),
261+ ? assertEqual ({bool , false }, rabbit_misc :table_lookup (Headers2 , <<" x-false" >>)),
262+
263+ ? assertEqual (<<" content-type" >>, ReceivedContentType ),
264+ ? assertEqual (<<" content-encoding" >>, ReceivedContentEncoding ),
265+
266+ ? assertEqual (3 , ReceivedPriority ),
267+ ? assertEqual (<<" correlation-id" >>, ReceivedCorrelationId ),
268+ ? assertEqual (<<" reply-to" >>, ReceivedReplyTo ),
269+ ? assertEqual (<<" 180000" >>, ReceivedExpiration ),
270+ ? assertEqual (<<" message-id" >>, ReceivedMessageId ),
271+ ? assertEqual (123456 , ReceivedTimestamp ), % timestamp is divided by 1 000
272+ ? assertEqual (<<" guest" >>, ReceivedUserId ),
273+ ok
274+ end ),
275+ ok = rabbit_ct_broker_helpers :rpc (Config ,
276+ 0 ,
277+ application ,
278+ set_env ,
279+ [rabbitmq_shovel , convert_amqp10_props_to_amqp091 , false ]).
280+
281+
171282change_definition (Config ) ->
172283 Src = ? config (srcq , Config ),
173284 Dest = ? config (destq , Config ),
0 commit comments