CAP icon indicating copy to clipboard operation
CAP copied to clipboard

When using RedisStreams only one ConsumerGroup is created

Open mlatoszek opened this issue 2 years ago • 2 comments

Fixed RedisStream.Manager.Extensions.TryGetOrCreateStreamGroupAsync to create ConsumerGroup when not found.

mlatoszek avatar Sep 22 '22 11:09 mlatoszek

When using RedisStreams as a transport along with multiple Consumer Groups - the current implementation throws exception when staring subscriber that has different consumer group that the one that created the stream. It seems like creation part was missing from TryGetOrCreateStreamGroupAsync method.

mlatoszek avatar Sep 22 '22 11:09 mlatoszek

@mlatoszek , Could you please confirm if I understood correctly the issue, you had two deployed instances that use CAP RedisStreams , and each one of them has a unique DefaultGroupName, or do both instances use the same name? as if they use different names, this is already handled when reading the stream group by StreamName and then filtering the group by DefaultGroupName after that we are creating the group if it was not there, you will find that in TryGetOrCreateStreamConsumerGroupAsync method the public one

MahmoudSamir101 avatar Sep 22 '22 21:09 MahmoudSamir101

Hi @MahmoudSamir101,

The issue occurs when there are two instances with different consumer group name - using the same stream. Please see the code below: image if (streamExist) the second consumer group will not be created as the operations ends on checking if there is already a consumer group with the same name registered in the stream - but if there isn't - nothing happens.

That's why TryGetOrCreateStreamGroupAsync IMO should create consumer group in the stream, if it does not exist. The name of this method suggest it.

mlatoszek avatar Sep 23 '22 06:09 mlatoszek

@mlatoszek , you are right, we do nothing if a stream was created from one of the consumer groups Thanks for the fix

MahmoudSamir101 avatar Sep 23 '22 12:09 MahmoudSamir101

My pleasure @MahmoudSamir101 :) Btw. do you know when can it be merged and the fix released with new nugets? I need it in order to use CAP in our project. I can create nugets myself and release it to our private repo but would be great to use official ones ;)

mlatoszek avatar Sep 23 '22 13:09 mlatoszek

Hi @MahmoudSamir101 , You can review and merge this PR directly, and I will push the 6.2.1 preview verion to nuget

yang-xiaodong avatar Sep 23 '22 13:09 yang-xiaodong

@yang-xiaodong should I keep the version.props changes or you will manage the version number

MahmoudSamir101 avatar Sep 23 '22 14:09 MahmoudSamir101

should I keep the version.props changes

Yes, that's exactly our next version number

yang-xiaodong avatar Sep 23 '22 14:09 yang-xiaodong

Fixed in version 6.2.1-preview-180716003 and pushed to nuget in a few minutes ago.

yang-xiaodong avatar Sep 23 '22 15:09 yang-xiaodong