Declarative style in reactive programming

By on Mar 2, 2019 in eng |

My team has adopted reactive programming in our new project. We are using Spring WebFlux to serve data over REST call. The whole team is new on this programming style. The most essential concept I find myself struggling with is the declarative style of reactive programming The following made-up example in Kotlin below show typical pattern we see in reactive programming. The activateMember method will chain together method call and reactor operator (map, flatMap, onErrorReturn) and finally return a Mono or Flux of something. <pre class="wp-block-syntaxhighlighter-code">fun main(args: Array<String>) { activateMember("fake-id-11").subscribe(::println) } fun activateMember(userId: String): Mono<OperationResult> { return getUserInfoFromServer(userId) .flatMap { user -> saveUserStatus(user, UserStatus.ENABLED) } .map { isSuccess -> if (isSuccess)...

Heartbeat Thread in Kafka Consumer

By on Aug 8, 2018 in eng |

Kafka Consumer 0.10.1 has introduced a background thread for sending heartbeat instead of relying on user application thread to keep polling regularly like in the earlier versions.

Stop The World

By on Feb 13, 2017 in eng | 2 comments

I was watching an excellent technical session about Java GC. When the speaker said “Pause is inevitable no matter which collector you use”, a thought suddenly came to my mind that this is also true for living a life.

The long lost happiness

By on Jun 20, 2015 in eng | 1 comment

I took a two days vocation in Koh Samed a months ago. In the second night, I came across a beautiful fire shows on the beach near a restaurant. My Canon 6D was very good with low light so I took a lot of photos. I could not move around easily since the place was crowed so I missed some excellent actions. The show ended leaving me wanting for more. I waited there for a while in hope that there will be a next round but there was no sign of it. While I was thinking about going back to my room, I saw the light of fire from a show in another restaurant like 100 meters away. I grabbed my camera and run.

Instance Confinement

By on Jul 12, 2013 in eng |

I almost forgot that I have this story in my to-be-blogged list. I was assigned to perform performance tuning on a system in my previous project. I found a concurrency bottleneck and rearrange the synchronization pattern to gain noticeably throughput. I later had a chance to read about the Instance Confinement technique which could be applied with the case. The technique uses the normal object encapsulation to make the code easier to understand in term of concurrent access aspect.