boost your ecommerce with spring
TRANSCRIPT
BOOsT Your E-commerce withSpring
Petar Tahchiev@ptahchiev
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
2
Contents
● About me (5 mins)● Mind the gap (5 mins)● Solution (5 mins)● Spring to the rescue (60 mins)
– Why spring? (5 mins)
– Initial implementation (10 mins)
– Challenges and solutions (45 mins)
● Lessons learned (10 mins)● Q&A (5 mins)
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
3
About me (@ptahchiev)
● Mathematician, software developer and entrepreneur
● Apache Maven developer
● Co-author of “JUnit in Action II”
● Interested in Spring
● Interested in e-commerce
● Founder of Nemesis Software Ltd. (@nemesissoftware)
● Hobby musician (http://soundcloud.com/ptahchiev)
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
4
Mind the gap
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
5
Mind the gap - FOSS
● My journey in e-commerce began 2008
● Implemented more than 30 successful e-commerce stores
● I noticed several patterns
– The vast majority of clients had the LAMP stack ...
– ... and wanted enterprise Java stack …
– ... because of performance problems.
– Scaling was a problem
– Infrastructure was a problem
– Resources wasn't a problem
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
6
Mind the gap - enterprise
● Several Java enterprise e-commerce players
● None of which was cloud-ready
● Sharing the same disease
– Legacy software issues
– Modularity issues
– Infrastructure issues
– Knowledge issues
– Time-to-market challenges
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
7
Solution
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
8
Solut ion
● A new platform that steps on the following principles
– Enterprise
– Cloud-ready (12 factor app)
– Latest and greatest of FOSS
– Open standards
– Modular
– REST
– Easy to use, easy to import data and fast time-to-market
– Demo storefront
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
9
Spring to the rescue
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
10
Spring to the rescue – why?
● Evaluated several frameworks
● Why we ended up with Spring
– The de-facto standard in Enterprise Java Programming
– The spring eco-system provides the complete stack of technologies
– The team behind it
– Innovative
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
11
Spring to the rescue – initialimplementation
● Started in 2011 with Spring 3.0.7.RELEASE
● Maven based project
● JPA backed with hibernate
● Csv based imports with catalog synchronizations
● Multiple javascript backends over REST
● Multi
– Catalog - Website
– Language - Currency
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
12
Spring to the rescue – initialimplementation
● However, ecosystem not complete
– No Spring platform bom
– No Spring data solr/elasticsearch/rest/redis
– No Spring mobile
– No Spring session
– No Jcache
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
13
So what was it then?
● Spring WebMVC
● Spring security
● Spring data jpa was just out
● Spring social was just out
● Custom mobile implementation with HandlerInterceptor's postView
● Custom boot implementation
● Custom REST implementation
● maven-jetty-plugin or maven-tomcat-plugin
● Some xml-based configuration
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
14
Challenges
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
15
Spring Platform BOM
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
16
Spring Platform BOM
● Easy dependency management
● Maven plugin declarations
● Maven profile declarations
● Still to improve – expect to have properties for maven plugin versions
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
17
Spring Boot
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
18
Spring Boot
● Get rid of the custom constructions (replace with conditionals)
● Separate each module as a spring-boot module
– Add spring.factories and @Configuration class
– Client to list it as maven dependency
● Use the actuator endpoints
● Maven plugin
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
19
Spring Boot
● The overall code that was reduced code ~ 60%
● We didn't just stop there
– We raised 11 issues
– Contributed the jcache actuator endpoint
– Contributed the STOMP logging actuator endpoint
● Kudos to (@snicoll) and (@david_syer)
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
20
s ta r t .ne mes i s . i o
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
21
Spring DATA
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
22
Spring Data – JPA - domain model
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
23
Spring Data – JPA - domain model
● Setup modular domain model
● JPA entities as interfaces
● Keep repositories in the platform
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
24
Spring Data – JPA - repositories
● Implications on modularity
● Kudos to Oliver Gierke (@olivergierke)
● Expose it all via REST
● We didn't just stop there
– Raised more than 30 JIRA issues (mostly on Spring Data REST)
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
25
Spring Data – Search
● Introduce spring-data repositories for JPA/Solr/Elasticsearch
● Common core + Multiple implementations (Solr, Elasticsearch)
● Kudos to Christoph Strobl (@stroblchristoph)
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
26
Spring Data – REST
● Server-side generated
● Projections
● Validation
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
27
Spring Session
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
28
Spring Session
● Pre-Spring-Session implementation
● Replace it all with Spring session
● Implications on the SessionService
● Multiple browser sessions
● Kudos to Rob Wynch (@rob_wynch)
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
29
Spring Batch
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
30
Spring Batch
● Allows us to orchestrate different jobs (csv imports, catalogs syncs, etc)
● Demo initialization
● Aggregate imports implementation
● Executor service for multi-threaded reader
● Session implications
● Kudos to Michael Minnella (@michaelminella)
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
31
Spring WebMVC
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
32
Spring WebMVC
● Jawr
● Webjars & Themes
● Kudos to Rossen Stoyanchev (@rstoya05)
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
33
Spring Security
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
34
Spring Security
● Securing the storefront
● Securing the REST layer
● Kudos to Rob Wynch (@rob_wynch)
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
35
Spring Mobile
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
36
Spring Mobile
● Single platform hosts multiple sites
● Each website can be responsive or not
● If not responsive the website needs a separate set of views
● If responsive however we must always view the desktop views
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
37
Testing
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
38
Testing
● Each module contains a set of unit/integration tests
● The REST module contains also mockMVC tests
● The storefront contains both mockMVC and selenium tests with multipleprofiles
● Tests are executed on a CircleCI machine on each repository push
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
39
Documentation
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
40
Documentation
● Documentation is maintained inside Git repository
● Stored in Asciidoc format
● Built and deployed by maven on CircleCI on each push
● Rest module uses also spring-restdocs
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
41
Lessons Learned
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
42
Lessons Learned
● Software is never complete – there is always room for improvement
● Spring turned out to be the right choice for us
● Don't hesitate to ask for support
● The Spring team is really great
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
43
Questions?
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
44
Learn More. Stay Connected.
Learn more on h t tp : / / nemes is . io /
@ s p r i n g c e n t r a l S p r i n g . i o / v i d e o