public async Task SMS_Limits_FindMax_Producers() { // 1 Stream, X Producers, 1 Consumer Guid streamId = Guid.NewGuid(); string streamProviderName = SmsStreamProviderName; output.WriteLine("Starting search for MaxProducersPerStream value using stream {0}", streamId); IStreamLifecycleConsumerGrain consumer = this.GrainFactory.GetGrain <IStreamLifecycleConsumerGrain>(Guid.NewGuid()); await consumer.BecomeConsumer(streamId, this.StreamNamespace, streamProviderName); int loopCount = 0; try { // Loop until something breaks! for (loopCount = 1; loopCount <= MaxExpectedPerStream; loopCount++) { IStreamLifecycleProducerGrain producer = this.GrainFactory.GetGrain <IStreamLifecycleProducerGrain>(Guid.NewGuid()); await producer.BecomeProducer(streamId, this.StreamNamespace, streamProviderName); } } catch (Exception exc) { this.output.WriteLine("Stopping loop at loopCount={0} due to exception {1}", loopCount, exc); } MaxProducersPerStream = loopCount - 1; output.WriteLine("Finished search for MaxProducersPerStream with value {0}", MaxProducersPerStream); Assert.NotEqual(0, MaxProducersPerStream); // "MaxProducersPerStream should be greater than zero." output.WriteLine("MaxProducersPerStream={0}", MaxProducersPerStream); }
private async Task Test_PubSub_Stream(string streamProviderName, Guid streamId) { // Consumer IStreamLifecycleConsumerGrain consumer = this.GrainFactory.GetGrain <IStreamLifecycleConsumerGrain>(Guid.NewGuid()); await consumer.BecomeConsumer(streamId, this.StreamNamespace, streamProviderName); // Producer IStreamLifecycleProducerGrain producer = this.GrainFactory.GetGrain <IStreamLifecycleProducerGrain>(Guid.NewGuid()); await producer.BecomeProducer(StreamId, this.StreamNamespace, streamProviderName); await producer.SendItem(1); int received1 = await consumer.GetReceivedCount(); Assert.True(received1 > 1, $"Received count for consumer {consumer} is too low = {received1}"); // Unsubscribe await consumer.ClearGrain(); // Send one more message await producer.SendItem(2); int received2 = await consumer.GetReceivedCount(); Assert.Equal(0, received2); // $"Received count for consumer {consumer} is wrong = {received2}" }
public async Task SMS_Limits_FindMax_Consumers() { // 1 Stream, 1 Producer, X Consumers Guid streamId = Guid.NewGuid(); string streamProviderName = StreamTestsConstants.SMS_STREAM_PROVIDER_NAME; Console.WriteLine("Starting search for MaxConsumersPerStream value using stream {0}", streamId); IStreamLifecycleProducerGrain producer = GrainClient.GrainFactory.GetGrain <IStreamLifecycleProducerGrain>(Guid.NewGuid()); await producer.BecomeProducer(streamId, this.StreamNamespace, streamProviderName); int loopCount = 0; try { // Loop until something breaks! for (loopCount = 1; loopCount <= MaxExpectedPerStream; loopCount++) { IStreamLifecycleConsumerGrain consumer = GrainClient.GrainFactory.GetGrain <IStreamLifecycleConsumerGrain>(Guid.NewGuid()); await consumer.BecomeConsumer(streamId, this.StreamNamespace, streamProviderName); } } catch (Exception exc) { Console.WriteLine("Stopping loop at loopCount={0} due to exception {1}", loopCount, exc); } MaxConsumersPerStream = loopCount - 1; Console.WriteLine("Finished search for MaxConsumersPerStream with value {0}", MaxConsumersPerStream); Assert.AreNotEqual(0, MaxConsumersPerStream, "MaxConsumersPerStream should be greater than zero."); Console.WriteLine("MaxConsumersPerStream={0}", MaxConsumersPerStream); }
public static Task RemoveConsumer(this IStreamLifecycleConsumerGrain grain, Guid streamIdGuid, string streamNamespace, string providerName, StreamSubscriptionHandle <int> consumerHandle) { var streamId = StreamId.Create(streamNamespace, streamIdGuid); return(grain.RemoveConsumer(streamId, providerName, consumerHandle)); }
public static Task TestBecomeConsumerSlim(this IStreamLifecycleConsumerGrain grain, Guid streamIdGuid, string streamNamespace, string providerName) { var streamId = StreamId.Create(streamNamespace, streamIdGuid); return(grain.TestBecomeConsumerSlim(streamId, providerName)); }