@@ -259,7 +259,7 @@ void publishConsumeComplexMessage(
259
259
Client .ChunkListener chunkListener =
260
260
(client , correlationId , offset , messageCount , dataSize ) -> client .credit (correlationId , 1 );
261
261
Client .MessageListener messageListener =
262
- (correlationId , offset , chunkTimestamp , message ) -> {
262
+ (correlationId , offset , chunkTimestamp , committedOffset , message ) -> {
263
263
messages .add (message );
264
264
latch .countDown ();
265
265
};
@@ -395,7 +395,7 @@ void publishConsumeWithSimpleCodec() throws Exception {
395
395
(client , subscriptionId , offset , messageCount1 , dataSize ) ->
396
396
client .credit (subscriptionId , 1 ))
397
397
.messageListener (
398
- (subscriptionId , offset , chunkTimestamp , message ) -> {
398
+ (subscriptionId , offset , chunkTimestamp , committedOffset , message ) -> {
399
399
messageBodies .add (new String (message .getBodyAsBinary ()));
400
400
consumeLatch .countDown ();
401
401
}));
@@ -448,7 +448,7 @@ void batchPublishing() throws Exception {
448
448
(client , subscriptionId , offset , messageCount1 , dataSize ) ->
449
449
client .credit (subscriptionId , 1 ))
450
450
.messageListener (
451
- (subscriptionId , offset , chunkTimestamp , message ) -> {
451
+ (subscriptionId , offset , chunkTimestamp , committedOffset , message ) -> {
452
452
ByteBuffer bb = ByteBuffer .wrap (message .getBodyAsBinary ());
453
453
sizes .add (message .getBodyAsBinary ().length );
454
454
sequences .add (bb .getInt ());
@@ -479,7 +479,7 @@ void consume() throws Exception {
479
479
480
480
AtomicLong chunkTimestamp = new AtomicLong ();
481
481
Client .MessageListener messageListener =
482
- (corr , offset , chkTimestamp , message ) -> {
482
+ (corr , offset , chkTimestamp , committedOffset , message ) -> {
483
483
chunkTimestamp .set (chkTimestamp );
484
484
latch .countDown ();
485
485
};
@@ -515,7 +515,7 @@ void publishAndConsume(boolean directBuffer) throws Exception {
515
515
};
516
516
517
517
Client .MessageListener messageListener =
518
- (corr , offset , chunkTimestamp , data ) -> consumedLatch .countDown ();
518
+ (corr , offset , chunkTimestamp , committedOffset , data ) -> consumedLatch .countDown ();
519
519
520
520
Client client =
521
521
cf .get (
@@ -659,7 +659,7 @@ void declareAmqpStreamQueueAndUseItAsStream(TestInfo info) throws Exception {
659
659
(client1 , subscriptionId , offset , messageCount1 , dataSize ) ->
660
660
client1 .credit (subscriptionId , 1 ))
661
661
.messageListener (
662
- (subscriptionId , offset , chunkTimestamp , message ) ->
662
+ (subscriptionId , offset , chunkTimestamp , committedOffset , message ) ->
663
663
consumedLatch .countDown ()));
664
664
ConnectionFactory connectionFactory = new ConnectionFactory ();
665
665
try (Connection amqpConnection = connectionFactory .newConnection ()) {
@@ -837,4 +837,42 @@ void exchangeCommandVersions() {
837
837
assertThat (infos .stream ().filter (info -> info .getKey () == Constants .COMMAND_DECLARE_PUBLISHER ))
838
838
.isNotEmpty ();
839
839
}
840
+
841
+ @ Test
842
+ void deliverVersion2LastCommittedOffsetShouldBeSet () throws Exception {
843
+ int publishCount = 20_000 ;
844
+ byte correlationId = 42 ;
845
+ TestUtils .publishAndWaitForConfirms (cf , publishCount , stream );
846
+
847
+ CountDownLatch latch = new CountDownLatch (publishCount );
848
+
849
+ Client .ChunkListener chunkListener =
850
+ (client , corr , offset , messageCountInChunk , dataSize ) -> {
851
+ client .credit (correlationId , 1 );
852
+ };
853
+
854
+ AtomicLong committedOffset = new AtomicLong ();
855
+ Client .MessageListener messageListener =
856
+ (corr , offset , chkTimestamp , committedOfft , message ) -> {
857
+ committedOffset .set (committedOfft );
858
+ latch .countDown ();
859
+ };
860
+
861
+ Client client =
862
+ cf .get (
863
+ new Client .ClientParameters ()
864
+ .chunkListener (chunkListener )
865
+ .messageListener (messageListener ));
866
+
867
+ client .exchangeCommandVersions ();
868
+
869
+ Response response =
870
+ client .subscribe (correlationId , stream , OffsetSpecification .first (), credit );
871
+ assertThat (response .getResponseCode ()).isEqualTo (Constants .RESPONSE_CODE_OK );
872
+ assertThat (response .isOk ()).isTrue ();
873
+
874
+ assertThat (latch .await (10 , SECONDS )).isTrue ();
875
+ assertThat (committedOffset .get ()).isPositive ();
876
+ client .close ();
877
+ }
840
878
}
0 commit comments