June Wrap up

Progress on Spring Boot Buch, Spring Datasource Proxy, Workshop
June 30, 2017 by Michael

June was a very though month. I did quite some traveling and thus had hardly time for biking. Cycling wise worst June ever, below 300km in total.

Spring Boot Buch

Two weeks ago I received several drafts for the cover and I’m quite happy with them and already decided for one.

(By the way, I have banners, too…)

      __...--~~~~~-._   _.-~~~~~--...__
    //               `V'               \\ 
   //                 |                 \\ 
  //__...--~~~~~~-._  |  _.-~~~~~~--...__\\ 
 //__.....----~~~~._\ | /_.~~~~----.....__\\
====================\\|//====================
                    `---`
Spring Boot Buch on 2.0.0.M2.

I finished the whole messaging chapter, wrote some short paragraphs how to use email sender and started working on my examples for the reactive chapter. I think they quite nice and I’m looking forward to describe them. The chapter about reactive programming is the last to finish.

I’m really happy that I was able to estimate the timeframe of that project relatively good. Next month’s gonna be disrupted, though. First there’s JCrete in two weeks (and I hope that AirBerlin stays in business until I’m back) and then there will be some changes in my life I have to organize, so lets see how this will turn out.

Spring Datasource Proxy

On my way to the location of the third topic of this post, I stumbled upon this post by Arnold Galovics.

He uses datasource-proxy for logging statements. That’s nice if you don’t use JPA for example, which can do it on a different layer. In his post Arnold describes a bean post processor to replace Spring Boots auto configured database (or any other for that matter).

In Spring Boot Buch I describe a different way. In this I use the incredible useful Spring Boot class DataSourceProperties. If you have the spring-boot-starter-data-jpa on the path, configuration properties matching the prefix spring.datasource are automatically mapped to an bean instance of this class. It provides a convenient builder method that even takes care of replacing pool specific configuration with Springs values (for example, HikariCP has some different properties than Tomcat pool).

The properties can be used like this in your configuration:

@Bean 
public DataSource dataSource(DataSourceProperties dataSourceProperties) {
    final DataSource originalDataSource = 
        dataSourceProperties.initializeDataSourceBuilder().build();
    return ProxyDataSourceBuilder
        .create(originalDataSource)
        .logQueryBySlf4j(SLF4JLogLevel.INFO)
        .build();
}

And that’s it. Spring Boots auto configuration gives your configuration precedence. So you don’t wait for spring-boot-starter-data-jpa to provide a datasource but use the same mechanism like it does to get a datasource only in the scope of the bean method, proxy it and return the proxy.

This works also with Vlad Mihalceas Flexypool for example.

You’ll find this and many more tipps in the upcoming Spring Boot Buch, planned to be published by the end of the year! Follow the progress at @springbootbuch.

That brings me to:

Another installment of bootiful databases and a premiere

Earlier this year I discovered that you can get to Cluj in Romania for just a few Euros via Wizz Air. I reached out to my friend Vlad.



Vlad does awesome work for Hibernate and wrote a great book about high performance Java persistence. We made plans about speaking together and luckily that worked out at the 59th meet up of the Transylvania JUG. They had a full room in a Hotel just for us. Amazing.

The audience was great, we both got good questions and feedback. Sadly, I forgot to take pictures, but I saw someone with a camera.

The day after, a premiere: Accesa booked me for a Spring Boot Workshop. Apart from my terrible cold that went pretty smooth. That stuff was arranged as a test driven introduction to the different slices of a Spring Boot application and I felt comfortable with it. Sadly, half of the audience already had worked with Boot, but that’s just how it is.

If you’re interested in the topic, here is the repository: ws-20170627-cluj. The last commits are an outlook how to integrate Spring Cloud and easily create docker container for your services. If you have interest in that, we should get into contact.

No comments yet

Post a Comment

Your email is never published. We need your name and email address only for verifying a legitimate comment. For more information, a copy of your saved data or a request to delete any data under this address, please send a short notice to michael@simons.ac from the address you used to comment on this entry.
By entering and submitting a comment, wether with or without name or email address, you'll agree that all data you have entered including your IP address will be checked and stored for a limited time by Automattic Inc., 60 29th Street #343, San Francisco, CA 94110-4929, USA. only for the purpose of avoiding spam. You can deny further storage of your data by sending an email to support@wordpress.com, with subject “Deletion of Data stored by Akismet”.
Required fields are marked *