public async Task<AtomDocument> GetHeadDocument(SubscriptionId subscriptionId)
 {
     _adapter.Info($"requesting head document for id {subscriptionId.Id}");
     var documentId = await burstManager.SubscriptionActorRef.Ask<DocumentId>(new GetHeadDocumentIdForFeedRequest(subscriptionId));
     var document = await _documentRepository.GetDocument(documentId);
     return document;
 }
示例#2
0
        public static void Main(string[] args)
        {
            var akkaSystemName = GetValueFromCommandLine("akkaSystemName", args);
            var seedNodes = GetValueFromCommandLine("seedNodes", args);
            var akkaPortNumber = GetIntFromCommandLine(args, "portNumber");
            var entriesPerDocument = GetIntFromCommandLine(args, "entriesPerDocument");
            var persistence = GetValueFromCommandLine("persistence", args);

            var eventSystemHost = new BurstingEventSystemHost(akkaPortNumber, akkaSystemName, persistence, seedNodes, 3601, entriesPerDocument);
            var EventRaisingController = eventSystemHost.Get<EventRaisingController>();
            eventSystemHost.Start();

            Console.Title = string.Join(" ", args);
            Thread.Sleep(TimeSpan.FromSeconds(5));

            var subscriptionId = new SubscriptionId(GetValueFromCommandLine("subscriptionId", args));

            if (!string.IsNullOrEmpty(subscriptionId.Id))
            {
                Console.WriteLine("Getting subscriptionId");
                ISubscriptionManager shardedSubscriptionManager = eventSystemHost.Get<ISubscriptionManager>();
                
                var currentSubscription =
                    shardedSubscriptionManager.GetSubscriptionDetails(new SubscriptionQuery(subscriptionId)).Result;

                if (currentSubscription is NullSubscription)
                {
                    _subscriptionMessage = new SubscriptionMessage(
                        new AtomNotificationChannel(),
                        subscriptionId,
                        new AllEventMatcher());

                    shardedSubscriptionManager.CreateSubscription(_subscriptionMessage);
                    Thread.Sleep(1000);

                }

                Thread.Sleep(1000);

                IEventPublisher notifier = eventSystemHost.Get<IEventPublisher>();

                var i = 0;
                while (true)
                {
                    notifier.PublishMessage(new DummyDomainEvent(akkaPortNumber + ":" + (++i).ToString()));
                    LogManager.GetLogger("").Info("Raising event with id" + i);
                }
            }

            while (true)
            {
                Thread.Sleep(TimeSpan.FromSeconds(5));
            }
        }
        public Task<string> GetSerialisedHeadDocument(SubscriptionId documentId)
        {
            logger.Info("LoggingAtomDocumentRetrieverDecorator.GetSerialisedHeadDocument " + documentId.Id);

            try
            {
                return decoratedRetriever.GetSerialisedHeadDocument(documentId);
            }
            catch (System.Exception e)
            {
                logger.Error(e.ToString());
                throw;
            }
        }
        public Task<DocumentId> GetHeadDocumentId(SubscriptionId subscriptionId)
        {
            logger.Info("LoggingAtomDocumentRetrieverDecorator.GetHeadDocumentId " + subscriptionId.Id);

            try
            {
                return decoratedRetriever.GetHeadDocumentId(subscriptionId);
            }
            catch (System.Exception e)
            {
                logger.Error(e.ToString());
                throw;
            }
        }
        public async Task<AtomDocument> GetHeadDocument(SubscriptionId subscriptionId)
        {
            logger.Info("LoggingAtomDocumentRetrieverDecorator.GetHeadDocument " + subscriptionId.Id);
            try
            {
                var document = await decoratedRetriever.GetHeadDocument(subscriptionId);
                logger.Info($"LoggingAtomDocumentRetrieverDecorator.GetHeadDocument: Returning id {document.DocumentId.Id} with {document.Entries.Count} events in");

                logger.Info(new AtomDocumentSerialiser().Serialise(document, "http://localhost:3600/events/atom/document/"));

                return document;
            }
            catch (System.Exception e)
            {
                logger.Error(e.ToString());
                throw;
            }
        }
 public GetHeadDocumentForFeedRequest(SubscriptionId subscriptionId)
 {
     this.SubscriptionId = subscriptionId;
 }
 public SubscriptionMessage(INotificationChannel notificationChannel, SubscriptionId subscriptionId, IEventMatcher eventMatcher)
 {
     NotificationChannel = notificationChannel;
     SubscriptionId = subscriptionId;
     EventMatcher = eventMatcher;
 }
 public SubscriptionMessage(INotificationChannel notificationChannel, SubscriptionId subscriptionId, IEventMatcher eventMatcher)
 {
     NotificationChannel = notificationChannel;
     SubscriptionId      = subscriptionId;
     EventMatcher        = eventMatcher;
 }
 public async Task<string> GetSerialisedHeadDocument(SubscriptionId documentId)
 {
     var atomDocument = await GetHeadDocument(documentId);
     return atomDocumentSerialiser.Serialise(atomDocument, "http://matt.com");
 }
 public async Task<AtomDocument> GetHeadDocument(SubscriptionId subscriptionId)
 {
     var documentId = await factory.GetActorRef().Ask<DocumentId>(new GetHeadDocumentIdForFeedRequest(subscriptionId));
     var atomDocument = await shardedAtomDocumentFactory.GetActorRef().Ask<AtomDocument>(new GetAtomDocumentRequest(documentId));
     return atomDocument;
 }
 public async Task<DocumentId> GetHeadDocumentId(SubscriptionId subscriptionId)
 {
     var documentId = await factory.GetActorRef().Ask<DocumentId>(new GetHeadDocumentIdForFeedRequest(subscriptionId));
     return documentId;
 }
 public EventWithSubscriptionNotificationMessage(SubscriptionId subscriptionId, DomainEvent eventToNotify)
 {
     SubscriptionId = subscriptionId;
     EventToNotify = eventToNotify;
 }
 public async Task<string> GetSerialisedHeadDocument(SubscriptionId documentId)
 {
     var atomDocument = await GetHeadDocument(documentId);
     return atomDocumentSerialiser.Serialise(atomDocument, "http://localhost:3600/events/atom/document/");
 }
 public GetDocumentFromFeedRequest(SubscriptionId subscriptionId, DocumentId documentId)
 {
     SubscriptionId = subscriptionId;
     DocumentId = documentId;
 }
 public Task<DocumentId> GetHeadDocumentId(SubscriptionId subscriptionId)
 {
     throw new System.NotImplementedException();
 }
 public Task<string> GetSerialisedHeadDocument(SubscriptionId documentId)
 {
     throw new System.NotImplementedException();
 }
 public async Task<HttpResponseMessage> GetFeed([FromUri] string subscriptionId)
 {
     var subscription = new SubscriptionId(subscriptionId);
     AtomDocument document = await atomDocumentRetriever.GetHeadDocument(subscription);
     return SerialiseDocumentToResonse(document);
 }