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