Skip to main content

Posts

Showing posts from 2016

Reactive Programming with RxJava book published

"Reactive Programming with RxJava: Creating Asynchronous, Event-Based Applications" book was finally published on paper.
More than a year of hard work resulted in almost 350 pages packed with RxJava and touching various technologies like Android, Camel, NoSQL, Hystrix and more. It's available as an ebook and in paperback at official O'Reilly store as well as on Amazon. But rather than making a sales pitch I'd like to share some of my experiences with writing my first book.

Atlas is great All authors writing for O'Reilly get access to Atlas - their publishing platform. Atlas is like a combination of GitHub and Jenkins - it hosts your books in built-in git repository and "builds" them. For developers the user experience is very familiar. The one and only source of your book is in O'Reilly-hosted git repository. You can use it as any other repository: commit changes, push to branches, pull revisions from other authors. You can quickly see history …

Small scale stream processing kata. Part 2: RxJava 1.x/2.x

In part 1: thread pools we designed and implemented relatively simple system for processing events in real time. Make sure you read previous part as it contains some classes that we'll reuse. Just in case here are the requirements:

A system delivers around one thousand events per second. Each Event has at least two attributes:

clientId - we expect up to few events per second for one clientUUID - globally unique Consuming one event takes about 10 milliseconds. Design a consumer of such stream that:

allows processing events in real timeevents related to one client should be processed sequentially and in order, i.e. you can not parallelize events for the same clientIdif duplicated UUID appeared within 10 seconds, drop it. Assume duplicates will not appear after 10 seconds What we came up so far was a combination of thread pools and shared cache. This time we will implement the solution using RxJava. First of all I never revealed how EventStream is implemented, only giving the API:

in…

Small scale stream processing kata. Part 1: thread pools

Once again I prepared a programming contest on GeeCON 2016 for my company. This time the assignment required designing and optionally implementing a system given the following requirements:

A system delivers around one thousand events per second. Each Event has at least two attributes:

clientId - we expect up to few events per second for one clientUUID - globally unique Consuming one event takes about 10 milliseconds. Design a consumer of such stream that:

allows processing events in real timeevents related to one client should be processed sequentially and in order, i.e. you can not parallelize events for the same clientIdif duplicated UUID appeared within 10 seconds, drop it. Assume duplicates will not appear after 10 seconds There are few important details in these requirements:

1000 events/s and 10 ms to consume one event. Clearly we need at least 10 concurrent consumers in order to consume in near real-time.Events have natural aggregate ID (clientId). During one second we can exp…

Guide to time and date in Java

Properly handling dates, time, time zones, daylight saving time, leap years and such has been my pet peeve for a long time. This article is not a comprehensive guide to time domain, see Date and time in Java - much more detailed but slightly, ekhem, dated. It's still relevant, but doesn't cover java.time from Java 8. I want to cover the absolute minimum that every junior Java developer should be aware of.

When did an event happen? Philosophy and quantum physics aside, we may treat time as a one-dimensional metric, a real number value. This value keeps growing when time passes by. If one event appeared after another, we assign greater time to that event. Two events happening simultaneously have the same time value. For practical reasons in computer systems we store time in discrete integer, mainly because computer clocks tick discretely. Therefore we can store time as an integer value. By convention we assign time = 0 to January 1st, 1970 but in Java we increment this value eve…

Functor and monad examples in plain Java

This article was initially an appendix in our Reactive Programming with RxJava book. However introduction to monads, albeit very much related to reactive programming, didn't suit very well. So I decided to take it out and publish separately as a blog post. I am aware that "my very own, half correct and half complete explanation of monads" is the new "Hello, world" on programming blogs. Yet the article looks at functors and monads from a specific angle of Java data structures and libraries. Thus I thought it's worthwhile sharing.

RxJava was designed and built on top of very fundamental concepts like functors , monoids and monads . Even though Rx was modeled initially for imperative C# language and we are learning about RxJava, working on top of similarly imperative language, the library has its roots in functional programming. You should not be surprised after you realize how compact RxJava API is. There are pretty much just a handful of core classes, typica…