18 December 2016

Few points about Micro-services architecture


Micro-services are not meant to be scaled down version of SOA (Service oriented architecture). They should be based on business context and should not be created based on technical refactoring viewpoint.

Ideal platforms for microservices would be cloud were you can easily scale any one component we want. Example if we notice that one business component (say UI) need support 1000 instances and rest every thing can be 1 or 2 instances then decompose the UI component into a microservice

Cloud platforms and dockers are good area to experiment with micro-services as scaling, and management of  multiple versions can be easily accomplished there.

Few no's for microservices -
  • No clustering should be planned
  • Try to make integrations independent of programming language (rest, http, xml)
  • Avoid single database for multiple microservices

Finally one word of caution, managing multiple microservices is very important. Otherwise after 5 to 6 microservices people loose track of which version is integrated to what.

09 December 2016

jQuery data-table with features similar to excel

Recently in one of our projects, we were looking for a jQuery data-table with basic features similar to excel viz. -

  • Navigate from cell to cell in a row using right arrow/tab 
  • Enable cell edit key press after selecting the cell 
  • Enable auto suggest based on the existing data in the column 
  • Enable copy of cell and paste to another cell 
  • Enable drop-down  to chose values rather than free text 
  • Enable column freeze 
  • Enable column wise filters
While researching for it, we found few useful components that provides these functionalities. 

  1. Slickgrid jQuery plugin
  2. Handson table
  3. JQGrid
Hope this will help in any teams looking for data-tables with similar functionality.




30 November 2016

Best practices for Enterprise level logging

Unless mandated by business requirements, all the log statements should be at minimum logging level. The idea is to reduce the logging overhead as much as possible. Sometimes the overhead is significant to impact application performance.

Use asynchronous logging wherever possible.

Use file rolling and archiving features of the logging framework instead of re-inventing the wheel.

It is a practice among developers to log method entry/exit for troubleshooting. This kind of logging should be done using AOP framework such as Spring AOP, and at debug/trace level. A better practice will be log at only those places where there is a significant processing/turning point.

Do not log any kind of sensitive information such as passwords, credit card numbers, national ids, Personal Identifiable information etc. which could lead to privacy and security issues.

Do not hard-code any credentials (e.g. database credentials when doing database based logging) etc. in logging configuration file.

Do not log huge payloads (such as SOAP request/response etc.) in production but log the important details going out and coming in.

Benchmark the log file growth as per production peak volumes and identify storage requirements (SAN/NAS).

Check regulatory/enterprise guidelines (if any) for the retention period of logs. Device the backup/archival/purge policy accordingly.

Suggest use of log analysis tools such as Splunk or ELK stack for monitoring, troubleshooting, quick searches, dashboards etc.

Secure the log files/sources from external access.

Design a new Framework or Use Existing Framework with a wrapper that can help you capture details better.

Make sure the exception or event is logged only at source. Most of the times, every component participating, in the process, logs the exception/event . This not only leads to unnecessary logging but also sometimes logs incorrect information for tracing the issue.

Have a unique event ID(within application & combination with an application id should make it unique across applications) for every Exception/Process/Event so the Support Group can triage, without much hassle.


18 November 2016

Test SMTP server for DEV/Testing

Many times we face problem testing email settings/code in our development environment if we don't have a SMTP server in our development environment.

There is a easy solution for it.

Use dummy SMTP server - SMTP4DEV available in CodePlex at following location -

http://smtp4dev.codeplex.com/

Once it is launched, it sits in your system tray and listens on port no. 25 of your localhost (127.0.0.1) server. This helps in receiving and viewing messages and verifying their format/structure.

It however cannot be used for sending messages.

Detailed instructions for installing and using this nifty tool can be found at its CodePlex location.



30 September 2016

MSDN Subscriptions is now Visual Studio Subscriptions

From Oct 4, 2016, MSDN subscriptions will be re-christened as Visual Studio subscriptions.

After 4 October 2016, you need to go to the new Visual Studio Subscriptions portal to access your subscription.

Please note that you will have no access to the current MSDN Subscriptions portal between 9:00 pm (PST) 3 October and 9:00 pm (PST) 4 October, while we complete the migration.

In case of any questions, check the FAQ or contact Visual Studio Customer Service

27 September 2016

Tech Trivia


  • The word 'Robot' comes from Czech word 'ROBOTA'. In English, it translates to 'forced labor'. 
  • A Red Panda is an animal native to the Himalayas and Southwestern China. The English word for Red Panda is Firefox which is where the browser gets its name from. So the Firefox Logo is actually a Red Panda and not Fox as thought by many (including me!).
  • Android is Andy Rubin who is the co-creator of Android. It was a nick-name given to him at Apple before he joined Google, for his obsession and love for robots.
  • Creators of PNG file format wanted it to be pronounced as PING.
  • Nothing can be compared to the human mind. If a computer is designed which is as powerful as the human brain, then it would be able to perform about 38 thousand trillion operations per second. Also, it will be able to hold about 3584 terabytes of memory.
  • HP, Microsoft & Apple have one not so obvious thing in common - they all started in a garage.
  • If you find a security bug in Facebook, they are willing to pay money ($500 and upwards) for you to tell them about it.
  • 160 billion emails are sent daily, 97% of which are spam.
  • Wikipedia uses an army of anti-vadal bots. These bots prevent vandalism of wiki pages. As per them, vandalism is anyone signing up and editing pages with an intent to destroy or alter content in a negative manner.
  • Ubuntu is one of the most popular distribution channels of Linux. The word Ubuntu comes  from the African word meaning 'I am because of you'.
  • The actual name of Android mascot is 'Bugdroid', though it is not official, the team at Google refer to it by this name.
  • The first known cell phone virus, Cabir.A, appeared in 2004.

26 September 2016

C# - Serialize Object to XML HttpResponseMessage

Sometimes we have an explicit requirement to serialize a C# object to XML HttpResponseMessage format.

This generic function can be used to achieve this conversion -

public static HttpResponseMessage CreateXmlResponse<T>(T objectToSerialize)
{
    return new HttpResponseMessage(HttpStatusCode.OK)
    {
        Content = new ObjectContent<T>(objectToSerialize,
                                        new System.Net.Http.Formatting.XmlMediaTypeFormatter
                                        {
                                            UseXmlSerializer = true
                                        })
    };
}


The function takes an object of type 'T' as input and serializes it using XMLMediaTypeFormatter XML serializer available in .NET namespace System.Net.Http.Formatting.

A sample function call be like this - 

var response = CreateXmlResponse<ObjectClass>(object);

19 September 2016

C# - Convert JSON string to JSON HttpResponseMessage

Use following method/function to convert string having JSON data to JSON HttpResponseMessage -

public static HttpResponseMessage CreateJsonResponse(string json)
{
    return new HttpResponseMessage()
    {
        Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json")
    };

}

Following code can be used to call this method/function

var response = CreateJsonResponse(jSonString);

Following code can be used to call this method/function

12 September 2016

Convert time-stamp in UTC format to local date time

Some times it is required to convert a time-stamp in UTC format to your local system data time.

A UTC time-stamp format looks something like this - 2016-08-23T11:59:00Z

This time-stamp is in UTC zone and following C# code can be used to convert this into local date time. As an example, here I am converting it to 'Central Standard Time (CST)'. Depending on your time zone, you can pass a different value.

public static string GetLocalDateTime(string timeStamp)
{
    TimeZoneInfo cstZone = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
    DateTime cstTime = TimeZoneInfo.ConvertTimeFromUtc(Convert.ToDateTime(timeStamp), 
                                                       cstZone);
    return cstTime.ToString();
}


An example call will be - 

var localDateTime = GetLocalDateTime("2016-08-23T11:59:00Z");


Output will be -  8/23/2016 6:59:00 AM

06 September 2016

Options for SMS solution

One of our clients had the following requirements around their SMS solution:-

1.       SMS Authentication
2.       SMS Sales (Ordering pay per view / adding balance)
3.       Alerts and notifications

They were currently using a messaging platform which was very specific to a particular country. To reduce the overall cost, they were looking at other solutions and wanted to make use of the open source solutions in this space to replace the their existing solution. They were interested in building a custom solution and paying to the network carrier for billing rather than using a 3rd party off the shelf solution.

We performed study and comparison of various open source and COTS SMS Gateways. Found this article useful in comparison -

http://socialcompare.com/en/comparison/sms-gateways-1odvv6xv

The final solution recommended was Kannel. It is one of the highly scalable and efficient open source SMS and WAP Gateway solution that majority of the Messaging Providers uses in their suite. It is based on C technology and supports connectivity to various SMS Centers. It also provides HTTP based API for integration with other business suites for sending and receiving messages.

Hope this helps someone who is looking for similar comparison and solution.