问题描述
我在异步回调中有非常简单的代码,该代码在每次调用时创建,发送消息,然后处置EventHubProducerClient。对于每个唯一的事件中心实例,将EventHubProducerClient创建为单例是否有好处?
var ConnectionString = "Endpoint=sb://{EventHub Namespace}.servicebus.windows.net/;SharedAccessKeyName={KeyName};SharedAccessKey={Key};EntityPath={EventHub Instance}"
await using (var producerClient = new EventHubProducerClient(ConnectionString))
{
var batch = await producerClient.CreateBatchAsync();
batch.TryAdd(new EventData(Encoding.UTF8.GetBytes("test message")));
await producerClient.SendAsync(batch);
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)