@@ -27,7 +27,9 @@ groups() ->
27
27
autodelete_amqp091_dest_on_confirm ,
28
28
autodelete_amqp091_dest_on_publish ,
29
29
simple_amqp10_dest ,
30
- simple_amqp10_src
30
+ simple_amqp10_src ,
31
+ message_prop_conversion ,
32
+ message_prop_conversion_no_props
31
33
]},
32
34
{with_map_config , [], [
33
35
simple ,
@@ -169,6 +171,168 @@ simple_amqp10_src(Config) ->
169
171
ok
170
172
end ).
171
173
174
+ message_prop_conversion (Config ) ->
175
+ MapConfig = ? config (map_config , Config ),
176
+ Src = ? config (srcq , Config ),
177
+ Dest = ? config (destq , Config ),
178
+ with_session (Config ,
179
+ fun (Sess ) ->
180
+ shovel_test_utils :set_param (
181
+ Config ,
182
+ <<" test" >>, [{<<" src-protocol" >>, <<" amqp10" >>},
183
+ {<<" src-address" >>, Src },
184
+ {<<" dest-protocol" >>, <<" amqp091" >>},
185
+ {<<" dest-queue" >>, Dest },
186
+ {<<" add-forward-headers" >>, true },
187
+ {<<" dest-add-timestamp-header" >>, true },
188
+ {<<" publish-properties" >>,
189
+ case MapConfig of
190
+ true -> #{<<" cluster_id" >> => <<" x" >>};
191
+ _ -> [{<<" cluster_id" >>, <<" x" >>}]
192
+ end }
193
+ ]),
194
+ LinkName = <<" dynamic-sender-" , Dest /binary >>,
195
+ Tag = <<" tag1" >>,
196
+ Payload = <<" payload" >>,
197
+ {ok , Sender } = amqp10_client :attach_sender_link (Sess , LinkName , Src ,
198
+ unsettled , unsettled_state ),
199
+ ok = await_amqp10_event (link , Sender , attached ),
200
+ Headers = #{durable => true , priority => 3 , ttl => 180000 },
201
+ Msg = amqp10_msg :set_headers (Headers ,
202
+ amqp10_msg :new (Tag , Payload , false )),
203
+ Msg2 = amqp10_msg :set_properties (#{
204
+ message_id => <<" message-id" >>,
205
+ user_id => <<" guest" >>,
206
+ to => <<" to" >>,
207
+ subject => <<" subject" >>,
208
+ reply_to => <<" reply-to" >>,
209
+ correlation_id => <<" correlation-id" >>,
210
+ content_type => <<" content-type" >>,
211
+ content_encoding => <<" content-encoding" >>,
212
+ % absolute_expiry_time => 123456789,
213
+ creation_time => 123456789 ,
214
+ group_id => <<" group-id" >>,
215
+ group_sequence => 123 ,
216
+ reply_to_group_id => <<" reply-to-group-id" >>
217
+ }, Msg ),
218
+ Msg3 = amqp10_msg :set_application_properties (#{
219
+ <<" x-binary" >> => <<" binary" >>,
220
+ <<" x-int" >> => 33 ,
221
+ <<" x-negative-int" >> => - 33 ,
222
+ <<" x-float" >> => 1.3 ,
223
+ <<" x-true" >> => true ,
224
+ <<" x-false" >> => false
225
+ }, Msg2 ),
226
+ ok = amqp10_client :send_msg (Sender , Msg3 ),
227
+ receive
228
+ {amqp10_disposition , {accepted , Tag }} -> ok
229
+ after 3000 ->
230
+ exit (publish_disposition_not_received )
231
+ end ,
232
+ amqp10_client :detach_link (Sender ),
233
+ Channel = rabbit_ct_client_helpers :open_channel (Config ),
234
+ {# 'basic.get_ok' {}, # amqp_msg {payload = Payload , props = # 'P_basic' {
235
+ content_type = ReceivedContentType ,
236
+ content_encoding = ReceivedContentEncoding ,
237
+ headers = Headers2 ,
238
+ delivery_mode = ReceivedDeliveryMode ,
239
+ priority = ReceivedPriority ,
240
+ correlation_id = ReceivedCorrelationId ,
241
+ reply_to = ReceivedReplyTo ,
242
+ expiration = ReceivedExpiration ,
243
+ message_id = ReceivedMessageId ,
244
+ timestamp = ReceivedTimestamp ,
245
+ type = _ReceivedType ,
246
+ user_id = ReceivedUserId ,
247
+ app_id = _ReceivedAppId ,
248
+ cluster_id = _ReceivedClusterId
249
+ }}} = amqp_channel :call (Channel , # 'basic.get' {queue = Dest , no_ack = true }),
250
+
251
+ ? assertEqual (<<" payload" >>, Payload ),
252
+ ? assertEqual (2 , ReceivedDeliveryMode ),
253
+ ? assertEqual ({longstr , <<" binary" >>}, rabbit_misc :table_lookup (Headers2 , <<" x-binary" >>)),
254
+ ? assertEqual ({long , 33 }, rabbit_misc :table_lookup (Headers2 , <<" x-int" >>)),
255
+ ? assertEqual ({long , - 33 }, rabbit_misc :table_lookup (Headers2 , <<" x-negative-int" >>)),
256
+ ? assertEqual ({double , 1.3 }, rabbit_misc :table_lookup (Headers2 , <<" x-float" >>)),
257
+ ? assertEqual ({bool , true }, rabbit_misc :table_lookup (Headers2 , <<" x-true" >>)),
258
+ ? assertEqual ({bool , false }, rabbit_misc :table_lookup (Headers2 , <<" x-false" >>)),
259
+
260
+ ? assertEqual (<<" content-type" >>, ReceivedContentType ),
261
+ ? assertEqual (<<" content-encoding" >>, ReceivedContentEncoding ),
262
+
263
+ ? assertEqual (3 , ReceivedPriority ),
264
+ ? assertEqual (<<" correlation-id" >>, ReceivedCorrelationId ),
265
+ ? assertEqual (<<" reply-to" >>, ReceivedReplyTo ),
266
+ ? assertEqual (<<" 180000" >>, ReceivedExpiration ),
267
+ ? assertEqual (<<" message-id" >>, ReceivedMessageId ),
268
+ ? assertEqual (123456 , ReceivedTimestamp ), % timestamp is divided by 1 000
269
+ ? assertEqual (<<" guest" >>, ReceivedUserId ),
270
+ ok
271
+ end ).
272
+
273
+ message_prop_conversion_no_props (Config ) ->
274
+ MapConfig = ? config (map_config , Config ),
275
+ Src = ? config (srcq , Config ),
276
+ Dest = ? config (destq , Config ),
277
+ with_session (Config ,
278
+ fun (Sess ) ->
279
+ shovel_test_utils :set_param (
280
+ Config ,
281
+ <<" test" >>, [{<<" src-protocol" >>, <<" amqp10" >>},
282
+ {<<" src-address" >>, Src },
283
+ {<<" dest-protocol" >>, <<" amqp091" >>},
284
+ {<<" dest-queue" >>, Dest },
285
+ {<<" add-forward-headers" >>, true },
286
+ {<<" dest-add-timestamp-header" >>, true },
287
+ {<<" publish-properties" >>,
288
+ case MapConfig of
289
+ true -> #{<<" cluster_id" >> => <<" x" >>};
290
+ _ -> [{<<" cluster_id" >>, <<" x" >>}]
291
+ end }
292
+ ]),
293
+ LinkName = <<" dynamic-sender-" , Dest /binary >>,
294
+ Tag = <<" tag1" >>,
295
+ Payload = <<" payload" >>,
296
+ {ok , Sender } = amqp10_client :attach_sender_link (Sess , LinkName , Src ,
297
+ unsettled , unsettled_state ),
298
+ ok = await_amqp10_event (link , Sender , attached ),
299
+ Msg = amqp10_msg :new (Tag , Payload , false ),
300
+ ok = amqp10_client :send_msg (Sender , Msg ),
301
+ receive
302
+ {amqp10_disposition , {accepted , Tag }} -> ok
303
+ after 3000 ->
304
+ exit (publish_disposition_not_received )
305
+ end ,
306
+ amqp10_client :detach_link (Sender ),
307
+ Channel = rabbit_ct_client_helpers :open_channel (Config ),
308
+ {# 'basic.get_ok' {}, # amqp_msg {payload = ReceivedPayload , props = # 'P_basic' {
309
+ content_type = undefined ,
310
+ content_encoding = undefined ,
311
+ headers = ReceivedHeaders ,
312
+ delivery_mode = ReceivedDeliveryMode ,
313
+ priority = ReceivedPriority ,
314
+ correlation_id = undefined ,
315
+ reply_to = undefined ,
316
+ expiration = undefined ,
317
+ message_id = undefined ,
318
+ timestamp = undefined ,
319
+ type = undefined ,
320
+ user_id = undefined ,
321
+ app_id = undefined ,
322
+ cluster_id = ReceivedClusterId
323
+ }}} = amqp_channel :call (Channel , # 'basic.get' {queue = Dest , no_ack = true }),
324
+
325
+ ? assertEqual (<<" payload" >>, ReceivedPayload ),
326
+ ? assertEqual (1 , ReceivedDeliveryMode ),
327
+ ? assertEqual (<<" x" >>, ReceivedClusterId ),
328
+ ? assertEqual (4 , ReceivedPriority ),
329
+
330
+ ? assertNotEqual (undefined , rabbit_misc :table_lookup (ReceivedHeaders , <<" x-shovelled" >>)),
331
+
332
+ ok
333
+ end ).
334
+
335
+
172
336
change_definition (Config ) ->
173
337
Src = ? config (srcq , Config ),
174
338
Dest = ? config (destq , Config ),
0 commit comments