private static void IndexProspect(object sender, MsgHandlerEventArgs e) { _EventCounter.Labels(_Host, "received").Inc(); Console.WriteLine($"Received message, subject: {e.Message.Subject}"); var eventMessage = MessageHelper.FromData <ProspectSignedUpEvent>(e.Message.Data); Console.WriteLine($"Indexing prospect, signed up at: {eventMessage.SignedUpAt}; event ID: {eventMessage.CorrelationId}"); var prospect = new Documents.Prospect { CompanyName = eventMessage.Prospect.CompanyName, CountryName = eventMessage.Prospect.Country.CountryName, EmailAddress = eventMessage.Prospect.EmailAddress, FullName = $"{eventMessage.Prospect.FirstName} {eventMessage.Prospect.LastName}", RoleName = eventMessage.Prospect.Role.RoleName, SignUpDate = eventMessage.SignedUpAt }; try { Index.CreateDocument(prospect); Console.WriteLine($"Prospect indexed; event ID: {eventMessage.CorrelationId}"); _EventCounter.Labels(_Host, "processed").Inc(); } catch (Exception ex) { Console.WriteLine($"Index prospect FAILED, email address: {prospect.EmailAddress}, ex: {ex}"); _EventCounter.Labels(_Host, "failed").Inc(); } }
private static void IndexProspect(object sender, MsgHandlerEventArgs e) { Console.WriteLine($"Received message, subject: {e.Message.Subject}"); var eventMessage = MessageHelper.FromData <ProspectSignedUpEvent>(e.Message.Data); Console.WriteLine($"Indexing prospect, signed up at: {eventMessage.SignedUpAt}; event ID: {eventMessage.CorrelationId}"); var prospect = new Documents.Prospect { CompanyName = eventMessage.Prospect.CompanyName, CountryName = eventMessage.Prospect.Country.CountryName, EmailAddress = eventMessage.Prospect.EmailAddress, FullName = $"{eventMessage.Prospect.FirstName} {eventMessage.Prospect.LastName}", RoleName = eventMessage.Prospect.Role.RoleName, SignUpDate = eventMessage.SignedUpAt }; Index.CreateDocument(prospect); Console.WriteLine($"Prospect indexed; event ID: {eventMessage.CorrelationId}"); }