HNHacker News
TopNewBestAskShowJobs

jeyjeyemem

18 karma · joined January 2, 2018

submissionscomments
jeyjeyemem··on Show HN: Externalized Properties, a modern Java configuration library
You can still strictly adhere to section III if you choose to - by only loading the environment variables, but Externalized Properties allows more than that if needed.

By using ExternalizedProperties instead of direct System.getenv() you get other useful features such as automatic conversions, variable expansion, and processing (e.g. automatic decryption/automatic base64 decode, etc)

jeyjeyemem··on Show HN: Externalized Properties, a modern Java configuration library
Definitely! There's no limit on what configuration formats Externalized Properties can support as you can implement custom `Resolver`s to retrieve from any source and format e.g.

    public class PklResolver implements Resolver {
        public Optional<String> resolve(InvocationContext context, String propertyName) {
            return getFromPklConfig(propertyName);
        }
    }


    // Register custom resolver when building ExternalizedProperties

    ExternalizedProperties externalizedProperties = ExternalizedProperties.builder()
        .resolvers(new PklResolver(...))
        .build();

    AppProperties appProperties = externalizedProperties.initialize(AppProperties.class);

    // Resolves config from PklResolver

    String myConfig = appProperties.myConfig();
jeyjeyemem··on Show HN: Externalized Properties, a modern Java configuration library
It's more performant than other similar libraries such as the Owner and cfg4j which no longer seems to be actively developed at this point and others such as Spring's Environment and MicroProfile config implementations

See benchmarks here: https://github.com/joel-jeremy/java-config-library-benchmark...

Aside from the performance, the other advantage of using this config library is how it makes testing easier and how easy it is to integrate with your dependency injection frameworks of choice.

jeyjeyemem··on Show HN: Externalized Properties, a modern Java configuration library
Externalized Properties was inspired by the The Twelve Factor Methodology's section III. Config.

The goal of this library is to make it easy for applications to implement configuration best practices by providing easy-to-use APIs as well as providing the flexibility to choose where to store their configurations/properties.

Externalized Properties takes full advantage of Java's Dynamic Proxies.

Why Dynamic Proxies?

* Dependency Injection Friendly

Since Externalized Properties works with interfaces, it makes it easy to integrate with dependency injection (DI) frameworks. it's as simple as building ExternalizedProperties, initializing a dynamic proxy from an interface, and registering the proxy interface to your chosen DI framework.

* Testing Friendly

Another side-effect of being dependency injection friendly is that it also makes it easy to mock/stub out configurations/properties on unit tests. It's as simple as creating a stub implementation of the proxy interface or using mocking frameworks to mock the proxy interface.

jeyjeyemem··on Emissary, a fast open-source Java messaging library
Emissary really shines if performance is a top priority.

The setup is more or less similar, you register a bunch of event handlers when initializing the library. The main difference is that, in addition to events, Emissary also supports "request" messages. Requests enforce the invariant that only one handler should handle it - if there are multiple handlers registered for a given request, Emissary will throw an error. That, and some extension points which is only needed for more advance use cases.

The InstanceProvider allows users to let the dependency injection (DI) framework of their choice instantiate the request/event handler classes (see https://github.com/joel-jeremy/emissary?tab=readme-ov-file#e...). This is in contrast to the way EventBus does it where subscribers need to be instantiated at startup time. By leveraging the DI framework, additional services can be injected to the handler's constructor.

jeyjeyemem··on Emissary, a fast open-source Java messaging library
This a frequently requested feature. At the moment, it only handles in-process messages but allowing for persistent events is definitely in the roadmap. It's not built-in right now, but this can be achieved by implementing custom RequestHandlerInvocationStrategy and EventHandlerInvocationStrategy. For example, one can implement an invocation strategy to serialize and send certain events to Kafka, queue, or your DB of choice.

See: https://github.com/joel-jeremy/emissary/blob/main/emissary-c...

Here are the default invocation strategies built-in right now: https://github.com/joel-jeremy/emissary/tree/main/emissary-c...

jeyjeyemem··on Emissary, a fast open-source Java messaging library
Yes, I am the author. I didn't know that, I'll give it a try. Thank you for the tip!
jeyjeyemem··on Emissary, a fast open-source Java messaging library
Emissary is a simple-to-use, no dependency, yet BLAZING FAST messaging library for decoupling messages (requests and events) and message handlers.

Emissary aims to take advantage of the simplicity of using the annotations for handlers (e.g. @RequestHandler/@EventHandler) without the drawbacks of reflection (slow).

What differentiates Emissary from other messaging/dispatch libraries? It takes advantage of java.lang.invoke.LambdaMetafactory to avoid the cost of invoking methods reflectively. This results in performance close to directly invoking the request handler and event handler methods.

~ 1000% more throughput compared to other similar libraries (Spring's ApplicationEventPublisher, Pipelinr, EventBus) ~ 90% faster compared to other similar libraries (Spring's ApplicationEventPublisher, Pipelinr, EventBus)

Benchmarks found on the GitHub repository: https://github.com/joel-jeremy/emissary?tab=readme-ov-file#p...