Skip to content

Instantly share code, notes, and snippets.

View dsyer's full-sized avatar

Dave Syer dsyer

View GitHub Profile
@dsyer
dsyer / config-props.md
Created November 2, 2017 10:25
Notes on Dynamic Configuration Properties

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 / startup.md
Last active October 30, 2023 07:41
Notes on Spring Boot startup performance

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) |
@dsyer
dsyer / .gitignore
Created December 23, 2010 13:53
Cloud Sample for Spring Batch Admin
.classpath
.project
.settings
target
bin
@dsyer
dsyer / .gitignore
Created April 19, 2012 14:06
Spring Security OAuth2 samples with custom OAuth2 endpoint URLs
*/src/META-INF/
*/src/main/java/META-INF/
samples/*/*/src/main/webapp/META-INF/
target/
.classpath
.project
.DS_Store
.settings/
*.iml
*.iws
@dsyer
dsyer / .classpath
Created December 23, 2010 13:56
A sample job for Spring Batch repository metadata - copies execution history from one repository to another.
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry kind="src" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
@dsyer
dsyer / .classpath
Created July 12, 2010 10:57
A sample using JDBC polling to test scalability with Spring Integration
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry kind="src" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
@dsyer
dsyer / .gitignore
Created February 8, 2012 15:58
Some Gatling Experiments
.cache
target/
*~
#*
*#
*/src/main/*/META-INF/
*/src/main/*/WEB-INF/lib/
.access_token
.result
.classpath
@dsyer
dsyer / table.md
Last active April 25, 2020 15:57
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 / README.md
Last active September 25, 2019 04:09
Infrastructure Advisors and Spring ApplicationContext lifecycle

Aggressive Bean Instantiation and "Unproxyable" Beans

This project is a minimal setup depending only on spring-context but mimicking closely the mess that you get into with @EnableTransactionManagement (spring-tx) or @EnableGlobalMethodSecurity (spring-security). These annotations lead to registration of an InfrastructureAdvisorAutoProxyCreator which is responsible for locating the Advisor bean that provides the enabled feature. The mess is caused by aggressive bean instantiation in that component which can cause cascades of unsafe bean instantation

@dsyer
dsyer / azure-functions.adoc
Last active September 21, 2018 08:19
Azure Functions Blog Draft

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