I’ve created a sample Spring Boot
app that demonstrates useful scenario of asynchronous publish / subscribe model. It could be
useful in many ways. Idea is that, for example, you have some API
handling some web requests, and apart from functionality it provides, it also
publishes some event, so that some other thread can react upon it, with main functionality still being processed with request handling thread.
Or even shorter – request handling thread will do it’s job, and publishes some event (using Java
annotation), and some other background thread
will subscribe to event and process it. You can use it for scenario you register user with your API
, and publish user registered event, and in
background you can subscribe to it by sending out e-mail to end user.
37 posts tagged with "technology"
View All TagsAvoid NullPointerException - use Java 8 Optional
This blog post should start with a popular quote:
Tony Hoare introduced
null
references in ALGOL W back in 1965 “simply because it was so easy to implement”, says Mr. Hoare. He talks about that decision considering it “my billion-dollar mistake”.
Instead of dealing with null
/ not-null
references, Java 8 JDK
ships with new type: Optional<T>
. How to use it?
Constructors in Kotlin
Constructors are regular functions that give a chance to developer to initialise state of class instance. They are completely optional, and it's perfectly valid to have this, although not so useful 😃
Impact of decisions at software companies
The focus of this article is to cover some pros and cons of various decisions one software company can take. Software companies need to make decisions to move forward, and as we are about to see - they rarely bring only benefits to the company.
Let's analyze the impact of various decisions software companies tend to make. Listed are some decisions, that never came with only positive effects, and, quite frequently, cons are outweighing all the pros.
Ready? Let's get started!
Decorator pattern in kotlin
If you feel curious how would an implementation of decorator design pattern look like in Kotlin, this might be the right place for you. This example is just a very basic thing that you then tweak until it’s perfect. Pattern definition can be found at Wiki, but what’s important is that you can compose chain of decorators at runtime and in such a way – you can control runtime behavior of your system.
Easy way to contribute to the Github open-source project
A couple of days ago a friend of mine asked me how he can change some existing Github project. There are quite some materials around covering this topic, but what I give you here is an exact set of steps required to actually perform the change.
By the end of the article, if you stay with me, you will be able to understand how to technically contribute to the Github open-source projects.
Extension functions in kotlin
Kotlin language recently gained some traction owing to Google promoting it as a primary language for writing android apps. Kotlin has already been for a while in production owing to it’s creator JetBrains incorporating it in own tools, such as Intellij IDEA and so forth.
Factory method pattern in Kotlin
Kotlin
language can come quite handy write concise and expressive code, without too much boilerplate, while keeping all advantages of being JVM
citizen. Let's quickly peek
into example of creating Factory
method creational design pattern implementation.
Football application using Spring boot, Thymeleaf and Spring RestTemplate
As part of my effort to adopt Spring Boot
I noticed that I need to learn new view technology in Java
ecosystem, since Spring Boot
doesn't promote JSP
, which I was
used to using. I've explored alternatives a bit, and decided to give a shot to Thymeleaf
as templating engine.
Inject language / reference feature of Intellij IDEA
One of very neat features of Intellij IDEA that I came across is injecting language / reference feature into String
object.