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