Master Build |
NPM Stable |
Snapshots |
Muon is a set of libraries and services that let you build highly effective distributed systems that are message and event oriented.
Muon is structured as a set of libraries, known as muon-core
that give a set of infrastructure for building messaging systems. These are available in multiple languages and handle the concerns of discovery, transport, encoding and managing failures. On top of these, the exact messaging semantics that you want to express are built. These are built as a "stack", a set of channels, agents and finally a user facing API that you will use in your application code. These messages need to be transferred between your services to enable them to communicate. A Muon Transport enables this communication by giving a standard bidirectional channel like interface between them that they can exchange messages over
Muon can have multiple transports active at the same time, and chooses the most appropriate one to use to connect to the remote system. Connections to remote systems are fully multiplexed/ pipelined, giving the lowest latency and performance while also conserving system resources.
Muon is a system for building Microservices. In a Microservice system, things move, services change. In Muon, the system that supports finding where the thing you are looking for is the Discovery
. This is used by Muon to lookup the current location of a give service and identify what transport should be used to connect to it.
Muon can have multiple discoveries active at the same time, and combines the information they provide to give a full view of the system.
AMQP is a wire standardised messaging protocol that is widely implemented across the industry. We use RabbitMQ in our testing.
To use the transport in Java, first import Muon and the transport. Here, we include the AMQP transport, along with a discovery. In a real system, you would add a messaging stack to give you an API to work with.
build.gradle
repositories {
jcenter()
maven { url 'https://simplicityitself.artifactoryonline.com/simplicityitself/muon' }
maven { url 'https://simplicityitself.artifactoryonline.com/simplicityitself/muon-snapshot' }
}
dependencies {
compile "io.muoncore:muon-core:$muonVersion"
compile "io.muoncore:muon-transport-amqp:0.0.1-SNAPSHOT"
compile "io.muoncore:muon-discovery-amqp:0.0.1-SNAPSHOT"
}
To use the AMQP Discovery and Transport, you need to set the properties muon.transport.factories
and muon.discovery.factories
. These should be set to the appropriate AMQP specific version. Muon will then instantiate the factories and use them to create the Discovery and Factory instances for it to use.
You can configure which url will be used to connect to by setting the amqp.discovery.url
and amqp.transport.url
appropriately.
AutoConfiguration config = MuonConfigBuilder.withServiceIdentifier("my-service").withTags("awesome") (1)
.addWriter(c -> {
c.getProperties().setProperty(
"muon.transport.factories",
"io.muoncore.transport.amqp.AmqpMuonTransportFactory"); (2)
c.getProperties().put("amqp.transport.url", "amqp://muon:microservices@localhost");
c.getProperties().setProperty(
"muon.discovery.factories",
"io.muoncore.discovery.amqp.AmqpDiscoveryFactory"); (3)
c.getProperties().put("amqp.discovery.url", "amqp://muon:microservices@localhost");
}).build();
Muon muon = MuonBuilder
.withConfig(config).build(); (4)
//... add a stack to the muon.
-
Create a new config
-
Set the discovery to be AMQP (this is currently the default) and set the broker connection URL
-
Set the transport to be AMQP (this is currently the default) and set the broker connection URL
-
Build a Muon instance from the given config.
This will now be available. You can check this using the Muon CLI.
export MUON_URL=amqp://muon:microservices@localhost
muon discover
To use this, import Muon and the transport
npm install --save muon-core@next
npm install --save muon-amqp@next
Then, create a Muon instance
index.js
var Muon = require("muon-core")
require("muon-amqp").attach(Muon)
var muon = Muon.create("amqp://localhost")
// ... attach a stack, interact with other services, etc.
Additions and extensions to this stack are very welcome. Add issues and PRs to the repo.
All code is Copyright (c) Muon Core Ltd 2017.
Muon is Free Software, licensed under the terms of the LGPLv3 license as included in LICENSE
Muon has a commercial-friendly license allowing private forks and closed modifications of all projects, alongside enterprise support and extended support for enterprise technologies and patterns.
This will enable you to use Muon in any situation where your legal team will not accept a Free Software license.
Please see http://muoncore.io/pro/ for more detail. You can find the commercial license terms in COMM-LICENSE.