Posts

Showing posts from 2016

Introducing Java Reactive Extentions in to a SpringBoot Micro Service

Image
Today I am going to teach you about RxJava, which is a new programming paradigm to do asynchronous programming easily. RxJava stands for Reactive Extensions for Java. Writing a blocking code is evil and deteriorates the performance of your application. So we should focus on writing asynchronous code which never keeps you blocking. There are two approaches to writing asynchronous code, one is using callbacks the other is using RxJava. Callbacks has low composition and lead to callback hell if you have many callbacks back to back. The code becomes more and more complex. That is where RxJava comes to our rescue. RxJava was a project that has been open sourced by the Netflix.




In RxJava Iterators and Iterables become Observers and Observables. Iterable and Iterator is a pull model. In RxJava Observable and Observer is a push model. Push model is preferred over the pull model. You will subscribe to a stream and you will receive notifications. The source will notify you when it emits new item…

Streams and LambdaExpressions in Java 8

Introduction Typical processing patterns on collections were very hard up until Java 8 introduced a new abstraction called a Stream. Stream operations are chained together into pipelines. Other than that lambda expressions (JSR335) facilitate functional programming and simplifies the development a lot.
Workshop For an example consider the following real world use case. Suppose we have university system where an instructor can deliver questions (multiple choice) to students. Then students start responding the question with answers. The instructor needs to find following abstract information out of all the responses.
Percentage of correct responses. Assuming that the multiple choice question has four answer options, how many students have chosen each option.
If you implement this by following orthodox way, you may end up with many lines of code  blocks. That’s where Java8 comes to the rescue. By combining Java8 streams and lambda functions you can write each usecase in one single line of cod…

JMS 2.0 Support in WSO2 ESB

Image
Introduction JMS is a messaging API implemented to communicate between two or more java clients using an enterprise messaging system. Java client components can use JMS API to communicate with other distributed Java clients while maintaining a loosely coupled, asynchronous connection. Therefor JMS API is well known and most often used as a message communication methodology.

JMS 1.1 was introduced in 2002 and it remained unchanged until 2013, wherein the JMS 2.0 was introduced. In order to cater for todays message communication requirements, JMS 2.0 address many issues and shortcomings that was there with 1.1. Mainly JMS 2.0 introduces a simplified API in order to reduce the amount of code that needs to be written by the programmer. Even though the code lines are reduced, all the classic API functionalities are still available with JMS 2.0 simplified API. ( with JMS 2.0 programmer can decide which API to use classic or simplified, because both are available with JMS 2.0) But more than th…