The Spring Blog

Engineering
Releases
News and Events

This Week in Spring - December 20, 2016

Welcome to another installment of This Week in Spring! This week I’m in the winter wonderland of Toronto, Canada, hanging out with the amazing Pivotal Labs Toronto office and working with some of the largest financial institutions in all of Canada as they transition to Spring Cloud and to Pivotal Cloud Foundry. I love seeing seemingly large, lumbering companies run at startup speeds and crave it.

This week is the week of Christmas for some in the world, followed shortly by the western western new year. If you celebrate either (or both) of them, then, on behalf of the Spring team, let me wish you the happiest of holidays! I, for one, can’t believe we’re now less than two weeks away from 2017 (and with it, the beginning of the 7th year writing This Week in Spring!)

Read more...

Spring Cloud Spinnaker 1.0.0.M3

Greetings Spring community,

I am happy to release the second milestone for Spring Cloud Spinnaker. Spring Cloud Spinnaker bundles up the continuous delivery Spinnaker platform, and provides a 1-click installer to let you install it to any certified Cloud Foundry provider.

UPDATE: This blog post originally cited M2, however one of our early adopters spotted a critical bug, so M3 has been built and released with the fix in hand.

Key features included in this release:

  • Much more simplified way to login, select your org and space from dropdowns, etc., shooting for as simple an experience as possible.

  • Ability to manage two CF spaces

  • Support for Jenkins and Travis CI monitoring.

  • Configure email and slack notifications

  • Move to hosted uber JARs, meaning installing the installer is no longer a bugbear

  • Other enhancements regarding to Spinnaker itself include ability to clone server groups, an upgrade to our Reactor-based cf-java-client 2 library, and also enhance UX showing more CF information than ever.

Read more...

This Week in Spring - December 13th, 2016

Welcome to another installment of This Week in Spring! This year has flown so quickly by! Can you believe we’re less than 19 days until 2017? I’m utterly stunned. I suppose I shouldn’t be, though, given the breakneck speed of progress and new software releases from the Spring team and the community. What a good problem to have!

This week, after returning from Australia early Sunday morning, I hacked with my buddy Josh McKenty, I spoke with my buddy Baruch at the San Francisco Java User Group on Monday, will speak with my buddy Matt Raible at the Denver Java User Group on Wednesday (don’t miss it!), and will speak in Saint Louis on Thursday and Hartford on Friday. It’s going to be a fun week and if you’re around, don’t hesitate to say hi.

Read more...

This Week in Spring - December 6th, 2016

Welcome to another installment of This Week in Spring! This week I’m in Brisbane, Australia, on the second leg of the YOW! conference circuit. If you’re around, please say hi or find me when YOW! moves to Sydney in a few days.

We’ve got a lot to cover so let’s get to it!

Read more...

This Week in Spring - November 29th, 2016

Welcome to another installment of This Week in Spring! I can’t believe how quickly this year has gone! This week I’m in Melbourne, Australia for the YOW! conference and then week it’s off to Brisbane and then Sydney for the next editions of the same show. Australia is the furthest I’ve ever been from my ‘native’ timezone - so even though I always post This Week in Spring every Tuesday, I appreciate that it’s still Monday for anybody west of Europe right now! Tonight, I’ll join my pal, Intellij’s Trisha Gee, and we’ll be speaking at the Melbourne JVM User Group. I’m super excited to be here, for my first time, helping bring the Spring down under. If you’re around then say hi (@starbuxman)!

Read more...

Going reactive with Spring Data

Last weeks' Spring Data Kay M1 is the first release ever that comes with support for reactive data access. Its initial set of supported stores — MongoDB, Apache Cassandra and Redis — all ship reactive drivers already, which made them very natural candidates for such a prototype. Let’s take a more detailed look at the new programming model and the APIs that make up that support.

Reactive Repositories

The repositories programming model is the most high-level abstraction Spring Data users usually deal with. They’re usually comprised of a set of CRUD methods defined in a Spring Data provided interface and domain-specific query methods. Here’s what a reactive Spring Data repository definition would look like:

public interface ReactivePersonRepository
  extends ReactiveCrudRepository<Person, String> {

  Flux<Person> findByLastname(Mono<String> lastname);

  @Query("{ 'firstname': ?0, 'lastname': ?1}")
  Mono<Person> findByFirstnameAndLastname(String firstname, String lastname);
}

As you can see, there’s not too much difference to what you’re used to. However, in contrast to the traditional repository interfaces, a reactive repository uses reactive types as return types and can do so for parameter types, too. The CRUD methods in the newly introduced ReactiveCrudRepository, of course make use of these types, too.

By default, reactive repositories use Project Reactor types but other reactive libraries can also be used. We provide custom repository base interface (e.g. RxJava1CrudRepository) for those and also automatically adapt the types as needed for query methods, e.g RxJava’s Observable and Single. The rest basically stays the same. Note, however, that the current milestone does not support pagination yet and you of course have to have the necessary reactive libraries on the classpath to activate support for a particular library.

Activating reactive Spring Data

Similarly to what we have in the blocking world, the support for reactive Spring Data is activated through an @Enable… annotation alongside some infrastructure setup:

@EnableReactiveMongoRepositories
public class AppConfig extends AbstractReactiveMongoConfiguration {

  @Bean
  public MongoClient mongoClient() {
    return MongoClients.create();
  }

  @Override
  protected String getDatabaseName() {
    return "reactive";
  }
}

See how we use a different base class for the infrastructure configuration, as we need to make use of the MongoDB async driver.

Read more...