Implement Viewing Transactions in Real Time James Payne Managing Director for New Media / Advancement July 27, 2015 Agenda Introductions How it works Technologies How It Works 1/4 Three Processes One process reads transactions from iModules via web services The second process aggregates transaction data and caches the result The third process creates web pages from the cached data How It Works 2/4 One process reads transactions from iModules via web services Requests transaction synopsis data once a minute via iModules web services Receives and parses XML data from iModules Data is saved into (MongoDB) database How It Works 2/4 https://api.imodules.com/ws/21/TransactionsQuery.asmx <soapenv:Header/> <soapenv:Body> <tran:GetTransactionsAllSince> <tran:login>XXXXXX</tran:login> <tran:password>XXXX</tran:password> <tran:startDate>2015-07-17T13:59:30</tran:startDate> <tran:includeFailedTransactions>true</tran:includeFailedTransactions> <tran:includeNonMembers>true</tran:includeNonMembers> <tran:includeUnreviewed>true</tran:includeUnreviewed> <tran:filter></tran:filter> </tran:GetTransactionsAllSince> </soapenv:Body> </soapenv:Envelope> How It Works 3/4 The second process aggregates transaction data and caches the result Once a minute, reads data from MongoDB database for each time interval; five minutes, one hour, one day, one week, one month Calculates totals and other metrics Packages data in the format the web server will expect Caches processed data object into memory using memcached How It Works 4/4 The third process creates web pages from the cached data Web server reads data from cache, MongoDB, or directly from iModules depending on data type Web page is created on the fly Technologies • Required… • iModules Web Services • Tools of choice for OUR implementation… • Java programming language • Linux operating system • Cron scheduler • Memcached in-memory cache • MongoDB database • Tomcat application server • Google Graphs • JQuery Tablesorter What is a web service? - Also known as ‘APIs’ - A building block for ‘Service-Oriented Architecture’ (SOA) - Used to tie systems together - Used to provide access by a provider to services or data to a consumer other than a browser… But sometimes to a browser (AJAX) Documentation - iModules has very good web service documentation - Download it at… https://confluence.imodules.com/display/help/ iModules+Web+Services+2.1+-+Engineering+Documentation - Or just search the Internet for imodules web service 2.1 Access - You will need a username and password to access web services - Tell your account manager that you would like to use web services - Your account manager will arrange access for you Programming Language We used Java. Any language will do as long as it can do the following… • Allow Internet access (HTTP) to place web service requests • Allow parsing of received XML data • Allow database access • Allow cache access • php, Perl, PL/SQL, Visual Basic… Many others Operating System • We used Linux… But any will do. • Choose the one you are comfortable with Scheduler The scheduler runs the web service and data aggregations processes once per minute Cron is built into the Linux operating system Caching In-memory caching allows very fast access to difficult-to-produce or frequently retrieved data We use memcached – A widely-used opensource cache - Developed at LiveJournal - Used by Wikipedia, Twitter, YouTube, Craigslist, many others Database Someplace to keep the data safe We use MongoDB – a ‘NoSQL’ database - Allows storage of ‘schemaless’ JSON documents - Easy to understand and use - Scalable and performant with minimal administrative overhead JavaScript Add-Ins Google Charts – Allows dynamic graphing of data Jquery / Tablesorter – Allows sorting of HTML tables Resources iModules Web Service v2.1 Documentation https://confluence.imodules.com/display/help/iModules+Web+Services+2.1+ -+Engineering+Documentation XML http://www.w3schools.com/xml/ Memcached http://memcached.org/ MongoDB https://www.mongodb.org/ Google Charts https://developers.google.com/chart/ Tablesorter http://tablesorter.com/docs/ Implement Viewing Transactions in Real Time James Payne james.payne@dartmouth.edu Questions?