Spring Reactive Neo4j



  1. Spring Data Neo4j Dynamic Query
  2. Spring Reactive Neo4j System
  3. Neo4j Spring Boot

Setting up the Spring Boot SDN/RX application First of all, go to the Spring Initializr. As we want to create a reactive, secured web application, you will need to add reactive and security as. Please note that Neo4j requires each entity to have a primary key, with a field named id being picked up by default. An alternatively named field could be used by annotating it with @Id @GeneratedValue. Then, we need to create a configuration that will be used to bootstrap Neo4j‘s OGM. For simplicity, let us use an embedded in-memory only. Neo4j is a highly scalable, native graph database. Spring Data supports Spring Neo4J for Graph Database: annotated POJOs, SD-Repositories and Neo4j-Template. Tutorial will guides you how to work with Spring Neo4j. Technologies for Spring Neo4j tutorialII. Structure of Project2. Create Spring Boot project2. Add needed dependencies3.

Patrick Baumgartner

42talents, Switzerland

Workshop info:

Date: 13 November

Time: 10:00 – 17:00

Language: English

Patrick Baumgartner

42talents, Switzerland

Workshop info:

Date: 13 November

Spring reactive neo4j software

Time: 10:00 – 17:00

Language: English

Patrick Baumgartner works as a passionate software crafter at 42talents and builds software with Java, the Spring ecosystem, OSGi, Neo4j and ElasticSearch and other open source technologies. In the software crafter community, he co-organises the Software Craftsmanship Zurich Meetup and runs the SoCraTes Conference Switzerland and is involved VoxxedDays Zürich and other events. Besides that, he teaches at ZHAW Zurich University of Applied Science and speaks regularly on conferences about Software Craft and technical topics around Java and Spring.

In this Workshop, we will use Spring Framework 5 to write Functional Reactive code and will answer the following questions.

● What is Functional Programming?
● What is Reactive Programming?
● What is Functional Reactive Programming?

Functional Reactive Programming is a hot trend in the Java world and also introduced in Spring Framework 5. This new paradigm allows you to effectively work with streams of data.
You’ll get hands on experience with building a Reactive application to stream data leveraging the newly available Reactive data types, Spring WebFlux and Spring Data.

  • Introduction Reactive Streams, Publisher/Subscriber types and Reactor types
  • Using Spring WebFlux
  • Functional configuration API for Spring WebFlux
  • Using Spring Data MongoDB to reactively stream data
  • Using Reactive Types with Thymeleaf
  • Using Spring Security Reactive
  • Using Reactive RabbitMQ with Spring
  • Using Reactive Redis with Spring

Participants will build and test the individual parts of a Spring Boot microservices infrastructure themselves. We will use different tools and demonstrate the interaction between them. At the end of the day, participants will take along a backpack of tools, working techniques and terms that will help them successfully implement reactive components with Spring Boot. The example project realised in the workshop can later serve as a basis for own projects.

This workshop is targeted at developers and architects who are new to reactive programming and want to learn how to use the Spring ecosystem to get started.

In order to participate, you will need:

  • A laptop with at enough spare disk space and RAM
  • Java, Maven and your favourite IDE installed (Eclipse, Spring STS, IntelliJ, Netbeans)

A couple of weeks ago, I received a paper copy of “Hacking with Spring Boot 2.3 – Reactive Edition” by Greg L. Turnquist. Greg sent this copy to me free of charge for a review. Thanks for that!

I’m happy about the opportunity to read a new Spring Boot book after I published one myself nearly two years ago (See Spring Boot Buch) about Spring Boot 2.0.

I also have only high regards of Greg. While I work at Neo4j, Inc. and Greg at VMWare we happen to have very similar tasks: We both work at various Spring Data modules and meet regularly at the shared standup.

Spring Data Neo4j Dynamic Query

About the print

Greg chose to self-publish his new book and I can totally relate. My copy came as “print on demand” version from Amazon. The quality is really nice and in no way worse than Greg’s previous book.

Neo4j

I may prefer a more black typesetting, but it’s still readable well enough. Apart from that, you clearly see it’s AsciiDoc based sources 🙂

Lexicon or hands on?

Hacking with Spring Boot 2.3 is definitely a hands on book. After a quick introduction to Spring Boot itself, Greg jumps right away from it 🙂 The focus lies on introduction reactive programming concepts and a very simple kitchen domain.

All the time, it really feels like you are sitting with Greg together on the keyboard, pair programming.

What I like about not doing Spring and Spring Boot related stuff at the very beginning is the mere fact that this is what Spring should be about: Providing the plumbing for your domain around it, not inside it. Having the start designed this way is excellent.

Of course, Greg needs to introduce core Spring Boot concepts at the beginning and we get a good overview about Spring Boot starters, auto configuration, metadata and more.

On data access

The book is about hacking with Spring Boot, not with Spring Data. But I agree 100% with Greg that an application without data is somewhat meaningless. As the book targets reactive programming especially, Greg has to pick a database that supports real reactive drivers, not something wrapped in a thread pool. At the time of writing, MongoDB was the predominant one. I would have of course loved to see SDN/RX and Neo4j, but I guess I cannot have everything.

In the meantime, you can go for Neo4j or with R2DBC and several SQL-Databases (amongst them, PostgresQL).

Anyway, I do think that Greg manages to cover standard idioms and best practices to work with Spring Data based data access code a like. It’s an exhausting topic, but the overview is just right.

Spring Reactive Neo4j

On developer tools

Solid content on the “standard” Spring Boot developer tools, like restarting mechanisms and caching. Complete and nothing much to say about. The new logging groups are mentioned.

The information about Project Reactors debug mode, the logging mechanism for reactive assemblies and also the reference to the BlockHound a very valuable, even for a seasoned library developer like myself.

On testing

Testing with Spring Boot is a solid introduction to the testing support. It recaps the differences between unit, integration and end-to-end-tests. It clarifies that Spring Boot (and Spring) always strived for testability, in contrast to other believes.

While I would have probably chose different examples for testing services – for example not firing up the Spring Context at all as long as possible, especially with everything constructor injected as one should do – I super like the stance on reactive testing support. Starting about Project Reactors step verifiers and some more gems:

I learned about to things: Mono#hide respectively the corresponding fact that Project reactor may optimizes empty monos away and about Blockhounds JUnit 5 integration (Remember: Blockhound detects blocking calls in reactive code):

The above dependency brings in a test execution listener that instruments all running tests. Sweet and short.

Operations with Spring Boot

So must of the Docker and container related stuff in that chapter is brand new Spring Boot 2.3. Spring Boot Actuator has been there forever, but it’s helpful of course for people being new to Boot. Also: Thanks for the reminder to epxose actuator endpoints consciously.

Anyway, I myself found the explanation of how to use Spring Boot 2.3s new layered Jar with layered Docker images and WITHOUT the also possible Buildpack approach very usable.

Rest? Not for the RESTFul!

I wouldn’t be happy having a book by Greg without a good chapter on REST. But of course, I get one: Greg evolves a standard REST controller (Just returning plain JSON) to support HATEOAS to support affordances, all in a reactive way and all accompanied by Spring REST docs test.

A reader must do some deeper dive in some of the junction points afterwards, but they clearly have an idea what is possible.

Subliminal Messages

The most valuable piece of information for me here is the very nice explanation of Project Reactors publishOn and subscribeOn operators as well as the different schedulers revisited.

RSocket 🚀

This chapter makes me want use this link to start.spring.io, add our SDN/RX to it and jump into developing an RSocket proxy to reactive Neo4j repositories.

Especially on the topic of RSocket of which I don’t know yet much, Greg’s approach showing what is possible works very well for me. It gives you an idea and let’s you build from there on.

I personally will do some more reading afterwards on the backgrounds, though and this would of course also be my recommendation (the very same recommendation I have for people after many conference talks: Check the techs background and ideas, before you take conference driven development home and just go with the flow).

“Spring security is a beast”

Well, chapters about security: They are a can of worms. Writing them exposes the same problems that Spring Boot 1.x has had by making educated guesses of how Spring Security should be configured (they changed that later on, nowadays Spring Boot uses Spring Security’s defaults and backs of entirely when one configures a single aspect of it).

Anyway: There’s only so much depth an author can go, and so Greg shows only the basic concepts of Spring Security (for reactive applications).

I guess that in the real world, that chapter will leave the most open questions, for example how to integrate with Keycloak, Kerberos, LDAP or whatever.

As Greg writes about Spring Security’s OAuth2 support, my approach would be applying what you learn there and delegate everything to some IDAM, for example bespoke Keycloak (in contrast of running your own OAuth server based on a Spring Boot Spring Security application).

The main takeaway of that chapter for me is actually some good ideas what I can do once I have an authenticated user in the context.

Spring Reactive Neo4j

Verdict

As I said already on twitter:

'Hacking with Spring Boot 2.3' by @gregturn is a very different book than mine, focusing more on what's possible and not that much on the internal workings of things. I like it, though. The book guides you through a lot of recommended best practices.

In depth review incoming.

— Michael Simons (@rotnroll666) July 3, 2020

Greg’s book gives a rock solid overview, both about core Spring and Spring Boot ideas as well as reactive programming paradigms. The later was super valuable for me.

If you want to go more into technical details – why auto configuration or Spring data repositories work – you need to look for a different resource, most possible the great documentations and talks from the Spring team (this one from Madhura) or my own talks or book (given you can read German).

While I work for Neo4j and I find the lack of Neo4j examples in Greg’s book disturbing, I’m gonna recommend it anyway to my colleagues in the field teams. After reading, they will have good ideas what’s in the box and where to dig further.

No comments yet

Spring Reactive Neo4j System

Post a commentTrackback URIRSS 2.0 feed for those comments

Neo4j Spring Boot

Post a Comment