Skip to content

Commit

Permalink
#82 (comment): Added a fixed limit to 10 iterations
Browse files Browse the repository at this point in the history
  • Loading branch information
masesdevelopers committed Oct 11, 2023
1 parent a330be0 commit 73ebcba
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/net/KEFCore/Storage/Internal/KafkaCluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,14 @@ public virtual bool EnsureConnected(

public virtual string CreateTable(IEntityType entityType)
{
var topicName = entityType.TopicName(Options);
return CreateTable(entityType, 0);
}

private string CreateTable(IEntityType entityType, int cycle)
{
if (cycle >= 10) throw new System.TimeoutException($"Timeout occurred executing CreateTable on {entityType.Name}");

var topicName = entityType.TopicName(Options);
try
{
try
Expand All @@ -197,7 +203,7 @@ public virtual string CreateTable(IEntityType entityType)
var result = kafkaAdminClient.CreateTopics(coll);
result.All().Get();
}
catch (Java.Util.Concurrent.ExecutionException ex)
catch (ExecutionException ex)
{
throw ex.InnerException;
}
Expand All @@ -207,7 +213,7 @@ public virtual string CreateTable(IEntityType entityType)
if (ex.Message.Contains("deletion"))
{
Thread.Sleep(1000); // wait a while to complete topic deletion and try again
return CreateTable(entityType);
return CreateTable(entityType, cycle++);
}
}
return topicName;
Expand Down

0 comments on commit 73ebcba

Please sign in to comment.