Saturday, December 27, 2014

Using Spring Batch to Read, Process and Write Entities in Mongo

Almost all of the enterprise applications require bulk processing to perform business operations in mission critical environments. These business operations include complex processing of large volumes of data at regular intervals without requiring any user interactions. Some Examples are Month-End Calculations, Quaterly Rollups, Data Migration and various other operations. 

Introduction
Spring Batch is an open source framework for batch processing – execution of a series of steps. Spring Batch helps developers to concentrate on business logic and framework takes care of the entire batch infrastructure.  
This example demonstrates use of Spring Batch with MongoItemReader and MongoItemWriter to read data from MongoDB, Process it and write back to Mongo DB.


Photo credit: Spring Source

Saturday, November 15, 2014

Implementing Token based Authentication and Form Authentication using Spring Security

In today's world, where technological ecosystem has developed so much that no system can work independently. Systems are integrated together to work in tandem and serve value to their users. Rather than users going to several systems to gather information, the concept has evolved to integrate all the required system together and present the information in simple consumable form for the user. Due to this paradigm shift, the systems are developed using Service Oriented Architecture (SOA). They expose services for their consumers to get information from the system without involving any complexity of integrating two heterogeneous systems.

Background

The systems will have their regular login form for allowing users to login directly into it and get the required information. Along with this, the information retrieval can also be automated using APIs (REST, SOAP etc) and these APIs must be secured to allow authorized access.This post would demonstrate how Spring Security can be used to setup Form Authentication as well as Token based Authentication for REST Services. Here, I am making REST APIs as stateless endpoints and hence every access to APIs would be sending an authentication token along with it.

Saturday, November 1, 2014

Publish and Consume messages to RabbitMQ with Spring AMQP

Earlier in this post, I have demonstrated publishing and consuming messages to RabbitMQ message broker using RabbitMQ client library. When we are working on application which uses Spring framework, it makes sense to use spring-amqp library instead. However, it is not to say RabbitMQ client library cannot be used with Spring. Using spring-amqp offers advantages of loose coupling with message broker which enables to switch from one Message Broker to another without any major changes in the code.

Monday, April 14, 2014

Integrate External App with Salesforce using Canvas API

If you are using Salesforce extensively and also other internal/external applications to aggregate all the information to take a decision, Salesforce's Canvas API is one of the best ways to ensure, your people have all the data available at their disposal in a single interface rather juggling with several systems and arrive at a decision. 
Force.com Canvas is a mechanism for consuming third-party applications within Salesforce. Its goal is to connect applications at a UI level instead of just an API level

A little background... 
Canvas framework is a set of tools and JavaScript APIs that can be used to expose an application (written in virtually ANY language) as a canvas app. This means you can take your new or existing applications and make them available to your users as part of their Salesforce experience. However, the external application needs to follow two guidelines:
1. It must be a web application.
2. It must be https compliant.


External App embedded within Salesforce using Canvas
Fig: External App embedded within Salesforce using Canvas

Monday, March 10, 2014

How to set CreatedBy, CreatedDate, UpdatedBy, UpdatedDate and Version Audit entities for MongoDB documents?

It is a common programming practice to have audit fields associated with each document which helps in determine the basic information like when document was last created or modified and who did it. This information proves to be very crucial piece of information available while troubleshooting a problem.
Stamping each document with these information in different collections becomes tedious and repetitive. This topic covers how can we use Spring framework to auto populate these fields and developers just need to focus on the other important fields within a document.

A little background... 

We will use Spring Data MongoDB in the example to integrate with MongoDB. MongoDB is a scalable, high-performance, Document Oriented NoSQL database. 
A model can be made Auditable by one of the following ways:
1. Using @CreatedBy, @CreatedDate@LastModifiedBy, @LastModifiedDate and @Version annotations defined in package org.springframework.data.annotation.
2. Model implementing org.springframework.data.domain.Auditable interface. Auditable is an interface that defines all required properties for auditing an Entity, it is inherited from Presistable interface.
In this article we will focus on using Annotations for populating the audit fields.


Figure: Class diagram for Audit Entity

Thursday, February 27, 2014

How to Publish and Consume messages using RabbitMQ?

With the evolution of distributed computing paradigm, often the processes are running on different physical platforms. However, as the processing becomes distributed, you start worrying about how the systems can be connected together. This elicit the need for a reliable communication mechanism which can send messages between discrete components of an application. Hence, Message Queues are developed which act as a broker that facilitate message passing which other services can access. 
In this topic, we will develop a small Producer-Consumer application using RabbitMQ.

A little background...

RabbitMQ is open source message broker solution that implements Advanced Message Queuing Protocol (AMQP).


Message Broker
Communication flow using a Message Broker

Tuesday, February 11, 2014

How to build a voice application using Twilio?

This topic talks about step by step process to build a voice application using Java and Twilio. In this blog, we will see how to make a call to another phone number using Twilio and also convert browser as a phone and start receiving calls on browser.

A little background…


Twilio is a cloud communications company which provides Web APIs to build voice, VOIP and SMS applications. In this post, we will cover how to use these APIs to make an outbound call and start conversation.

Twilio handles call instructions in realtime using TwiML(Twilio Markup XML) hosted as a Web API. 


Twilio-Outbound-Call-Flow
Figure 1: Outbound call flow using Twilio