@@ -40,8 +40,6 @@ var _ = Describe("Streaming Producers", func() {
40
40
producer , err := testEnvironment .NewProducer (testProducerStream , nil )
41
41
Expect (err ).NotTo (HaveOccurred ())
42
42
Expect (producer .BatchSend (CreateArrayMessagesForTesting (5 ))).NotTo (HaveOccurred ())
43
- // we can't close the subscribe until the publish is finished
44
- time .Sleep (200 * time .Millisecond )
45
43
Expect (producer .Close ()).NotTo (HaveOccurred ())
46
44
})
47
45
@@ -55,8 +53,6 @@ var _ = Describe("Streaming Producers", func() {
55
53
Expect (err ).NotTo (HaveOccurred ())
56
54
57
55
Expect (producer .BatchSend (CreateArrayMessagesForTesting (5 ))).NotTo (HaveOccurred ())
58
- // we can't close the subscribe until the publish is finished
59
- time .Sleep (200 * time .Millisecond )
60
56
err = producer .Close ()
61
57
Expect (err ).NotTo (HaveOccurred ())
62
58
}(& wg )
@@ -217,6 +213,22 @@ var _ = Describe("Streaming Producers", func() {
217
213
Expect (producer .Close ()).NotTo (HaveOccurred ())
218
214
})
219
215
216
+ It ("Wait for inflight messages" , func () {
217
+ // https://github.com/rabbitmq/rabbitmq-stream-go-client/issues/103
218
+
219
+ producer , err := testEnvironment .NewProducer (testProducerStream , nil )
220
+ Expect (err ).NotTo (HaveOccurred ())
221
+
222
+ for i := 0 ; i < 65672 ; i ++ {
223
+ Expect (producer .Send (amqp .NewMessage ([]byte ("h" )))).NotTo (HaveOccurred ())
224
+ }
225
+
226
+ Expect (producer .Close ()).NotTo (HaveOccurred ())
227
+ Expect (producer .lenUnConfirmed ()).To (Equal (0 ))
228
+ Expect (producer .lenPendingMessages ()).To (Equal (0 ))
229
+ Expect (len (producer .messageSequenceCh )).To (Equal (0 ))
230
+ })
231
+
220
232
It ("Handle close" , func () {
221
233
var commandIdRecv int32
222
234
@@ -292,7 +304,7 @@ var _ = Describe("Streaming Producers", func() {
292
304
}, 5 * time .Second ).Should (Equal (int32 (101 )),
293
305
"confirm should receive same messages send by producer" )
294
306
295
- Expect (len ( producer .unConfirmedMessages )).To (Equal (0 ))
307
+ Expect (producer .lenUnConfirmed ( )).To (Equal (0 ))
296
308
Expect (producer .Close ()).NotTo (HaveOccurred ())
297
309
// in this case must raise an error since the producer is closed
298
310
Expect (producer .Close ()).To (HaveOccurred ())
@@ -323,7 +335,7 @@ var _ = Describe("Streaming Producers", func() {
323
335
By ("Max frame Error" )
324
336
s := make ([]byte , 1148576 )
325
337
Expect (producer .Send (amqp .NewMessage (s ))).To (HaveOccurred ())
326
- Expect (len ( producer .unConfirmedMessages )).To (Equal (0 ))
338
+ Expect (producer .lenUnConfirmed ( )).To (Equal (0 ))
327
339
Expect (producer .Close ()).NotTo (HaveOccurred ())
328
340
329
341
producer , err = testEnvironment .NewProducer (testProducerStream ,
@@ -348,7 +360,7 @@ var _ = Describe("Streaming Producers", func() {
348
360
}, 5 * time .Second ).Should (Equal (int32 (101 )),
349
361
"confirm should receive same messages send by producer" )
350
362
351
- Expect (len ( producer .unConfirmedMessages )).To (Equal (0 ))
363
+ Expect (producer .lenUnConfirmed ( )).To (Equal (0 ))
352
364
Expect (producer .Close ()).NotTo (HaveOccurred ())
353
365
354
366
})
@@ -381,7 +393,7 @@ var _ = Describe("Streaming Producers", func() {
381
393
}, 5 * time .Second ).Should (Equal (int32 (10 )),
382
394
"confirm should receive same messages send by producer" )
383
395
384
- Expect (len ( producer .unConfirmedMessages )).To (Equal (0 ))
396
+ Expect (producer .lenUnConfirmed ( )).To (Equal (0 ))
385
397
Expect (producer .Close ()).NotTo (HaveOccurred ())
386
398
})
387
399
@@ -418,7 +430,7 @@ var _ = Describe("Streaming Producers", func() {
418
430
}, 5 * time .Second ).Should (Equal (int32 (10 )),
419
431
"confirm should receive same messages send by producer" )
420
432
421
- Expect (len ( producer .unConfirmedMessages )).To (Equal (0 ))
433
+ Expect (producer .lenUnConfirmed ( )).To (Equal (0 ))
422
434
err = producer .Close ()
423
435
Expect (err ).NotTo (HaveOccurred ())
424
436
})
@@ -561,7 +573,7 @@ var _ = Describe("Streaming Producers", func() {
561
573
}, 5 * time .Second ).Should (Equal (int32 (232 )),
562
574
"confirm should receive same messages send by producer" )
563
575
564
- Expect (len ( producer .unConfirmedMessages )).To (Equal (0 ))
576
+ Expect (producer .lenUnConfirmed ( )).To (Equal (0 ))
565
577
566
578
// same test above but using batch send
567
579
var arr []message.StreamMessage
@@ -578,7 +590,7 @@ var _ = Describe("Streaming Producers", func() {
578
590
}, 5 * time .Second ).Should (Equal (int32 (12 * 20 )),
579
591
"confirm should receive same messages send by producer" )
580
592
581
- Expect (len ( producer .unConfirmedMessages )).To (Equal (0 ))
593
+ Expect (producer .lenUnConfirmed ( )).To (Equal (0 ))
582
594
583
595
Expect (producer .Close ()).NotTo (HaveOccurred ())
584
596
@@ -651,7 +663,7 @@ var _ = Describe("Streaming Producers", func() {
651
663
}, 5 * time .Second ).Should (Equal (int32 (501 )),
652
664
"confirm should receive same messages send by producer" )
653
665
654
- Expect (len ( producer .unConfirmedMessages )).To (Equal (0 ))
666
+ Expect (producer .lenUnConfirmed ( )).To (Equal (0 ))
655
667
atomic .StoreInt32 (& messagesConfirmed , 0 )
656
668
657
669
for z := 0 ; z < 501 ; z ++ {
@@ -664,7 +676,7 @@ var _ = Describe("Streaming Producers", func() {
664
676
}, 5 * time .Second ).Should (Equal (int32 (501 * 5 )),
665
677
"confirm should receive same messages send by producer" )
666
678
667
- Expect (len ( producer .unConfirmedMessages )).To (Equal (0 ))
679
+ Expect (producer .lenUnConfirmed ( )).To (Equal (0 ))
668
680
Expect (producer .Close ()).NotTo (HaveOccurred ())
669
681
})
670
682
@@ -724,7 +736,7 @@ func testCompress(producer *Producer) {
724
736
}, 5 * time .Second ).Should (Equal (int32 (457 )),
725
737
"confirm should receive same messages send by producer" )
726
738
727
- Expect (len ( producer .unConfirmedMessages )).To (Equal (0 ))
739
+ Expect (producer .lenUnConfirmed ( )).To (Equal (0 ))
728
740
atomic .StoreInt32 (& messagesConfirmed , 0 )
729
741
730
742
for z := 0 ; z < 457 ; z ++ {
@@ -789,7 +801,7 @@ func verifyProducerSent(producer *Producer, confirmationReceived *int32, message
789
801
}, 10 * time .Second , 1 * time .Second ).Should (Equal (int32 (messageSent )),
790
802
"confirm should receive same messages send by producer" )
791
803
792
- Expect (len ( producer .unConfirmedMessages )).To (Equal (0 ))
804
+ Expect (producer .lenUnConfirmed ( )).To (Equal (0 ))
793
805
}
794
806
795
807
func runConcurrentlyAndWaitTillAllDone (threadCount int , wg * sync.WaitGroup , runner func (int )) {
0 commit comments