4

AMPS: Empowering real time message driven applications.

 3 years ago
source link: https://blog.knoldus.com/amps-empowering-real-time-message-driven-applications/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

AMPS: Empowering real time message driven applications.

Reading Time: 3 minutes

Greetings!!

In this blog, we will talk about AMPS, a pub-sub engine which delivers messages in real time with a subject of interest. AMPS is mainly used by Financial Institutions as enterprise message bus. We will also demonstrate how we can use AMPS with to publish and subscribe messages with an example. So, let’s start with introducing AMPS. 

What is AMPS?

Advanced Message Processing System (AMPS) is a publish and subscribe engine developed by 60East technologies. It  is highly scalable and allow publishing and subscribing messages in real time. It is equipped with in built support of multiple messaging protocols such as FIX, NVFIX, JSON, XML which are mainly used in financial services such as trade processing. It empowers applications to deliver messages in real time with flexible topic and content based routing options. 

AMPS

How does it work?

The above diagram describes how messaging looks like in AMPS. AMPS provides a unique way message delivery by TOPICs. A topic is nothing but a subject of interest which is assigned to messages. For example A cricket score update server would publish a message with topic “Sixer” whenever a Six is hit in the game of Cricket. This message would be deliver to each subscriber having subscribed the topic “SIX” in the real time. AMPS also allow content based subscriptions where a subscriber would be interested in a particular content in the messages. For example In the diagram, Subscriber 2 is interested in Content “A”. Here “A” is a player who has hit the SIX. Whenever something is talked about the particular player, subscriber 2 will receive messages.

Writing Pub/Sub clients for AMPS.

Writing clients for publishing and subscribing to AMPS messages is super simple. Create a Client with a name and use connect method to connect to the AMPS server. Look at the following publisher example.

Publishing to a Topic:

xxxxxxxxxx
import com.crankuptheamps.client.{Client, MessageStream}
val client_name = "Publisher"
val server_url = "tcp://127.0.0.1:9007/amps/json"
val topic = "Sixer"
val publisher = new Client(client_name)
publisher.connect(server_url)
publisher.logon
publisher.publish(topic, s"""{ "message" : "A has hit a massive SIX!" }""")

There is no restriction on a topic name. It can be any text but it is recommended that a topic name should be a text without character which are used in reg-ex. The reason is that a topic can be matched agains re-gex.

Subscribing to a Topic

xxxxxxxxxx
val server_url = "tcp://127.0.0.1:9007/amps/json"
val subsriber = new Client("Subscriber")
val topic = "Sixer"
subsriber.connect(server_url)
subsriber.logon
val dataStream = subsriber.subscribe(topic)
for( msg <- dataStream.iterator().asScala )
println("Messages......." + msg.getData )

Apart from publishing and subscribing with Topics, AMPS also support querying the the historical events, filtering and subscribing by the message payload etc. Since it is an introductory blog, SOW are currently out of scope for this blog.

A detail instruction on how to run this example is at the following link: AMPSClientExample

How to Get

The AMPS server:

However it is only available for Linux 64 bit machines, For other users, this blog can help write basic AMPS clients. You can download the evaluation package from href=”http://www.crankuptheamps.com/evaluate/”&gt;http://www.crankuptheamps.com/evaluate/

The Client Library:

The client library is provided as jars by the 60 East Tech. It can be download and put in the project. I’ve included it as lib jars in my sbt project. To view the details on how to download go to http://www.crankuptheamps.com. For reference, you can look into github repo of this blog.

How to Configure the Server
A rich documentation is provided with evaluation package where each step is detailed: You need to the downloaded the zip and extract it. Enter into the downloaded directory and then /docs: You will find: AMPS configuration reference, AMPS User Guide etc. I will leave the configuration up to you which is pretty simple once you go through the documentations.

Starting the AMPS Server
Extract the downloaded compressed file and call it MYDIR. Go to the MYDIR. To start the server we need a sample config for the server. To generate the sample config do as:

$MYDIR/bin/ampServer --sample-config > example_config_file_name.xml

Once the config is generated successfully, the server can be started as:
./bin/ampServer   example_config_file_name.xml

The successfully startup will look like:
2017-07-15T16:32:51.0801440+05:30 [1] info: 00-0015 AMPS initialization completed (1 seconds).

Once the server is started, the messages can be published by client application. Instruction to run the current example can be found at: link.

Where to go from Here:

For detail API example and capabilities of AMPS, you can visit the official site . Thanks for reading. Cheers !!!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK