Posts

Using a ReturnValueHandler to adapt RxJava Observables to Deferredresult in a SpringBoot micro service

If you look at my previous blog posts related to RxJava and Spring Boot microservices you may notice that all the subscriptions to the RxJava Observables are made in each and every controller method and controller method is responsible for the transformation between RxJava Observables and Spring aware DeferredResults. This is obvious one to one mapping that you can do between RxJava and Spring. In fact you can go further and generalize this behaviour. This will eliminate lots of boilerplate code in your application and make your code much more simple and readable. Also this brings a good software engineering practice called generalization and reuse into our code. Take a look at the following controller code before adding the return value handler. We can use a simple ReturnValueHandler that calls an adapter[Gamma95] that will adapt Observables to DeferredResults. By registering this value handler with Spring, all the methods that return an Observable will be reworked into returning a ...

Combining the emissions of multiple Observables together using RxJava Zip operator in a Spring Boot Micro service

Image
Introduction Well, today we are going to discuss an advanced RxJava operator called Zip. Let’s first take a look at the zip operator at a glance and then move on to a real world example that leverages the capabilities of the operator. In fact, zip is a very powerful and useful operator provided in the RxJava library. Prerequisites : Good knowledge of Java8, Functional Programming, RxJava, Spring Boot, Microservices. User Level : Advanced Since this is an advanced article, I am not going to walk you through the basics of RxJava or Spring Boot microservices. If you need to get some basic understanding of RxJava, I thoroughly recommend you to go through one of my previous blog posts [1] [2] or any other good introductory article about RxJava. If you need to learn more about Spring Boot microservices please go through some of the spring tutorials which are really comprehensive and impressive. RxJava Zip Operator Combines the emissions of multiple Observables together via a speci...

Introducing Java Reactive Extentions in to a SpringBoot Micro Service

Image
Introduction Today we are going to take a look at Reactive Programming using Java8 and RxJava, which is a library for composing asynchronous and event-based programs by using observable sequences. RxJava stands for Reactive Extensions for the JVM. It extends the observer pattern [Gamma95] to support sequences of data/events and adds operators that allow you to compose sequences together declaratively while abstracting away concerns about things like low-level threading, synchronization, thread-safety and concurrent data structures [1]. Pre-Requisites : Having a good knowledge about Java8, Functional Programming and spring boot microservices. What is Reactive programming? In essence, Reactive programming is an asynchronous programming paradigm concerned with data streams. The system time, a list of entries from the DB/API, user clicks, everything can be a stream of data. Data from different streams can easily be combined and transformed, and in the end processed/observed by the ...

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) ...

Preventing XSS and CSRF vulnerabilities in WSO2 ESB

INTRODUCTION In this article I will explain you how to prevent Cross Site Scripting and Cross-Site Request Forgery (CSRF) attacks in WSO2 ESB. First let me explain you what are those vulnerabilities. What is XSS Cross Site Scripting (XSS) is a client side code injection attack where an attacker can execute malicious scripts into a legitimate website or web application. XSS is a very common vulnerability exists in web applications and occurs when a web application makes use of unvalidated or unencoded user input within the output it generates. For an example an attacker can inject a malicious script into an input textfield of your web application, and once the form is submitted that malicious script get executed, leading to catastrophic consequences. What is Cross-Site Request Forgery (CSRF) CSRF is an attack that tricks the victim into submitting a malicious request. It inherits the identity and privileges of the victim to perform an undesired function on the victim...