public void ShouldNotDoAnythingWhenTryingToRemoveAPollerThatDoesNotExist() { //arrange var activeQueuePollers = new ActiveQueuePollers(); var key1 = Guid.NewGuid(); var queuePoller = new QueuePoller(key1, new QueueSettings("audit", new ApplicationConfiguration { ApplicationId = "test" })); activeQueuePollers.Add(queuePoller); var key2 = Guid.NewGuid(); var queuePoller2 = new QueuePoller(key2, new QueueSettings("audit", new ApplicationConfiguration { ApplicationId = "test" })); //act activeQueuePollers.Remove(queuePoller2); //assert activeQueuePollers.ActivePollers.Should().BeEquivalentTo(new List <IQueuePoller> { queuePoller }); }
public void ShouldBeAbleToRemoveOneFromListOfMany() { //arrange var activeQueuePollers = new ActiveQueuePollers(); var key1 = Guid.NewGuid(); var queuePoller1 = new QueuePoller(key1, new QueueSettings("audit", new ApplicationConfiguration { ApplicationId = "test" })); var key2 = Guid.NewGuid(); var queuePoller2 = new QueuePoller(key2, new QueueSettings("audit", new ApplicationConfiguration { ApplicationId = "test" })); activeQueuePollers.Add(queuePoller1); activeQueuePollers.Add(queuePoller2); //act activeQueuePollers.Remove(queuePoller1); //assert activeQueuePollers.ActivePollers.Select(p => p.Key).Should().BeEquivalentTo(new List <Guid> { key2 }); }
public SubscriptionService(IResourceCounter resourceCounter, IAmazonSnsFacade amazonSnsFacade, IAmazonSqsFacade amazonSqsFacade, ISubscriberRepository subscriberRespoitroy, QueuePoller queuePoller) { Validate.That(resourceCounter).IsNotNull(); Validate.That(amazonSnsFacade).IsNotNull(); Validate.That(amazonSqsFacade).IsNotNull(); Validate.That(queuePoller).IsNotNull(); Validate.That(subscriberRespoitroy).IsNotNull(); this.resourceCounter = resourceCounter; this.amazonSnsFacade = amazonSnsFacade; this.amazonSqsFacade = amazonSqsFacade; this.subscriberRespoitroy = subscriberRespoitroy; this.queuePoller = queuePoller; }
public SubscriptionService(IResourceCounter resourceCounter, IAmazonSnsFacade amazonSnsFacade, IAmazonSqsFacade amazonSqsFacade, ISubscriberRepository subscriberRespoitroy, QueuePoller queuePoller) { resourceCounter.Requires("resourceCounter").IsNotNull(); amazonSnsFacade.Requires("amazonSnsFacade").IsNotNull(); amazonSqsFacade.Requires("amazonSqsFacade").IsNotNull(); queuePoller.Requires("queuePoller").IsNotNull(); subscriberRespoitroy.Requires("subscriberRespoitroy").IsNotNull(); this.resourceCounter = resourceCounter; this.amazonSnsFacade = amazonSnsFacade; this.amazonSqsFacade = amazonSqsFacade; this.subscriberRespoitroy = subscriberRespoitroy; this.queuePoller = queuePoller; }
static void Main(string[] args) { var queueInformation = new QueueInformation { ConnectionString = @"Endpoint=sb://pinpon-test.servicebus.windows.net/;SharedAccessKeyName=build-consumer;SharedAccessKey=Oa3j00w6XDWfrfNvI6gGYJG6EtQhJyOip2bxtudL674=", Topic = @"build", Subscription = @"pinpon", }; var queuePoller = new QueuePoller(queueInformation); queuePoller.LogError += (o, e) => Console.Error.WriteLine(e); queuePoller.LogVerbose += (o, m) => Console.WriteLine(m); queuePoller.PinponChanged += (o, b) => Console.WriteLine(b); queuePoller.StartPolling(); Console.ReadKey(); }
public void ShouldBeAbleToAdd() { //arrange var activeQueuePollers = new ActiveQueuePollers(); var key1 = Guid.NewGuid(); var queuePoller = new QueuePoller(key1, new QueueSettings("audit", new ApplicationConfiguration { ApplicationId = "test" })); //act activeQueuePollers.Add(queuePoller); //assert activeQueuePollers.ActivePollers.First().Key.Should().Be(key1); }
public void SubscribeTo(QueueInformation queueInformation) { if (pollers.ContainsKey(queueInformation)) { return; } var queuePoller = new QueuePoller(queueInformation); queuePoller.LogError += (o, m) => logger.LogError(m); queuePoller.LogVerbose += (o, m) => logger.LogDebug(m); queuePoller.PinponChanged += QueuePoller_PinponChanged; queuePoller.StartPolling(); logger.LogInformation($"Subscribe to new queue : sub [{queueInformation.Subscription }], Topic [{queueInformation.Topic}]"); pollers.Add(queueInformation, queuePoller); }
private IXDListener CreateNetworkListener(IIdentityProvider provider) { var settings = AmazonAccountSettings.GetInstance(); var amazonSnsFacade = new AmazonSnsFacade(settings); var amazonSqsFacade = new AmazonSqsFacade(settings); var queuePoller = new QueuePoller(amazonSqsFacade); var resourceCounter = new ResourceCounter(); var respository = new TopicRepository(AmazonAccountSettings.GetInstance(), amazonSnsFacade); var subscriberRepository = new SubscriberRepository(settings, amazonSqsFacade); var subscriptionService = new SubscriptionService( resourceCounter, amazonSnsFacade, amazonSqsFacade, subscriberRepository, queuePoller); return(new XDAmazonListener(provider, serializer, respository, subscriberRepository, subscriptionService)); }