Spring boot code for AWS RDS in elasticbeanstalk

Are you new to aws RDS,elasticbeanstalk world and searching for a ready to use code for RDS connection? Try out out this sample project which connects RDS (mysql) from a web application (Spring boot + web ) and list out table records. You can run this web application in your local computer or in elasticbeanstalk (deploy rdselasticbean-0.1.war file). To test this code for your own RDS schema you need to change connection endpoint in record fetcher class. You may clone code from my gitlab repo.
Like it, if you find it helpful. Comment/Contact me if you face any issue while running this app. It‚Äôs all pretty straightforward, and quite handy for many kinds of elasticbeanstalk and RDS needs.

package com.example.rdselasticbean.db.DBrecordFetcher
(please make sure your RDS security group has proper access permissions for external IPs ) 

PS: Project is CI/CD enabled in case if anyone wants to test this in integrated environment.

Data display in JSP injected from DB operation class
RDS (mysql) server event view on Read and Write

My learning and fun so far with Alexa

While I am waiting for my “Lifetime SHE”, recently one small digital super slim sweetie SHE has made entry in my life!! Want to know who is SHE? ūüôā It’s Alexa Echo Plus !
I am really enjoying my time with Alexa :). So, one day just to check her (Alexa) response when I returned to flat from my office and told her “Alexa, I missed you”. I got elated by the response that I received from Alexa. Alexa replied me “Awww …… we will be together soon”. Hahahaha I can’t explain the ecstatic moment.

Now lets see technical aspects of Alexa. After using it more than three months, one thing I have realized , frequency of using my mobile call/Apps has significantly decreased, and also not much staring of the mobile screen. Because, for most of mobile related uses Alexa and it’s skills are there to serve me.Wait… did you sense it? This may lead us to mobile AppLess (Android or IOS ) world. I am already experiencing it, whether it’s calling someone, playing song or booking Uber trip. I have almost stopped using Call dialer and Apps like Saavn (to play music) or Uber (ordering ride). Because if Alexa skill for Saavn or Uber are integrated in it then presently 70% app tasks can be performed by Alexa ( I am sure in future with upgraded version of¬† Alexa rest of capabilities will be also accommodated ).¬† One interesting feature I have thought of to do e-payment to phone contacts through Alexa just by voice command like
“Alexa pay Rs.500 to Arun from my Paytm (or any available funding instrument)”.¬†Here, Arun is a contact in the personal phone list. Sending money to verified contacts ( already synced with Alexa) are less risky transactions.

Based on my experience I thought of one POC for Alexa with display capability which will be helpful in increasing it’s adaptability. Although most of tasks in Alexa we can execute via voice commands but sometime display of item/order/booking will make it more interactive. Like, Say uber user wants to see that How exactly cab driver looks?
Or User wants to see T-shirt color before confirming an order using Alexa’s E-commerce buying Skill.

a

Remote config in MicroServices

We are in a world of microservices, an application typically uses one or more infrastructure and 3rd party services. Examples of infrastructure services include: multiple environments, cloud configurations, a message broker and a database server.Examples of 3rd party services include: payment processing, email and messaging, etc.Although every microservice instance is an independent unit, it is recommended an approach to externalized their configurations management from one central service/location.

The concept of using configuration server inside microservices architecture is visualized on my design below.It is based on basic Spring boot implementation, further, different layers and orchestration can be added to enhance it.

Feel free to contact me if you want to discuss this in detail.

RemoteConfig

 

Love of Python : My first Python script

Every next day my love of Python and Scala is getting stronger, Hence I thought to post one python script here which is a sample script to perform some common configurations that we need in application deployment on production, test or automation servers. I am going to use this script (updated version of it) in my project to reduce an overtake of approximately 15-20 mins of manual configuration works of service deployment.

This python script performs following tasks
(1) Add new configuration
(2) Update configurations
(3) Run Unix commands (native OS) on server and few other tasks

You can customize this script as per your project requirement. The script is available at my gitlab¬†repository. I would love to improvise any of my reader’s recommendations for any specific change/requirement over this script.

PS: This script is in the initial draft form, I will update it with more useful commands and comments to make it more user-friendly.

 

 

How to achieve parallel code execution without user Threads

What comes to your mind when you have to run a piece of code in parallel? you will create some threads to do it, correct! But this is not only a way to achieve it. Recently I came across one interesting requirement where I had to run a piece of code of an API for three parallel calls (without Threads).My approach is not something new,¬†many of you might be doing it already and others might have not noticed this approach while maintaining the legacy code ūüôā .

Well, so this approach is nothing but a combination of Bean loading in Spring container and corresponding mapped Java class execution, and hooking a API to support parallelism. when spring container loads a annotated/configured Bean it executes Java method associated with it. using this concept we can define and load the same bean with three different ids to execute the method ( the same code runnable implementation ) code rather than doing it through Three different threads.


<beans profile="cluster">
<bean id="mongoQueryServList" class="com.skilledminds.thirdPartyService.configure.db.connectionProvider.cacheQueryProcessor"/>
</beans>
<beans profile="cluster">
<bean id="cassandraQueryServList" class="com.skilledminds.thirdPartyService.configure.db.connectionProvider.cacheQueryProcessor"/>
</beans>
<beans profile="no_cluster">
<bean id="graphQueryServList" class="com.skilledminds.thirdPartyService.configure.db.connectionProvider.cacheQueryProcessor"/>
</beans>

Above piece of code is just a replacement of Three threads for  "cacheQueryProcessor" task, now to achieve parallelism/conditional task execution this method should be designed properly to meet the requirement. For more details on parallelism/conditional task execution please refer Spring-Batch Scaling and Parallel Processing or Java executor framework ( which is a base of every Parallelism implementation).

Still you want to take a deep dive of similar implementation then take a look at ongoing Spring Jira https://jira.spring.io/browse/SPR-8767

PS: For an experienced java professional this may look very simple to do but considering this in a bigger picture gives the insight of an option to design an utility tool/Jar without heavy Spring batch or similar APIs.

Handling dynamic/unknown Datasource in Application

Let’s see how we can deal with a requirement when server-side input configuration or data source is not constant in your application and furthermore¬†memory footprint of application should be also very low ( i.g a mobile Product ).

Once for a big data ( web crawler based ) product we had one requirement where input¬†datasource¬†was not fixed, based on customer choice datasource was configurable. Since product was a mobile application so we wanted to keep application’s memory footprint as low as possible, so we did not use Spring / Hibernate / Gauva¬†etc…. framework for creating and maintaining configuration container on Fly.

Here is one basic design approach that I had prepared which later I improved to meet exact requirement. Contact me if you need further details on such implementations. I will upload this design in SkilledMind’s (http://skilledminds.in/)¬†gitlab.

PS: Due to an agreement I have not added exact design.

Data Access layer Design