@@ -398,6 +398,60 @@ var _ = Describe("Streaming Consumers", func() {
398
398
399
399
})
400
400
401
+ It ("Application Message Properties" , func () {
402
+ producer , err := env .NewProducer (streamName , nil )
403
+
404
+ chConfirm := producer .NotifyPublishConfirmation ()
405
+ go func (ch ChannelPublishConfirm , p * Producer ) {
406
+ for ids := range ch {
407
+ for _ , msg := range ids {
408
+ Expect (msg .GetMessage ().GetApplicationProperties ()["key1" ]).To (Equal ("value1" ))
409
+ Expect (msg .GetMessage ().GetApplicationProperties ()["key2" ]).To (Equal ("value2" ))
410
+ Expect (msg .GetMessage ().GetApplicationProperties ()["key3" ]).To (Equal ("value3" ))
411
+ Expect (msg .GetMessage ().GetApplicationProperties ()["key4" ]).To (Equal ("value4" ))
412
+ Expect (msg .GetMessage ().GetMessageAnnotations ()["annotation_key_1" ]).To (Equal ("annotation_vale_1" ))
413
+ Expect (msg .GetMessage ().GetMessageAnnotations ()["annotation_key_2" ]).To (Equal ("annotation_vale_2" ))
414
+ }
415
+ }
416
+ }(chConfirm , producer )
417
+
418
+ appMap := map [string ]interface {}{
419
+ "key1" : "value1" ,
420
+ "key2" : "value2" ,
421
+ "key3" : "value3" ,
422
+ "key4" : "value4" ,
423
+ "key5" : "value5" ,
424
+ }
425
+ Expect (err ).NotTo (HaveOccurred ())
426
+ msg := amqp .NewMessage ([]byte ("message" ))
427
+ msg .ApplicationProperties = appMap
428
+ msg .Annotations = map [interface {}]interface {}{
429
+ "annotation_key_1" : "annotation_vale_1" ,
430
+ "annotation_key_2" : "annotation_vale_2" ,
431
+ }
432
+
433
+ Expect (producer .Send (msg )).NotTo (HaveOccurred ())
434
+ defer func (producer * Producer ) {
435
+ Expect (producer .Close ()).NotTo (HaveOccurred ())
436
+ }(producer )
437
+
438
+ consumer , err := env .NewConsumer (streamName ,
439
+ func (consumerContext ConsumerContext , message * amqp.Message ) {
440
+ Expect (message .ApplicationProperties ["key1" ]).To (Equal ("value1" ))
441
+ Expect (message .ApplicationProperties ["key2" ]).To (Equal ("value2" ))
442
+ Expect (message .ApplicationProperties ["key3" ]).To (Equal ("value3" ))
443
+ Expect (message .ApplicationProperties ["key4" ]).To (Equal ("value4" ))
444
+ Expect (message .Annotations ["annotation_key_1" ]).To (Equal ("annotation_vale_1" ))
445
+ Expect (message .Annotations ["annotation_key_2" ]).To (Equal ("annotation_vale_2" ))
446
+
447
+ }, NewConsumerOptions ().SetOffset (OffsetSpecification {}.First ()).
448
+ SetConsumerName ("consumer_test" ))
449
+ Expect (err ).NotTo (HaveOccurred ())
450
+ time .Sleep (200 * time .Millisecond )
451
+ Expect (consumer .Close ()).NotTo (HaveOccurred ())
452
+
453
+ })
454
+
401
455
It ("Consistent Messages" , func () {
402
456
producer , err := env .NewProducer (streamName , nil )
403
457
Expect (err ).NotTo (HaveOccurred ())
0 commit comments