/// <summary> /// Construct an instance. /// </summary> /// <param name="cancellationToken">CancellationToken that the event processor should respect. Same as token passed to IEventProcessor methods.</param> /// <param name="partitionId">Id of the partition for which the event processor is handling events.</param> /// <param name="eventHubPath">Name of the event hub which is the source of events.</param> /// <param name="consumerGroupName">Name of the consumer group on the event hub.</param> /// <param name="checkpointMananger">The checkpoint manager instance to use.</param> public PartitionContext(CancellationToken cancellationToken, string partitionId, string eventHubPath, string consumerGroupName, ICheckpointMananger checkpointMananger) { this.CancellationToken = cancellationToken; this.PartitionId = partitionId; this.EventHubPath = eventHubPath; this.ConsumerGroupName = consumerGroupName; this.RuntimeInformation = new ReceiverRuntimeInformation(this.PartitionId); this.checkpointMananger = checkpointMananger; }
/// <summary> /// Constructor. Arguments break down into three groups: (1) Service Fabric objects so this library can access /// Service Fabric facilities, (2) Event Hub-related arguments which indicate what event hub to receive from and /// how to process the events, and (3) advanced, which right now consists only of the ability to replace the default /// reliable dictionary-based checkpoint manager with a user-provided implementation. /// </summary> /// <param name="serviceFabricServiceName">Service Fabric Uri found in StatefulServiceContext</param> /// <param name="serviceFabricPartitionId">Service Fabric partition id found in StatefulServiceContext</param> /// <param name="stateManager">Service Fabric-provided state manager, provides access to reliable dictionaries</param> /// <param name="partition">Service Fabric-provided partition information</param> /// <param name="userEventProcessor">User's event processor implementation</param> /// <param name="eventHubConnectionString">Connection string for user's event hub</param> /// <param name="eventHubConsumerGroup">Name of event hub consumer group to receive from</param> /// <param name="options">Optional: Options structure for ServiceFabricProcessor library</param> /// <param name="checkpointManager">Very advanced/optional: user-provided checkpoint manager implementation</param> public ServiceFabricProcessor(Uri serviceFabricServiceName, Guid serviceFabricPartitionId, IReliableStateManager stateManager, IStatefulServicePartition partition, IEventProcessor userEventProcessor, string eventHubConnectionString, string eventHubConsumerGroup, EventProcessorOptions options = null, ICheckpointMananger checkpointManager = null) { if (serviceFabricServiceName == null) { throw new ArgumentNullException("serviceFabricServiceName is null"); } if (serviceFabricPartitionId == null) { throw new ArgumentNullException("serviceFabricPartitionId is null"); } if (stateManager == null) { throw new ArgumentNullException("stateManager is null"); } if (partition == null) { throw new ArgumentNullException("partition is null"); } if (userEventProcessor == null) { throw new ArgumentNullException("userEventProcessor is null"); } if (string.IsNullOrEmpty(eventHubConnectionString)) { throw new ArgumentException("eventHubConnectionString is null or empty"); } if (string.IsNullOrEmpty(eventHubConsumerGroup)) { throw new ArgumentException("eventHubConsumerGroup is null or empty"); } this.serviceFabricServiceName = serviceFabricServiceName; this.serviceFabricPartitionId = serviceFabricPartitionId; this.serviceStateManager = stateManager; this.servicePartition = partition; this.userEventProcessor = userEventProcessor; this.ehConnectionString = new EventHubsConnectionStringBuilder(eventHubConnectionString); this.consumerGroupName = eventHubConsumerGroup; this.options = options ?? new EventProcessorOptions(); this.checkpointManager = checkpointManager ?? new ReliableDictionaryCheckpointMananger(this.serviceStateManager); this.EventHubClientFactory = new EventHubWrappers.EventHubClientFactory(); this.TestMode = false; this.MockMode = null; }