本文整理汇总了C#中MessagingFactory.CreateEventHubClient方法的典型用法代码示例。如果您正苦于以下问题:C# MessagingFactory.CreateEventHubClient方法的具体用法?C# MessagingFactory.CreateEventHubClient怎么用?C# MessagingFactory.CreateEventHubClient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessagingFactory
的用法示例。
在下文中一共展示了MessagingFactory.CreateEventHubClient方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenAsync
public async Task<string> OpenAsync(CancellationToken cancellationToken)
{
var builder = new ServiceBusConnectionStringBuilder(_connectionString)
{
TransportType = TransportType.Amqp
};
_messagingFactory = MessagingFactory.CreateFromConnectionString(builder.ToString());
_eventHubClient = _messagingFactory.CreateEventHubClient(_eventHubName);
_consumerGroup = !string.IsNullOrEmpty(_consumerGroupName)
? _eventHubClient.GetConsumerGroup(_consumerGroupName)
: _eventHubClient.GetDefaultConsumerGroup();
_eventProcessorFactory = new EventProcessorFactory();
_leaseRepository = new ReliableStateLeaseRepository(_reliableStateManager);
_checkpointManager = new CheckpointManager(_leaseRepository);
var allocatedPartitions = await new EventHubPartitionPartitionAllocationStrategy(_serviceName, _partitionId)
.AllocateAsync(_eventHubClient, new FabricClient());
foreach (var partition in allocatedPartitions)
{
var lease = await _leaseRepository.GetOrCreateAsync(_connectionString, _consumerGroupName, _eventHubName, partition);
await _consumerGroup.RegisterProcessorFactoryAsync(lease, _checkpointManager, _eventProcessorFactory);
}
return string.Concat(_eventHubName, " @ ", _connectionString);
}
示例2: EventSender
public EventSender(
MessagingFactory messagingFactory,
SimulatorConfiguration config,
Func<object, byte[]> serializer)
{
this._serializer = serializer;
this._eventHubClient = messagingFactory.CreateEventHubClient(config.EventHubPath);
}
示例3: MessageSender
public MessageSender(
MessagingFactory messagingFactory,
SimulatorConfiguration config,
Func<object, byte[]> serializer,
ISenderInstrumentationPublisher telemetryPublisher)
{
this._serializer = serializer;
this._instrumentationTelemetryPublisher = telemetryPublisher;
this._eventHubClient = messagingFactory.CreateEventHubClient(config.EventHubPath);
}
示例4: OpenEventHubAsync
public Task OpenEventHubAsync(string eventHubConnectionString, string hubName)
{
return Task.Factory.StartNew(async () => {
if (string.IsNullOrWhiteSpace(eventHubConnectionString))
throw new ArgumentException("invalid event hub connection string");
if (string.IsNullOrWhiteSpace(hubName))
throw new ArgumentException("invalid hubname");
this.IsOpen = true;
var builder = new ServiceBusConnectionStringBuilder(eventHubConnectionString) { TransportType = TransportType.Amqp };
var s = builder.ToString();
_factory = MessagingFactory.CreateFromConnectionString(builder.ToString());
_client = _factory.CreateEventHubClient(hubName);
var runtimeInfo = await _client.GetRuntimeInformationAsync();
_partitions.Clear();
foreach (var p in runtimeInfo.PartitionIds)
{
var partition = await _client.GetPartitionRuntimeInformationAsync(p);
var count = partition.LastEnqueuedSequenceNumber - partition.BeginSequenceNumber;
if (count != 0)
count++;
this.MessageCount = count;
_partitions.Add(new Partition(p, _messages));
_foundPartitions.OnNext(partition);
}
_foundPartitions.OnCompleted();
});
}
示例5: OpenAsync
public async Task<string> OpenAsync(CancellationToken cancellationToken)
{
await mOptions.PrepareAsync();
var useDefaultConsumerGroup = !string.IsNullOrEmpty(mOptions.EventHubConsumerGroupName);
mMessagingFactory = MessagingFactory.CreateFromConnectionString(mOptions.EventHubConnectionString);
mEventHubClient = mMessagingFactory.CreateEventHubClient(mOptions.EventHubName);
mConsumerGroup = useDefaultConsumerGroup ?
mEventHubClient.GetConsumerGroup(mOptions.EventHubConsumerGroupName)
: mEventHubClient.GetDefaultConsumerGroup();
return string.Concat(mEventHubNamespace, "/",
mOptions.EventHubName, "/",
useDefaultConsumerGroup ? "<default group>" : mOptions.EventHubConsumerGroupName);
}