/// <summary>
        /// Configures manual subscription
        /// </summary>
        /// <param name="subscription"></param>
        protected void ConfigureManualSubscription(IManualSubscription subscription)
        {
            switch (subscription)
            {
            case Assignment assignment:
                ConsumerActor.Tell(new KafkaConsumerActorMetadata.Internal.Assign(assignment.TopicPartitions), SourceActor.Ref);
                TopicPartitions = TopicPartitions.Union(assignment.TopicPartitions);
                break;

            case AssignmentWithOffset assignmentWithOffset:
                ConsumerActor.Tell(new KafkaConsumerActorMetadata.Internal.AssignWithOffset(assignmentWithOffset.TopicPartitions), SourceActor.Ref);
                TopicPartitions = TopicPartitions.Union(assignmentWithOffset.TopicPartitions.Select(tp => tp.TopicPartition));
                break;
            }
        }
예제 #2
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (consumerActor_ != null)
            {
                hash ^= ConsumerActor.GetHashCode();
            }
            if (Type.Length != 0)
            {
                hash ^= Type.GetHashCode();
            }
            if (Topic.Length != 0)
            {
                hash ^= Topic.GetHashCode();
            }
            return(hash);
        }
        /// <inheritdoc />
        protected override void ConfigureSubscription()
        {
            switch (_subscription)
            {
            case TopicSubscription topicSubscription:
                ConsumerActor.Tell(new KafkaConsumerActorMetadata.Internal.Subscribe(topicSubscription.Topics), SourceActor.Ref);
                break;

            case TopicSubscriptionPattern topicSubscriptionPattern:
                ConsumerActor.Tell(new KafkaConsumerActorMetadata.Internal.SubscribePattern(topicSubscriptionPattern.TopicPattern), SourceActor.Ref);
                break;

            case IManualSubscription manualSubscription:
                ConfigureManualSubscription(manualSubscription);
                break;

            default:
                throw new NotSupportedException();
            }
        }
예제 #4
0
 public void MergeFrom(Subscribe other)
 {
     if (other == null)
     {
         return;
     }
     if (other.consumerActor_ != null)
     {
         if (consumerActor_ == null)
         {
             consumerActor_ = new global::Proto.PID();
         }
         ConsumerActor.MergeFrom(other.ConsumerActor);
     }
     if (other.Type.Length != 0)
     {
         Type = other.Type;
     }
     if (other.Topic.Length != 0)
     {
         Topic = other.Topic;
     }
 }
        public override void PostStop()
        {
            ConsumerActor.Tell(KafkaConsumerActorMetadata.Internal.Stop.Instance, SourceActor.Ref);

            base.PostStop();
        }