Exemplo n.º 1
0
        public void ToQueueMessage_TestMethod()
        {
            string expected = "|Bank|Account|A-123456-BB|Balance|null|";
            string actual   = "";

            ProjectionRequested testObj = new ProjectionRequested()
            {
                ProjectionDomainName     = "Bank",
                ProjectionEntityTypeName = "Account",
                ProjectionInstanceKey    = "A-123456-BB",
                ProjectionTypeName       = "Balance"
            };

            actual = ProjectionRequested.ToQueueMessage(testObj);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 2
0
        public async Task NewEventAppended(IEventStreamIdentity targetEntity,
                                           string eventType,
                                           int sequenceNumber,
                                           string commentary     = "",
                                           object eventPayload   = null,
                                           IWriteContext context = null)
        {
            string messageToSend = MakeMessageString(targetEntity,
                                                     NOTIFICATION_NEW_EVENT,
                                                     eventType,
                                                     sequenceNumber);

            string queueName = string.Empty;

            // special case - if it is a Command or Query requesting a Classification or Projection..
            if (eventType == EventNameAttribute.GetEventName(typeof(ProjectionRequested)))
            {
                // Is it a command or query...
                if (targetEntity.DomainName.Contains("Command"))
                {
                    queueName = QUEUE_COMMAND_PROJECTIONS;
                }
                if (targetEntity.DomainName.Contains("Query"))
                {
                    queueName = QUEUE_QUERY_PROJECTIONS;
                }
                // Add the extra details to the message text to indicate what projection was requested
                ProjectionRequested evtPayload = eventPayload as ProjectionRequested;
                if (evtPayload != null)
                {
                    messageToSend += ProjectionRequested.ToQueueMessage(evtPayload);
                }
            }
            else
            {
                if (eventType == EventNameAttribute.GetEventName(typeof(ClassifierRequested)))
                {
                    // Is it a command or query...
                    if (targetEntity.DomainName.Contains("Command"))
                    {
                        queueName = QUEUE_COMMAND_CLASSIFICATIONS;
                    }
                    if (targetEntity.DomainName.Contains("Query"))
                    {
                        queueName = QUEUE_QUERY_CLASSIFICATIONS;
                    }
                    // Add the extra details to the message text to indicate what classification was requested
                    ClassifierRequested evtPayload = eventPayload as ClassifierRequested;
                    if (evtPayload != null)
                    {
                        messageToSend += $"|{evtPayload.DomainName}|{evtPayload.EntityTypeName}|{evtPayload.InstanceKey}|{evtPayload.ClassifierTypeName}|{evtPayload.AsOfDate}|{evtPayload.CorrelationIdentifier}";
                    }
                }
                else
                {
                    queueName = MakeQueueName(targetEntity);
                }
            }

            string connectionStringName = _eventStreamSettings.GetConnectionStringName(targetEntity);

            if (!string.IsNullOrWhiteSpace(queueName))
            {
                await SendQueueMessage(connectionStringName, queueName, messageToSend);
            }
        }