Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
MongoDB + Spring
Technical Webinar
Norberto Leite, Technical Evangelist, MongoDB
@nleite
3
Things that we are going to cover
•  How to use MongoDB on Spring projects
•  An overview of the different ways to integrate
•  Best practices
•  Upcoming interesting features for MongoDB
4
Ola!
Norberto Leite
Technical Evangelist
Madrid, Spain
http://www.mongodb.com/norberto
@nleite
norberto@mongodb.com
Agenda
MongoDB Intro
Spring Framework Overview
Spring + MongoDB
introduction
7
MongoDB
GENERAL PURPOSE DOCUMENT DATABASE OPEN-SOURCE
8
MONGODB FEATURES
JSON Document Model
with Dynamic Schemas
Auto-Sharding for
Horizontal Scalability
Text Search
Aggregation Framework
and MapReduce
Full, Flexible Index Support
and Rich Queries
Built-In Replication
for High Availability
Advanced Security
Large Media Storage
with GridFS
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring Stack
10
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Bag full of tricks
11
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Lots of different options and projects
Spring
Framework
Spring
Security
Spring
Data
Spring
Batch
Spring
Integration
Spring
Reactor
Spring
AMQP
Spring
Hateoas
Spring
Mobile
Spring
Android
Spring
Social
Groovy Spring
Web Services
Spring
Web Flow
Spring
XD
Spring
Boot
Spring
LDAP
Grails
Spring & MongoDB
Open Source Flexible Integration
14
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Demo
Unless otherwise indicated, these slides are
© 2013-2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Let's build
something with
MongoDB and
Spring
MongoDB + Spring
Not the typical …
16
… just nice and simple
17
Video Catalog App
•  All videos from our Education platform
– Yes, we have the coolest education app ever!
for remote education!
https://university.mongodb.com/
18
Video Catalog App
•  All videos from our Education platform
•  Load Video information into MongoDB
– Using GridFS for Binary storage
– Separate Database for Video Catalog
•  All using Spring implementation
19
Stack
MongoDB
DAL – Database Access Layer
demo.springio.batch REST API
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Code, code, code …
21
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
DAL
§ Decoupling Database
• Rule n1 on good Software Development
§ Base Library
§ Simple
22
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Batch
§ Batch Configuration Class
• reader()
• writer()
@Configuration
@EnableBatchProcessing
§ ItemProcessor()
• Excellent way to do pre-aggregations, computations…
23
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Batch
§ Things to look for
• chunk(chunkSize)
• Keep an eye on this value to optmise the loading
process
• writer()
• MongoDB bulk insert is here to help
http://1.bp.blogspot.com/-H40bE-rJUqk/UXo3YatYjqI/AAAAAAAAAho/zjrQVk3WrNA/s1600/paella_03.jpg
Take Ways
25
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Recap
§ Spring has a lot of things out of the box that we do not
need to reinvent the all the time
§ MongoDB can easily be integrated with existing Spring
based projects
§ Performance is important
§ Continuous Improvement is key!
M101J: MONGODB FOR JAVADEVELOPERS
https://university.mongodb.com/courses/M101J/about
MongoDB Days 2015
02 December, 2015 San Jose, Ca
https://www.mongodb.com/events/mongodb-days-siliconvalley
Obrigado!
Norberto Leite
Technical Evangelist
norberto@mongodb.com
@nleite
https://github.com/nleite/springdemo

Mongodb Spring

  • 1.
    Unless otherwise indicated,these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ MongoDB + Spring Technical Webinar Norberto Leite, Technical Evangelist, MongoDB @nleite
  • 3.
    3 Things that weare going to cover •  How to use MongoDB on Spring projects •  An overview of the different ways to integrate •  Best practices •  Upcoming interesting features for MongoDB
  • 4.
    4 Ola! Norberto Leite Technical Evangelist Madrid,Spain http://www.mongodb.com/norberto @nleite [email protected]
  • 5.
    Agenda MongoDB Intro Spring FrameworkOverview Spring + MongoDB
  • 6.
  • 7.
  • 8.
    8 MONGODB FEATURES JSON DocumentModel with Dynamic Schemas Auto-Sharding for Horizontal Scalability Text Search Aggregation Framework and MapReduce Full, Flexible Index Support and Rich Queries Built-In Replication for High Availability Advanced Security Large Media Storage with GridFS
  • 9.
    Unless otherwise indicated,these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Stack
  • 10.
    10 Unless otherwise indicated,these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Bag full of tricks
  • 11.
    11 Unless otherwise indicated,these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Lots of different options and projects Spring Framework Spring Security Spring Data Spring Batch Spring Integration Spring Reactor Spring AMQP Spring Hateoas Spring Mobile Spring Android Spring Social Groovy Spring Web Services Spring Web Flow Spring XD Spring Boot Spring LDAP Grails
  • 12.
  • 13.
  • 14.
    14 Unless otherwise indicated,these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Demo Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Let's build something with MongoDB and Spring MongoDB + Spring
  • 15.
  • 16.
    16 … just niceand simple
  • 17.
    17 Video Catalog App • All videos from our Education platform – Yes, we have the coolest education app ever! for remote education! https://university.mongodb.com/
  • 18.
    18 Video Catalog App • All videos from our Education platform •  Load Video information into MongoDB – Using GridFS for Binary storage – Separate Database for Video Catalog •  All using Spring implementation
  • 19.
    19 Stack MongoDB DAL – DatabaseAccess Layer demo.springio.batch REST API
  • 20.
    Unless otherwise indicated,these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Code, code, code …
  • 21.
    21 Unless otherwise indicated,these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ DAL § Decoupling Database • Rule n1 on good Software Development § Base Library § Simple
  • 22.
    22 Unless otherwise indicated,these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Batch § Batch Configuration Class • reader() • writer() @Configuration @EnableBatchProcessing § ItemProcessor() • Excellent way to do pre-aggregations, computations…
  • 23.
    23 Unless otherwise indicated,these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Batch § Things to look for • chunk(chunkSize) • Keep an eye on this value to optmise the loading process • writer() • MongoDB bulk insert is here to help
  • 24.
  • 25.
    25 Unless otherwise indicated,these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Recap § Spring has a lot of things out of the box that we do not need to reinvent the all the time § MongoDB can easily be integrated with existing Spring based projects § Performance is important § Continuous Improvement is key!
  • 26.
    M101J: MONGODB FORJAVADEVELOPERS https://university.mongodb.com/courses/M101J/about
  • 27.
    MongoDB Days 2015 02December, 2015 San Jose, Ca https://www.mongodb.com/events/mongodb-days-siliconvalley
  • 28.