Presentation is loading. Please wait.

Presentation is loading. Please wait.

© Donald F. Ferguson, 2014. All rights reserved. Topics in Modern Internet Application Development: Lecture 8: Simple Commerce and Databases Dr. Donald.

Similar presentations


Presentation on theme: "© Donald F. Ferguson, 2014. All rights reserved. Topics in Modern Internet Application Development: Lecture 8: Simple Commerce and Databases Dr. Donald."— Presentation transcript:

1 © Donald F. Ferguson, 2014. All rights reserved. Topics in Modern Internet Application Development: Lecture 8: Simple Commerce and Databases Dr. Donald F. Ferguson Donald.Ferguson@software.dell.com

2 2 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Agenda

3 3 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Agenda Introduction –Course roadmap –Project discussion, Q&A Composite applications –Core concepts –Traditional approach –Polyglot programming and polyglot database Exploring the commerce application –Content management system overview –Main page –Categories, tags and Redis –Product catalog and SimpleDB –Simple content management system with DynamoDB and S3 Project continuation

4 4 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Introduction

5 5 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Course Roadmap No syllabus survives first contact with the lectures  Our original roadmap from lecture 1 is out the window Remaining course roadmap DateTopics 13-Nov-2014Simple commerce application structure and concepts A simple content management system using Redis AWS SimpleDB, DynamoDB 27-Nov-2014Composite application technology Portal Service Bus Information integration Workflow/automation 04-Dec-2014 – 11-Dec-2014 Project discussions and help Final project reviews

6 6 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Questions? Comments? Discussion?

7 7 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Composite Applications

8 8 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Composite Applications – Some Definitions “In computing, a composite application is a software application built by combining multiple existing functions into a new application. … A composite application consists of functionality drawn from several different sources. The components may be individual selected functions from within other applications, or entire systems whose outputs have been packaged as business functions, modules, or web services.” (http://en.wikipedia.org/wiki/Composite_application)http://en.wikipedia.org/wiki/Composite_application “Composition refers to a way of delivering enterprise solutions by assembling them from prebuilt components, instead of building them from scratch. It also includes personalization and customization abilities, so that users can easily and quickly modify specific functionality in the solution.” (http://msdn.microsoft.com/en- us/library/bb220803.aspx)http://msdn.microsoft.com/en- us/library/bb220803.aspx “A composite application orchestrates independently developed programs, data and devices to deliver a new solution that none of the previously available applications could deliver on its own. Each resource accessed by a composite application uses a different data model. In most cases, the composite application supports user interactions beyond those provided by the leveraged applications. In other cases, a composite application may act as a service. Some composite applications are built by leveraging other composite applications.” (http://www.gartner.com/it-glossary/composite-application-2)http://www.gartner.com/it-glossary/composite-application-2

9 9 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Composite Applications – Some Pictures

10 10 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Databases and Use

11 11 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs SimpleDB Three things DBAs hate –Multi-valued fields –Different tuple formats in a single able –Dynamic addition of columns Using different attributes for different types of things to determine selections on a commerce “order” page.

12 12 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Backup

13 13 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs the type of functionality provided by Amazon SimpleDB has been accomplished with a clustered relational database that requires a sizable upfront investment, brings more complexity than is typically needed, and often requires a DBA to maintain and administer. In contrast, Amazon SimpleDB is easy to use and provides the core functionality of a database - real-time lookup and simple querying of structured data - without the operational complexity. Amazon SimpleDB requires no schema, automatically indexes your data and provides a simple API for storage and access. This eliminates the administrative burden of data modeling, index maintenance, and performance tuning.

14 14 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Reference Material

15 15 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Reference Material There is no text book for this class –Many books on concepts are language/runtime specific, and I did not want to mandate a “language.” –We are covering a broad set of concepts. Most books are narrower, which means there would be many books. –The “cool” technology evolves faster than we can author and publish books. –Everything I could teach or you need to know “is on the web.” A couple of students asked for books describing concepts independent of language/runtime. –The classics are –“Patterns of Enterprise Application Architecture” by Martin Fowler –“Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions” by Holpe and Wolf. –I checked with colleagues that are active in commercial web application development. The concepts are still relevant. You will see that I use versions of the patterns in my lectures. – The best programmer I have ever known, and someone who mentors new programmers, recommended “Domain-driven Design: Tackling Complexity in the Heart of Software” by Eric Evans. I have not read this book.

16 16 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs An Interlude on Composite applications Polyglot programming Polyglot database Data flow and control flow programming Messaging Domain Specific Languages and impedance mismatch.

17 17 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs RabbitMQ https://www.rabbitmq.com/getstarted.html

18 18 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Project Work Items

19 19 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Application Structure Web Application Customer Controller Agent Controller V V Data Access Service CustomerDS AgentDS ContactDS Business Service CRM Services Customer Facade Agent Facade V V V HTML

20 20 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs We are going to build a composite app Evolve the simple CRM service –Implementation using new functions, e.g. notification, workflow, rules/policy, new database types, reports, … –“Portal” for on the glass integration of multiple sites. Use a SaaS, web callable product, price, billing, … API Build a very simple, multi-tenant web commerce application (catalog, cart, …) CRM Service Multi-Tenant Commerce Service SaaS Account/ Billing API Cloud Infrastructure APIs S3 SQS OpenID …

21 21 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Current Assignment Data Access Service CustomerDS AgentDS ContactDS Business Service CRM Services Customer Facade Agent Facade V V V Q UI Controller REST API Web UI Controller may be on server or in browser (e.g. Angular) Standalone App Amazon SQS SQS Adaptor

22 22 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Current Assignment I – REST API Define and implement a REST API for the simple CRM service Your REST API/implementation must support –Duplicate request detection and discard. –Pagination, e.g. ability to iterate through large result sets. –Support requests that go “asynch” and require polling for the result. –Simple query, e.g. finding customers by last name and zipcode. Demonstrate invoking your API –From Web pages –A “standalone” program calling the REST API –Via an Amazon SQS queue. Implement the following three “rules” in your application objects 1.Agents in the USA, except those in TX and NY can have at most 5 customers. 2.A customer can only update their contact information once/week, unless their agent is in MN or CT. 3.Assigning a new agent to a customer is only allowed if there are no “contact records” less than 72 hours old.

23 23 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Current Assignment – II Think about the commerce application –There are going to be many, many message exchanges –Browse –Add to cart –Remove from cart –etc. The commerce application needs to remember –What has gone into the cart during this commerce session –What I have searched for during this commerce session –Don’t ask me, “Are you interested in metric wrenches?” –When I am shopping for textbooks. –Just because I looked for screwdrivers three years ago. Technically, –I could have the client store and provide all session information on every request –But, … this is fragile and complicated So, the application –Generates a session key/ID –The client requests always contain the session key either in a cookie or URL (URL rewrite) –Maintains session state in a “database.” –Invalidates the session key/ID when the client logs out or the session times out.

24 24 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Current Assignment – II Build a simple commerce application –Product –Catalog –Customer –Shopping Cart Customers connect to the commerce application –Creating a commerce session –Search the catalog and view product information –Add items to the cart –Submit the cart You must figure out how to –Implement session behavior, e.g. “find the cart.” –Record what items a customer has viewed during the current session.

25 25 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Current Assignment III Data Access Service CustomerDS AgentDS ContactDS Business Service CRM Services Customer Facade Agent Facade VVV REST API “RabbitMQ” Subscriptions Notification Service Install and configure RabbitMQ Write a simple application that enables agents to CRUD subscriptions, specifying –Topics –Notify method Listens for events on Rabbit MQ and uses AWS API to notify agent using SNS or SES Modify CRM app to automatically emit events for CUD of customer

26 26 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs New Material

27 27 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Session Management

28 28 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Session State Management References –Patterns of Enterprise Application Architecture, Chapter 17. –Chapter 4: Creating and Managing User Sessions, Sun Java System Application Server Standard and Enterprise Edition 7 2004Q2 Developer's Guide to Web Applications. (http://docs.oracle.com/cd/E19644-01/817-5451/dwsessn.html)http://docs.oracle.com/cd/E19644-01/817-5451/dwsessn.html –The Java EE 6 Tutorial, Chapter 20, Stateful Session Beans http://docs.oracle.com/javaee/5/tutorial/doc/bnbly.html#bnbma http://docs.oracle.com/javaee/5/tutorial/doc/bnbly.html#bnbma We will examine Stateful SessionBeans –Independent of the protocol, i.e. not intertwined with HTTP –Simple, clean demonstration of the concepts –I helped invent it, and you have to learn to use it even if no one uses it.

29 29 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Stateful SessionBeans Stateful session beans are appropriate if any of the following conditions are true. –The bean’s state represents the interaction between the bean and a specific client. –The commerce application has many active customers. –The cart and browsing history are specific to each customer. –The bean needs to hold information about the client across method invocations. –Is there are cart? What is in the cart? –What has the customer viewed? –The bean mediates between the client and the other components of the application, presenting a simplified view to the client. –Behind the scenes, the bean manages the work flow of several enterprise beans. –Multiple components: catalog, cart, customer information, … –REST calls read and manipulate multiple entitities

30 30 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Stateful SessionBean Lifecycle

31 31 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Interface

32 32 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Implementation

33 33 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Implementation

34 34 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Hmmm This seems OK for “stateful” programming –Local Java programming where I can have references to instances –RMI/IIOP –etc. How does this work for REST/URLs? –One URL, e.g. …/cart/addBook?title=“Blah Blah” –Kind of references lots of things –Depending on the client making the call. Use a Façade –Another, user independent, singleton implements interface cart –Extracts customerID for the HTTP header –Looks up the cart in a Map and delegates to the real cart –If the “real cart” does not exist, it create a cart and puts in the map. Do not do you assignment this way –This tutorial is awful. “Cart” is an EntityBean, not a SessionBean. –A REST/HTTP Session would typically have state independent of Stateful SessionBeans. –I used this example to help draw the distinction between pattern and realization.

35 35 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Commerce and Content Management

36 36 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Some New Data Models

37 37 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Query Results {author, “Ferguson”} {includes, {paper, {author, “Ferguson”}}} {references, {book, {author, “Ferguson”}}}

38 38 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Data and Rendering Two different renderings Of the same underlying document

39 39 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Content Management System Some Terminology A content management system (CMS) is a computer application that –Allows publishing, editing and modifying content, organizing, deleting as well as maintenance from a central interface. –Such systems of content management provide procedures to manage workflow in a collaborative environment. A web content management system is a bundled or stand-alone application –To create, deploy, manage and store content on Web pages. –Content includes text and embedded graphics, photos, video, audio, … –Content includes code that displays content in a specific way –A Web CMS may catalog and index content, select or assemble content at runtime, or deliver content to specific visitors in a requested way, such as other languages.

40 40 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs CMS Data Model

41 41 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Why Don ’ t I Just Use … A relational database? RDBs do not handle –Dynamic taxonomies/folders particularly well. –Relatively free form tagging and query of items. –You can realize the model in relational, but you have to write a specific schema. –Your code is awkward and you write “framework,” which is a CMS. A file system? –File systems do not handle arbitrary metadata well. I want to find documents with author=“Ferguson” not containing the text “Ferguson.” –I want to publish or rollback all changes made by Bob in the last 24 hours. –Jim must approve all contributions of type “Press Release.” MongoDB? –Handle hierarchical and dynamic tags well. –Not great for images, audio, … –Would still need some framework code.

42 42 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Apache Jackrabbit

43 43 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs The Simple Commerce Application Needs a CMS Product classification, e.g. –Classification I: Books, Magazines, Videos –Classification II: Sports, Engineering, Business Relatively freeform, queryable information –Artist Type = {Author, Editor, Contributor, Reviewer, …}.Name={…} –Format = {eBook, paperback, audiobook, …} Fragments of a rendering, e.g. –Images –Reviews –Descriptive prose –TOC Various renderings, e.g. –Summary in a search result –Full information

44 44 © Donald F. Ferguson, 2014. All rights reserved.Modern Internet App Development – Lecture 8: Simple Commerce, Content Management, Some DBs Commerce Application We are not going to use a full functional CMS –Powerful, but complex to set up and use. –Hides some interesting concepts. –Conflates orthogonal concepts. We are going to use –Redis for tracking what users have viewed, usage frequency, etc. –S3 for storing “content” and associated metadata –Images,.WAV files, etc. –Created date, author, tags, … –SimpleDB for product descriptions, categories, …


Download ppt "© Donald F. Ferguson, 2014. All rights reserved. Topics in Modern Internet Application Development: Lecture 8: Simple Commerce and Databases Dr. Donald."

Similar presentations


Ads by Google