Monday, September 27, 2021

How equipped your application is with Alerting

 There are various ways , the application can notify a set of recipients based on the error catrgories.

  •  Spring email: configure logback xml
  • Sending via  java mail api 

Thursday, September 23, 2021

Retryable Programming

 Spring retry is one of the implementation in Retryable Programming.
Code snippet:
Foo foo = template.execute(new RetryCallback<Foo>() {
    public Foo doWithRetry(RetryContext context) {
        // business logic here
    },
  new RecoveryCallback<Foo>() {
    Foo recover(RetryContext context) throws Exception {
          // recover logic here
    }
});
When the retry attempt is exhausted, the RetryOperations kicks off and it passes the control to a different callback, called the RecoveryCallback.

@Retryable(value = { SomeServerException.class}, maxAttempts = 3, backoff = @Backoff(delay = 2000, maxDelay=5000))
public void doSomething( arg1){
}

  @Recover
    public void recover(SomeServerException e, arg1){

}

Note: I. @Retryable should be invoked from some other bean.
          II. The method doSomething and recover should be a public method.



Wednesday, September 22, 2021

Application Memory Optimisation

 An application must be set with enough memory to be able to function as per the SLA. It should not be under or over utilised.

Things to be considered while setting up memory :

-Review the static and cached objects.

-Apply chunking instead of many items together.

-Apply common thread pooling to control the load

-Use fault tolerant library link resilency4j, circuit breaker etc.

-Have cloudWatch alarm setup tuned with read/write usage.

Thursday, September 2, 2021

Shell Scripting Essentials

Redirect stderror to output

$ cat foo.txt > output.txt 2>&1  // 2 stderror, &1 std output

cat nopx.txt > outputx.txt 2>&1 

// since there is an error the error will get redirected to outputx.txt


Command chaining &&


ls -ltr && mvn test && mvn deploy


Git shell coloring

# Regular Colors

Black="\[\033[0;30m\]"        # Black

Red="\[\033[0;31m\]"          # Red

Green="\[\033[0;32m\]"        # Green

Yellow="\[\033[0;33m\]"       # Yellow

Blue="\[\033[0;34m\]"         # Blue

Purple="\[\033[0;35m\]"       # Purple

Cyan="\[\033[0;36m\]"         # Cyan

White="\[\033[0;37m\]"        # White

More: https://gist.github.com/vratiu/9780109