boost your ecommerce with spring

44
BOOsT Your E-commerce with Spring Petar Tahchiev @ptahchiev

Upload: spring-io

Post on 08-Feb-2017

1.403 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Boost your eCommerce with Spring

BOOsT Your E-commerce withSpring

Petar Tahchiev@ptahchiev

Page 2: Boost your eCommerce with Spring

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)

Page 3: Boost your eCommerce with Spring

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)

Page 4: Boost your eCommerce with Spring

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

Page 5: Boost your eCommerce with Spring

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

Page 6: Boost your eCommerce with Spring

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

Page 7: Boost your eCommerce with Spring

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

Page 8: Boost your eCommerce with Spring

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

Page 9: Boost your eCommerce with Spring

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

Page 10: Boost your eCommerce with Spring

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

Page 11: Boost your eCommerce with Spring

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

Page 12: Boost your eCommerce with Spring

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

Page 13: Boost your eCommerce with Spring

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

Page 14: Boost your eCommerce with Spring

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

Page 15: Boost your eCommerce with Spring

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

Page 16: Boost your eCommerce with Spring

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

Page 17: Boost your eCommerce with Spring

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

Page 18: Boost your eCommerce with Spring

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

Page 19: Boost your eCommerce with Spring

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)

Page 20: Boost your eCommerce with Spring

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

Page 21: Boost your eCommerce with Spring

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

Page 22: Boost your eCommerce with Spring

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

Page 23: Boost your eCommerce with Spring

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

Page 24: Boost your eCommerce with Spring

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)

Page 25: Boost your eCommerce with Spring

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)

Page 26: Boost your eCommerce with Spring

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

Page 27: Boost your eCommerce with Spring

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

Page 28: Boost your eCommerce with Spring

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)

Page 29: Boost your eCommerce with Spring

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

Page 30: Boost your eCommerce with Spring

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)

Page 31: Boost your eCommerce with Spring

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

Page 32: Boost your eCommerce with Spring

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)

Page 33: Boost your eCommerce with Spring

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

Page 34: Boost your eCommerce with Spring

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)

Page 35: Boost your eCommerce with Spring

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

Page 36: Boost your eCommerce with Spring

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

Page 37: Boost your eCommerce with Spring

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

Page 38: Boost your eCommerce with Spring

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

Page 39: Boost your eCommerce with Spring

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

Page 40: Boost your eCommerce with Spring

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

Page 41: Boost your eCommerce with Spring

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

Page 42: Boost your eCommerce with Spring

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

Page 43: Boost your eCommerce with Spring

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?

Page 44: Boost your eCommerce with Spring

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