If you saw the following error, chances are you need to increase the bufferSize in your client.yml file. The default is 24 which is 24k bytes. It should be OK for small applications, but for bigger request body, you need to increase it to 100 or even 1024 for one of our customers.
java.io.IOException: overflow at io.undertow.protocols.ssl.SslConduit.doWrap(SslConduit.java:903) at io.undertow.protocols.ssl.SslConduit.doUnwrap(SslConduit.java:671) at io.undertow.protocols.ssl.SslConduit.read(SslConduit.java:567) at org.xnio.conduits.ConduitStreamSourceChannel.read(ConduitStreamSourceChannel.java:127) at io.undertow.client.ALPNClientSelector$2.handleEvent(ALPNClientSelector.java:87) at io.undertow.client.ALPNClientSelector$2.handleEvent(ALPNClientSelector.java:77) at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) at org.
Read More »
Most of us know how to create a response example in OpenAPI 3.0 specification in order to allow the light-codegen to generate the example output out of the specification. When dealing with array response, a lot of people don’t know how to write the specification to do so. Here is an example and the service is used to test light-router.
responses: '200': description: Successful response content: application/json: schema: type: array items: $ref: '#/components/schemas/KeyValue' example: - key: key1 value: value1 - key: key2 value: value2 The full specification can be found at https://github.
Read More »
While working on KVM virtual machines, I once locked out of the guess VMs due to ufw enabled and I forgot to allow port 22. After my session is timed out, I cannot connect to my VMs through SSH anymore. The following is the steps to gain access to the VMs and then enable SSH to access them.
Gain Console Access to VM Since SSH is blocked by the firewall on the VM, we have to find another way to connect.
Read More »
When using an event-based framework, we need to use MySQL Binlog library to connect to MySQL server to access the trailing transaction log. To make the connection secure, TLS will be used by the client.
If you have a DBA install the MySQL instance for your application, you can ask for the client certificate from him/her. However, if you are using MySQL docker for your testing, you need to get the client certificate from the docker container.
Read More »
Issue We were asked by one of our customers if our messaging based framework can utilize Oracle Streams instead of GoldenGate which requires a separate license.
After several days of investigation, we don’t think Oracle Streams is working in this use case.
Oracle Stream The Oracle Streams does not fit our CDC solution. It can capture the data change to the queue, but the queue is oracle database queue.
Oracle Steams use Oracle ANYDATA queue for the message store.
Read More »
How many cross-cutting concerns need to be implemented in order to bring services built with other frameworks or languages into light ecosystem?
As of today, Light only supports Java but some big customers have multiple LOBs with different preferred languages or frameworks. We were constantly asked how to bring services built with other languages or frameworks to the light ecosystem so that these services can interact with each other.
We have a long term plan to provide Nodejs, Go, DotNet Core and Rust frameworks but it will take time.
Read More »
Self-signed vs CA-signed certificate In Light, two places use certificates to ensure security for microservices:
TLS connection
JWT verification
A lot of questions have been asked on when to use a self-signed certificate and when to use a commercial CA-signed certificate. And here is the guideline from a purely technical perspective.
If the service is exposed to the Internet, you have to use a CA-signed certificate It will make your service trustful and simplify the client side development as they don’t need to include the service public certificate to verify the server certificate.
Read More »
The major difference is Spring Boot is based on servlet container and it is blocking and light-4j is based on non-blocking Undertow core. That is why there is huge gap in performance.
As this benchmark shows one light-4j instance can complete with over 100’s Spring Boot instances for the same throughput and latency not even counting SpringBoot uses 5 times more memory per instance. If you have too many services, then production cost will be significantly different.
Read More »
light-4j is a platform or ecosystem for building and running cloud native microservices. The design goal is higher throughput, lower latency and smaller memory footprint to lower production costs.
It contains the following:
Cross-cutting concerns All light-4j frameworks are built on top of an embedded gateway to address cross-cutting concerns for cloud native services within the request/response chain. These plugins or middleware handlers are wired in with IoC service during server startup and can be enabled or disabled or change behaviors via configurations.
Read More »
How to customize the output format for Error Status response Light-4j Status module is an object that models the error response and is constructed from error code defined in status.yml config file. The framework provides some error code and we are expecting the API itself provide some service specific error code. For more detail on the Status module, please check the cross-cutting concerns section.
The default output of error status is a JSON string with several properties flattened in a map.
Read More »
As most modules in light-4j have a config file, there are different options available to change the behaviour of the module through config. When writing unit tests, we want to test the module behaviours in different configurations.
The config module supports loading config file from module local, application, classpath and system property specified directory. The following example will construct and load different config files in each test class.
The entire code can be found status test folder
Read More »
How to serve Single Page Application(React/Angular etc.) from your API server instance During development, we normally use Nodejs to serve the single page application as it is easy to package and test/debug. However, during production, it makes sense that the API server serves the single page application by itself. In this way, we don’t need to enable CORS handler and same another instance of the server.
To learn how to use Nodejs for Single Page Application development, please take a look at https://github.
Read More »
How to compress the response with gzip For some of the API endpoints, the response bodies are big and it might be necessary to compress it before return it to the client. Undertow has a built-in EncodingHandler that can be utilize for this.
Here is an example with customized path provider.
public` HttpHandler getHandler() { return new EncodingHandler(new ContentEncodingRepository() .addEncodingHandler("gzip", new GzipEncodingProvider(), 50, Predicates.parse("max-content-size[150]"))) .setNext( Handlers.routing() .add(Methods.GET, "/v2/fronts/{front_id}", new FrontGetHandler(Config.getInstance().getMapper())) .
Read More »