Building a Common Message Solution with MongoDB at Vertafore
-
Upload
mongodb -
Category
Technology
-
view
243 -
download
0
description
Transcript of Building a Common Message Solution with MongoDB at Vertafore
© 2014 Vertafore, Inc. and its subsidiaries.1
Building a Common Notification Solution with MongoDBJohn Gao | September 16, 2014
Steven Engelhart
© 2014 Vertafore, Inc. and its subsidiaries.2
Agenda
1 About Vertafore
2 Problem Statement
3 Design and Implementation
4 Product Demo
© 2014 Vertafore, Inc. and its subsidiaries.3
The Company
13,000,000 Producer Lifecycle Mgmt transactions
20,0000 customers use Vertafore
1,000 agencies adopted AMS360 in 2012
96 of the top 100 agencies use Vertafore
80 of the top 100 carriers use Vertafore
44 years transforming insurance
#1 software supplier to independent insurance
50,000,000 real-time transactions
© 2014 Vertafore, Inc. and its subsidiaries.4
Vertafore Solution Suite
Connectivity
4© 2013 Vertafore, Inc. and its subsidiaries.
Agency Carrier MGA/WholesalerContent and BusinessProcess Management
Content and BusinessProcess Management
Business IntelligenceBusiness Intelligence
Agency Management,Download and Real-timeDownload and Real-time
Policy IssuancePolicy Issuance
Producer LifecycleManagement
Producer LifecycleManagement
Producer LifecycleManagement
Comparative Rating Rating ManagementRating Interfaces
Reference Libraries Reference LibrariesReference Libraries
Producer Tools Producer ToolsProducer Tools
Content and BusinessProcess Management
Business Intelligence
Agency Management,Download and Real-time
Benefits Management
Connectivity
© 2014 Vertafore, Inc. and its subsidiaries.5
Breaking the Mold
• Need solutions to be re-usable
• Breaking the traditional SQL solution development pattern
• Freedom to choose the right technology to solve the problem
© 2014 Vertafore, Inc. and its subsidiaries.6
Design Goals
• Simple and Easy to User API
• Performance and Scalability
• Need to support both pull and push
© 2014 Vertafore, Inc. and its subsidiaries.7
Design Decisions
• “RESTful” web service using OData
• MongoDB for database
• RabbitMQ for queue to support mobile push
© 2014 Vertafore, Inc. and its subsidiaries.8
Why MongoDB?
• Performance and scalability
• No object to relational model translation
• Object model can be very flexible
• Supports all major platforms
• Excellent .NET and LINQ support
© 2014 Vertafore, Inc. and its subsidiaries.9
Overall Architecture
© 2014 Vertafore, Inc. and its subsidiaries.10
Object Model – NotificationMessage
• Type – admin, user, …• Priority – normal, critical, …• Author• Publisher• Recipient…
© 2014 Vertafore, Inc. and its subsidiaries.11
Object Model – UML Diagram
© 2014 Vertafore, Inc. and its subsidiaries.12
MongoDB Document – NotificationMessage
© 2014 Vertafore, Inc. and its subsidiaries.13
Message Service – Layered Diagram
© 2014 Vertafore, Inc. and its subsidiaries.14
public class NotificationMessagesController : ODataController { public IQueryable<NotificationMessage> Get(ODataQueryOptions<NotificationMessage> query); public async Task<NotificationMessage> Get([FromODataUri] string key); public async Task<IHttpActionResult> Post([FromBody] NotificationMessage message); public async Task<IHttpActionResult> Put([FromODataUri] string key, NotificationMessage entity); public async Task<IHttpActionResult> Patch([FromODataUri] string key, Delta<NotificationMessage> patch); }
Odata Layer - Controller
© 2014 Vertafore, Inc. and its subsidiaries.15
Domain Layer – Domain Services
© 2014 Vertafore, Inc. and its subsidiaries.16
public interface IRepository<T, U> { T Get(Expression<Func<T, U>> keyExpression, U key); IQueryable<T> Get();
T Create(T entity); T Update(T entity); bool Delete(T entity); }
Data Layer - Interface
© 2014 Vertafore, Inc. and its subsidiaries.17
public MongoRepository(MongoDatabase database, string collection) { Collection = database.GetCollection<T>(collection); } public T Get(Expression<Func<T, U>> exp, U key) { return Collection.FindOne(Query<T>.EQ(exp, key)); }
public IQueryable<T> Get() { return Collection.AsQueryable(); }
Data Layer - Implementation
© 2014 Vertafore, Inc. and its subsidiaries.18
private void InitializeStructureMap(IQueryRules rules) {DomainStructureMap.Map(container, (ConfigurationSection)ConfigurationManager.GetSection("NotificationCreatedEventQueue")); DataStructureMap.Map(container, ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString); });}
How Are The Three Layers Linked?
© 2014 Vertafore, Inc. and its subsidiaries.19
public static void Map(IRegistry container, ConfigurationSection notificationConfigurationSection) {container.For<IEntityEventProcessor>() .HybridHttpOrThreadLocalScoped() .Use<EntityEventProcessor>();
container.For<IDomainService<NotificationMessage, string>>() .HybridHttpOrThreadLocalScoped() .Use<NotificationMessageService>();}
Structure Map – Domain
© 2014 Vertafore, Inc. and its subsidiaries.20
public static void Map(IRegistry container, string dataConnection) { RegisterMappings(); container.For<IRepository<NotificationMessage, string>>() .HybridHttpOrThreadLocalScoped() .Use(r => new MongoRepository<NotificationMessage, string>(r.GetInstance<MongoDatabase>(), "Messages"));
container.For<IRepository<MessageHistory, string>>() .HybridHttpOrThreadLocalScoped() .Use(r => new MongoRepository<MessageHistory, string>(r.GetInstance<MongoDatabase>(), "MessageHistory")); }
Structure Map – Data
© 2014 Vertafore, Inc. and its subsidiaries.21
BsonClassMap.RegisterClassMap<NotificationMessage>(map => { map.AutoMap(); map.SetDiscriminator("NotificationMessage"); map.IdMemberMap.SetIdGenerator (StringObjectIdGenerator.Instance); });
BsonClassMap.RegisterClassMap<UserRecipient>(map => {
map.AutoMap(); map.SetDiscriminator("MessageRecipient_User");
}); // Other mappings omitted for clarity
Bson Class Map
© 2014 Vertafore, Inc. and its subsidiaries.22
MongoDB Replica Set
© 2014 Vertafore, Inc. and its subsidiaries.23
NotificationMessages.OrderByDescending (nm => nm.CreatedAt).Skip(100).Take(50);
NotificationMessages.Where(n => n.Id == "54132e3bf11fbc138c8f7448");NotificationMessages.Where (nm =>
nm.UserRecipients.Any(ur => ur.UserId == "35630")).OrderByDescending (nm => nm.CreatedAt).Take(10);
NotificationMessages.Where(x => x.Summary.Contains("New opportunity")).Take(10);
Usage Examples – Linq Queries
© 2014 Vertafore, Inc. and its subsidiaries.24
https://ServiceEndpoint/NotificationMessages()?$orderby=CreatedAt desc&$skip=100&$top=50
https://ServiceEndpoint/NotificationMessages('54132e3bf11fbc138c8f7448')
https://ServiceEndpoint/NotificationMessages()?$filter=UserRecipients/any(ur:ur/UserId eq '35630')&$orderby=CreatedAt desc&$top=10
https://ServiceEndpoint/NotificationMessages()?$filter=substringof('New opportunity',Summary)&$top=10
Usage Examples – Odata Queries
© 2014 Vertafore, Inc. and its subsidiaries.25
"op" : "query",
"ns" : "NotificationService.Messages",
"query" : {
"$query" : {
"UserRecipients" : {
"$elemMatch" : {
"UserId" : "35630"
}
} },
"$orderby" : {
"CreatedAt" : -1 }
},
Usage Examples – MongoDB Queries
© 2014 Vertafore, Inc. and its subsidiaries.26
Mobile Push Service
• Mobile device registration service– Register mobile device– Odata web service– Registration stored in MongoDB
• Windows service – Monitor queue message– Send message that has mobile destination to
Apple or Google for actual delivery
© 2014 Vertafore, Inc. and its subsidiaries.27
{ "_id" : "54174aad92d00721d4ef7315", "DeviceType" : "Android", "Token" : "<Device token goes here>", "AppId" : "SeattleDemo", "VssoId" : "35689", "VendorId" : "PipelineManager - Agent", "CreatedDt" : ISODate("2014-09-15T20:23:08.747Z"), "ModifiedDt" : ISODate("2014-09-15T20:23:08.747Z"), "DeviceData" : { "Data" : null }}
Device Registration – MongoDB Document
© 2014 Vertafore, Inc. and its subsidiaries.28
Mobile Push Service - Workflow
© 2014 Vertafore, Inc. and its subsidiaries.29
Overall Dev Experience
• What we liked– Very easy to setup– Great documentation and online resources– Great community support– No more mismatch of object to relational– Quick development cycle– Flexible schema works well
© 2014 Vertafore, Inc. and its subsidiaries.30
Overall Dev Experience
• Things that could have been better– 2.6 release felt to be rushed out. – No out of box encryption support– No MongoDB Management Service (MMS) on
windows
© 2014 Vertafore, Inc. and its subsidiaries.31
Operations Experience
• Hosting team was able to ramp up quickly
• Simple installation
• Quick and intuitive deployment of packages
• Easy to scale out
© 2014 Vertafore, Inc. and its subsidiaries.32
Push Notification Demo
© 2014 Vertafore, Inc. and its subsidiaries.33
Questions
© 2014 Vertafore, Inc. and its subsidiaries.34