linzhiqiang / Aix.FoundatioEx

Foundatio的相关扩展 messagebus的kafka实现
3 stars 1 forks source link

Latest 'Aix.FoundatioMessagingEx.Kafka, Version=1.0.13.0' nuget issue to subscribe multiple Topic. #3

Open jojopeter opened 3 years ago

jojopeter commented 3 years ago

Earlier we used to reference the nuget 'Aix.FoundatioEx.Kafka, Version=1.0.6.0' which having the properties 'public TopicMode TopicMode { get; set; } and public ClientMode ClientMode { get; set; }' which handling to subscribe multiple topic. but currently we just upgraded to 'Aix.KafkaMessageBus, Version=1.0.13.0' is under the nuget package 'Aix.FoundatioMessagingEx.Kafka' where those properties are not available.

Can you please let me know if we have any substitute to resolve this issue? Or else can you please include this two as well as part of this latest package?

linzhiqiang commented 3 years ago

Do not configure topic properties In the configuration file,This property is compatible with older versions of a single topic. Please use a new way, Use TopicAttribute on the Message Object, as follows demo: [TopicAttribute(Name = "my_topic_name")] public class BusinessMessage{ }

linzhiqiang commented 3 years ago

public static string GetTopic(KafkaMessageBusOptions options, Type type) { string topicName = null;

//do not configure topic properties,This property is compatible with older versions of a single topic. if (!string.IsNullOrEmpty(options.Topic)) { topicName = options.Topic; } else { topicName = type.Name; //默认等于该类型的名称 var topicAttr = TopicAttribute.GetTopicAttribute(type); if (topicAttr != null && !string.IsNullOrEmpty(topicAttr.Name)) { topicName = topicAttr.Name; } topicName = $"{options.TopicPrefix ?? ""}{topicName}"; } return topicName; }

MatheswaranSagadevan commented 3 years ago

Hi linzhiqiang, we still get the "unknown topic/partition" exception even after using the TopicAttribute. We used the sample example you provided and added 5 producer and 5 consumer threads. every time we are facing this "Unknown Topic exception" for one of the 5 thread.

Also after googling and downgraded the confluent.kafka package to 1.4.4 in your example, and after the same code works fine without the exception. so if you could accept, then kindly provide us the new version of your nuget where kafka is downgraded. we may consider this as interim solution.

Later you could help us resolving this permanently if possible.

linzhiqiang commented 3 years ago

please "Install-Package Aix.FoundatioMessagingEx.Kafka -Version 1.0.144" please check kafka config "auto.create.topics.enable"

linzhiqiang commented 3 years ago

It may be a problem with the kafka environment