23 February 2020

Singleton Spring

Singleton Spring Beans are not like the GoF Singleton design pattern.

 Spring can have more than one if they have different id's; meanwhile, GoF only allows one instance of the class (object) in the complete classloader.

 None option can solve some thread-safe issues that may appear by the composition of other objects that are nor thread-safe, JDBC connections, HTTP session, SimpleDateFormat, etc.

Update:

From that URL:

Summary

Spring Singleton is very different from Singleton pattern. Spring guarantees to create only one bean instance for given bean id definition per container.Singleton pattern ensures that one and only one instance is created per ClassLoader.


20 February 2020

Rules Workflow Constrains

Always there is the necessity to handle workflow, decisions, rules, validations.

The big question is to identify if we build it from scratch or we use different frameworks/tools/enterprise solutions for it.

This is a simple list (among others) of feasible options:

UPDATE:

Bueno yendose a la nube existen varios otras servicios que ofrecen la misma versatibilidad:

  • AWS Step Function.


18 February 2020

AWS development

ir a para lista de servivios AWS

AWS Cloud Development Kit (CDK)
can create infrastructure with CDK and some best practices for creating reusable components.


AWS KCL
Kinesis Client Library
You can develop a consumer application for Amazon Kinesis Data Streams using the Kinesis Client Library (KCL). Although you can use the Kinesis Data Streams API to get data from a Kinesis data stream, we recommend that you use the design patterns and code for consumer applications provided by the KCL.

There are v1 and v2.


AWS SDK for Java
Get started quickly using AWS with the AWS SDK for Java. The SDK helps take the complexity out of coding by providing Java APIs for AWS services including Amazon S3, Amazon ECS, DynamoDB, AWS Lambda, and more.

28 January 2020

Log4j2 Composite config

Composite Configuration

Log4j allows multiple configuration files to be used by specifying them as a list of comma separated file paths on log4j.configurationFile. The merge logic can be controlled by specifying a class that implements the MergeStrategy interface on the log4j.mergeStrategy property. The default merge strategy will merge the files using the following rules:
  1. The global configuration attributes are aggregated with those in later configurations replacing those in previous configurations, with the exception that the highest status level and the lowest monitorInterval greater than 0 will be used.
  2. Properties from all configurations are aggregated. Duplicate properties replace those in previous configurations.
  3. Filters are aggregated under a CompositeFilter if more than one Filter is defined. Since Filters are not named duplicates may be present.
  4. Scripts and ScriptFile references are aggregated. Duplicate definiations replace those in previous configurations.
  5. Appenders are aggregated. Appenders with the same name are replaced by those in later configurations, including all of the Appender's subcomponents.
  6. Loggers are all aggregated. Logger attributes are individually merged with duplicates being replaced by those in later configurations. Appender references on a Logger are aggregated with duplicates being replaced by those in later configurations. Filters on a Logger are aggregated under a CompositeFilter if more than one Filter is defined. Since Filters are not named duplicates may be present. Filters under Appender references included or discarded depending on whether their parent Appender reference is kept or discarded.

14 January 2020

lsof tips & tricks

lsof is a command meaning "list open files", which is used in many Unix-like systems to report a list of all open files and the processes that opened them. This open source utility was developed and supported by Victor A. Abell, the retired Associate Director of the Purdue University Computing Center.

pid from port
lsof -i @192.14.166.72:20000

open jar files:
lsof -p | grep jar

Get the list of files opened
lsof –p

Get the count
lsof –p | wc –l

pid listening tcp at specific port:
lsof -i tcp:8888
lsof -i:22


From gist

#list all ports for tcp
sudo lsof -itcp

#find all things listening on ports
lsof -Pnl +M -i4 | grep LISTEN

#all ports for tcp, dont resolve port name from numbers
sudo lsof -itcp -P

#open files and ports of process #$PID
sudo lsof -p $PID

#only ports of tcp for process #$PID, dont resolve port name, dont resolve ip name
sudo lsof -a -p $PID -P -n -itcp

#only ports of tcp for process #$PID, dont resolve port name, dont resolve ip name, refresh every 5 seconds
sudo lsof -a -p $PID -P -n -itcp -r 5

#search by file (can be slow)
sudo lsof /complete/path/to/file

Blog Archive

Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.