这里面又是一个简单的模拟,通过创建两个event hubs。然后模拟同时给这两个event hub发流数据。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.ServiceBus;
using Microsoft.ServiceBus.Messaging;
using System.Threading;
namespace ConsoleApplication1
{
class SendMessageToEventHubs
{
private readonly string _connectionString = "Endpoint=*";
private readonly string _connectionString2 = "Endpoint=*";
private readonly string _entityPath;
private readonly string _eventhubNamespaceName;
private EventHubClient client, client2;
public SendMessageToEventHubs()
{
client = GetClient();
client2 = GetClient2();
}
public EventHubClient GetClient()
{
if(client == null)
{
client = EventHubClient.CreateFromConnectionString(_connectionString);
client.RetryPolicy = RetryPolicy.Default;
}
return client;
}
public EventHubClient GetClient2()
{
if (client2 == null)
{
client2 = EventHubClient.CreateFromConnectionString(_connectionString2);
client2.RetryPolicy = RetryPolicy.Default;
}
return client2;
}
public void Cleanup()
{
if(client != null)
{