Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ public MessageReceiptHandle removeReceiptHandle(ProxyContext context, Channel ch
}

protected boolean clientIsOffline(ReceiptHandleGroupKey groupKey) {
return this.consumerManager.findChannel(groupKey.getGroup(), groupKey.getChannel()) == null;
ClientChannelInfo clientChannelInfo= this.consumerManager.findChannel(groupKey.getGroup(), groupKey.getChannel());
Channel channel=clientChannelInfo.getChannel();
return channel==null || !channel.isActive();

}

protected void scheduleRenewTask() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@
import org.mockito.stubbing.Answer;

import static org.awaitility.Awaitility.await;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;

public class DefaultReceiptHandleManagerTest extends BaseServiceTest {
private DefaultReceiptHandleManager receiptHandleManager;
Expand Down Expand Up @@ -463,4 +462,20 @@ public void testClientOffline() {
listenerArgumentCaptor.getValue().handle(ConsumerGroupEvent.CLIENT_UNREGISTER, GROUP, new ClientChannelInfo(channel, "", LanguageCode.JAVA, 0));
assertTrue(receiptHandleManager.receiptHandleGroupMap.isEmpty());
}

@Test
public void testClientOffline_channelInactive(){

Channel mockChannel=Mockito.mock(Channel.class);
ClientChannelInfo mockClientChannelInfo=Mockito.mock(ClientChannelInfo.class);
ReceiptHandleGroupKey mockReceiptHandleGroupKey=new ReceiptHandleGroupKey(mockChannel,GROUP);
Mockito.when(consumerManager.findChannel(GROUP,mockChannel)).thenReturn(mockClientChannelInfo);
Mockito.when(mockClientChannelInfo.getChannel()).thenReturn(mockChannel);
Mockito.when(mockChannel.isActive()).thenReturn(false);
assertTrue(receiptHandleManager.clientIsOffline(mockReceiptHandleGroupKey));

}



}
Loading