This is (intended to be) a fast and simple event messaging framework, with support for:

  • Events
  • Queries (events that expect/generate a response)
  • Running multiple instances of the server as well as client services
  • SSL/TLS by default
  • Very little configuration

Getting Started

To get started with just and the following to your build.gradle for your Spring Boot service:

implementation "net.albinoloverats.messaging:messaging-client:0.1.1"
testImplementation "net.albinoloverats.messaging:messaging-test:0.1.1"

And then annotate you event objects with @Event and your even handler methods with @EventHandler. Likewise for any queries. Everything else should then be handled for you.

Configuration

Configuration options are identical for both server and client; an optional list of server hosts, which defaults to auto and will direct servers to issue a UDP broadcast message that can be picked up by other server and clients alike (provided they are on the same network). A value of none will disable this entirely and essentially force a single server instance. The SSL/TLS capabilities can also be configured, from the protocol version, to choosing between PEM certificates or JKS, with a fall-back default of an ephemeral/in-memory certificate (only really recommended for testing and development).

messaging:
  hosts:
    - auto
  ssl:
    protocol: TLS
    pem:
      keyPath: /path/to/server-key.pem
      keyPassword: key-password
      certificatePath: /path/to/server-cert.pem
      trustPath: /path/to/ca-cert.pem
    jks:
      keyStorePath: /path/to/server-key-store.jks
      keyStorePassword: key-store-password
      trustStorePath: /path/to/client-trust-store.jks
      trustStorePassword: trust-store-password

Remember, if you intend to run multiple server instances, they will need a trust certificate/store.

Running

There is a Docker image for the server, which is available from Dockerhub.

Testing

As hinted above there is the messaging-test library, which is a Spring Boot starter test library. It contains a simple, in-memory client/server that can be accessed via the static methods in the TestMessagingHarness class. There are also a few simple Matchers that work similarly to Hamcrest/Mockito (and ideally they don’t conflict).

Demonstration/Example

There is now also a messaging-demo (as a separate project), which serves as a simple demo application. At a minimum it will require a database; MariaDB is what’s configured by default. It also gives the option of enabling Kafka or Axon for a messaging comparison. And if you wish to go full-Docker you can also see how Prometheus and Grafana can be used for metrics and monitoring, with Traefik for optional load-balancing.