Burak Aktas Software Engineer

Spring Shedlock Tutorial

I talked about how to create a scheduled job in this post. Most of us probably faced with a use case to make only one specific cron job to run at a time in a distributed environment. For example; we don’t want to run multiple cron jobs to send same email to customers or charging them multiple times. To avoid this we have to find a way to make a cron job run only in one instance. For this we will walk through how to use Shedlock which provides a distributed lock mechanism for cron jobs. Well for this we also need to have a database so I will use MySQL in this example to run locally.

AWS CI/CD CodePipeline with Blue/Green Deployment

We will walk through how to create a CI/CD pipeline in AWS. Basically, CI/CD stands for Continuous Integration/Continuous Delivery which means whenever we push a new code change our pipeline will build the project, run the tests and deploy the new changes. In this tutorial we will use 4 AWS components;

  • CodeCommit for code repository
  • CodeBuild for continuous integration service to build and test our sources.
  • CodeDeploy for continuous deployment to deploy new changes into our compute services which we will use Amazon EC2.
  • CodePipeline for combining CodeBuild and CodeDeploy components to build a CI/CD pipeline.

Spring Security with JWT Tutorial

In this tutorial we will learn how to implement secured APIs in Spring Boot with using JWT tokens. First of all, we have to understand what is a JSON Web Token (JWT).

JWT is an open standard (RFC7519) to share information between entities in a JSON format. It is digitally signed thus it can be verified by entities. It is not encrypted but encoded which means if the man in the middle gets the token then it can be used for accessing secured resources. Because of this it shouldn’t contain any critical information like password, credit card number etc. This can be prevented by encryption with TLS or you can basically choose to encrypt JWT as well which is optional.

Initial Guide to Deploying Docker Containers into AWS ECS

In this tutorial we will walk through how to deploy simple docker containers into AWS ECS. ECS is a container service to deploy and manage your Docker containers on AWS. Basically, there are two types to deploy containers on ECS clusters which are;

  • EC2 instances
  • Fargate (Serverless)

We will use EC2 type container instances. Before starting there are some components specific to ECS terminology which we need to understand;

  • Task Definition: JSON|YML based configuration file. In other words recipe or blueprint of your containers. We give parameters like Docker Image, CPU, Memory, Network Mode for one or more containers. You can think of it like a Dockerfile.
  • Task: An instance based on given Task Definition. This is the Docker container which can contain one or more Task Definitions.
  • Service: Allows you to create and maintain a number of tasks (containers) including their lifecycle and deployment properties from same Task Definition.
  • ECS Container Agent: A service (docker container) that manages the connection between ECS cluster.
  • Cluster: Group for defining container instances. It can be either group of EC2 instances or a Fargate type cluster which is serverless.

Spring Schedule Tutorial

In this tutorial we will walk through how to implement and define crob jobs with a schedule behind of it in Spring Framework. Generally, in software architectures we want to have some background jobs to do some processing, aggregating or even just fetching some data and streaming them. Instead of implementing separate cron jobs and managing them as a separate application we can create and maintain cron jobs in same spring application with using @Scheduled annotation. Generally, all the scheduled tasks will run on the same thread which means when current task is being processed others will get blocked and has to wait current thread to finish. However, this can be configured by implementing our own ThreadPoolTaskExecutor to assign a thread pool. So that each task will run asyncrohonously.