Skip to content

Instantly share code, notes, and snippets.

Avatar

Dave Syer dsyer

View GitHub Profile
View table.md
class method sample beans classes heap memory median mean range
com.example.bench.MicroBenchmark main demo 100.000 4671.000 7.401 47.829 0.747 0.758 0.011
@dsyer
dsyer / azure-functions.adoc
Last active Sep 21, 2018
Azure Functions Blog Draft
View azure-functions.adoc

Spring Cloud Function and Azure Functions

Spring Cloud Function has had support for Microsoft Azure Functions since version 1.0, but in the latest 2.0 releases (still in milestone phase) we decided to change the programming model a bit. This article describes what the changes mean for users, and provides a bit of background behind the shift. We in the Spring team had a lot of fun working on this and collaborating with the folks at Microsoft to get

@dsyer
dsyer / config-props.md
Created Nov 2, 2017
Notes on Dynamic Configuration Properties
View config-props.md

Dynamic Configuration Properties in Spring Boot and Spring Cloud

TL;DR

  • Use @ConfigurationProperties and always get state from the bean.
  • The Environment can change at runtime and Spring Cloud does this for you using RefreshEvent.
  • Changes are propagated to beans in Spring Cloud in 2 ways (@ConfigurationProperties and @RefreshScope).
  • If you care about the state of @ConfigurationProperties being consistent on concurrent access, put it or the consumer @Bean in @RefreshScope.

Typical Scenarios

@dsyer
dsyer / settings.xml
Created May 30, 2017
Settings for concourse build
View settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<servers>
<server>
<id>gpg.passphrase</id>
<passphrase>{{passphrase}}</passphrase>
</server>
</servers>
</settings>
@dsyer
dsyer / startup.md
Last active Mar 17, 2022
Notes on Spring Boot startup performance
View startup.md

Anatomy of Spring Boot Start Up Timing

When a Spring Boot app starts up with default (INFO) logging, there are some noticeable gaps (pauses). It's worth focusing on the gaps when looking for efficiency savings because of the amount of time they take, and because no-one bothered to log anything, so the chances are the app is doing something repetitive. We can tweak the logging levels to try and fill in the gaps and find out what is going on in there.

Basic empty web app with actuators has three such gaps:

0                                                                        1410ms
|------|---------------------------|-----|------|---------|--------|--------|
       |           578             |     |144(5)|         | 133(6) |
View workshop.md

Modern Spring

Basic Spring Boot Features

Goal: show how it is easy to create web UI and modify its behaviour according to the environment.

  • Use start.spring.io to create an application with a simple @RestController

  • Use STS to do the same thing (and mention the other IDEs)

@dsyer
dsyer / migrating-oauth2.md
Last active May 3, 2018
Guide to migrating OAuth2 apps from Spring Boot 1.2 to 1.3
View migrating-oauth2.md

Migrating OAuth2 Apps from Spring Boot 1.2 to 1.3

There are some new features in Spring Boot 1.3 to do with OAuth2 clients and servers and Spring Security OAuth2. Some of those features were ported from Spring Cloud Security and hence were in the Angel release train of Spring Cloud, but are not in the Brixton release train. This article helps you navigate the changes and update any existing apps to use the new features confidently.

Dependency Management

If you are not using Spring Cloud you should be able to just change the version number of your Spring Boot dependency. Since some of the OAuth2 features migrated from Spring Cloud Security to Spring Boot in 1.3, it is likely that things are slightly more complicated than that. A [separate article](https://spring.io/blog/2015/11/25

View sd mongo exception
java.lang.IllegalArgumentException: null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
at org.springframework.data.convert.ReflectionEntityInstantiator.createInstance(ReflectionEntityInstantiator.java:76)
at org.springframework.data.convert.ClassGeneratingEntityInstantiator.createInstance(ClassGeneratingEntityInstantiator.java:83)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:251)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:231)
@dsyer
dsyer / README.md
Last active Feb 5, 2017
Messaging Microservices
View README.md

Messaging Microservices

Messaging and asynchronous patterns are completely natural with microservices, but a lot of the start of the art material concentrates on HTTP, JSON and REST. This document is about "Message-driven Microservices" with Spring. It tracks the convergence of various ideas that are floating around in Spring Cloud, Spring Boot and Spring XD.

There is already a spring-xd-module-runner project where we started experimenting with allowing user to develop and run an XD module locally. We can extrapolate from there to a more flexible model that leads optionally to a deployable XD module, but can also be used to form more flexible structures than a simple "stream".

Basic Programming Model

Just create MessageChannels "input" and/or "output" and add @EnableMessageBus and run your app as a Spring Boot app (single application context). You need to connect to the physical broker for the bus, which is automatic if the relevant bus imple

View keybase.md

Keybase proof

I hereby claim:

  • I am dsyer on github.
  • I am dsyer (https://keybase.io/dsyer) on keybase.
  • I have a public key whose fingerprint is 032D F42A 76D3 4CD8 DE76 BEFC 257D 4510 E2E1 1827

To claim this, I am signing this object: