Hi readers, in this blog, I will talk about what are AMPS, how it works, and then finally will talk about how to run it with a working example.
So let’s get started…!!
What are AMPS(Advanced Message Processing System)?
AMPS from 60East Technologies is a fast messaging engine that supports both publish-subscribe messaging and queuing. It is not just a simple messaging engine it is also packed with some powerful feature like high availability, historical replay, aggregation and analytics, content filtering and continuous query, last value caching, focus tracking, and more.
Let me highlight some important features of AMPS that make it different from other messaging systems:
- Topic and content-based publish and subscribe
- Client development kits for popular programming languages such as Java, C#, C++, C and Python
- Built-in support for FIX, NVFIX, JSON, BSON, BFlat, Google Protocol Buffer, and XML messages. AMPS also supports uninterpreted binary messages and allows you to create composite message types from existing message types.
- State-of-the-World queries
- Replication for high availability
- Message replay functionality
I will talk about these features in detailed in my upcoming blogs.
AMPS PUB-SUB Model
This is same as any other pub-sub model wherein a publisher publishes the message to a topic and subscriber subscribes to a topic and reads the message from it. But amps also provide some powerfully features like we can do content filtering where we can subscribe to a topic with a filter and with the help of that we can get only the filtered messages from AMPS server.
AMPS Cluster Model
When we compare with Kafka the AMPS model is little different. In AMPS, when we publish a message, the message goes to any of the available instances, not like Kafka where the message goes to the elected leader.
In an asynchronous communication, we get the acknowledgment soon after the message is published to one of the instances but the message is replicated between the instance in a synchronous manner.
When we have a cluster across different data centers the message is replicated to different instance within a data center is synchronous but for different data centers, the messages are replicated asynchronously.
Note: AMPS currently provide support to Linux 64-bit (2.6 kernel or later) on x86 compatible processors
- Java Development Kit version 1.7 or greater.
- Java Runtime Environment version 1.7 or greater.
- optional Apache Ant version 1.8 or greater.
You can download AMPS from here
Obtaining a Client
AMPS provide pre-compiled jars that we need to download and add it to in project so that we can start working with amps. You can download the jar from the AMPS official website. The pre-compiled JAR files will be located in the /dist/lib/ directory.
To run amps server we first create a configuration file for our server and run it with this file. Let’s take AMPSDIR is the directory location of amps on our local. So we first run the following command:
$AMPSDIR/bin/ampServer --sample-config > $AMPSDIR/amps_config.xml
This will create an amps_config.xml file and after that, we will run our amps server:
This will start up the amps server.
Now let’s understand how to create a publisher and a subscriber.
AMPS Publisher and Subscriber Example
To publish and subscribe to a topic first we need to create and open a Client connection.
We can create a client using Client class or a HAClient class which extends Client class and provides additional functionality like, it provides high availability as it allows applications to automatically:
- Recover from temporary disconnects between client and server.
- Failover from one server to another when a server becomes unavailable.
HAClient should be used for production as it handles failure-overs automatically. You can get the code on amps using HAClient on my GitHub repository.