The Talon Manual

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Talon provides the machinery to easily build, run and manage micro applications (‘micro app’). A micro app is a lightweight, stateful message processor that resides on a messaging fabric. A micro app stores state as Java objects entirely in local memory and collaborates with other micro apps using guaranteed eventing transactional message passing via its underlying messaging fabric.

Image RemovedImage Added

The Talon runtime uses configuration information to connect to the messaging fabric and drive the business logic embodied in the micro app message handlers in an exactly once, fully fault tolerant manner. Application developers just implement message handlers. The Talon runtime dispatches inbound messages to the appropriate handlers, the handlers execute business logic, update state and send outbound messages to downstream apps. Talon enables the following for a developer

  • Maintain state as POJOs
  • Sends and receive messages as POJOs
  • Assume that POJO state updates and outbound message sender sends performed by a message handler are durable and transactional.

By enabling this, Talon makes it extremely ease easy for the developer to author streaming, multi-agent apps that are fault tolerant, scalable and perform at memory speeds. 

A Simple App

Lets say, for example, a developer would like to write an app that performs the following

  • Maintain a counter in its state
  • Update Receive a message, update the counter on receipt of a message and send an outbound message with the updated counter value

...

Thats it. The rest - app lifecycle, message bus connectivity, serialization/deserialization, state persistence, HA, etc - are all taken care of by the Talon runtime.

Model State

...

State

Code Block
languagexml
themeEmacsRDark
<model>
    ...
    <entities>
        <entity name="Repository">
            <field name="counter" type="Long"/>
        </entity>
    </entities>
</modelmodel>

The state is comprised of above model defines a state tree with a single root Repository object with a counter value in it.

  • The Repository object contains a single counter field of type long

Model Messages

Code Block
languagexml
themeEmacsRDark
<model>
    ...
    <messages>
        <message name="Message">
            <field name="value" type="Long"/>
        </message>

        <message name="Event">
            <field name="result" type="Long"/>
        </message>
    </messages>
</model>

The above model defines a Message  and  and an Event message.

  • Message contains a field named value of type long 
  • Event contains a field named result of type long.

...

Convert to POJOs

The above XMLs are converted to POJOs as part of the app's build process. The following illustrates how this is done using the Talon's Maven code generator plugin

Code Block
languagexml
themeEmacsRDark
    <build>
        <plugins>
            <plugin>
                <groupId>com.neeve</groupId>
                <artifactId>nvx-core-maven-plugin</artifactId>
                <version>${nvx.talon.version}</version>
                <executions>
                    <execution>
                        <id>State</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <modelFile>${project.basedir}/src/main/models/com/neeve/talon/starter/state/state.xml</modelFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.neeve</groupId>
                <artifactId>nvx-core-maven-plugin</artifactId>
                <version>${nvx.talon.version}</version>
                <executions>
                    <execution>
                        <id>Messages</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <modelFile>${project.basedir}/src/main/models/com/neeve/talon/starter/messages/messages.xml</modelFile>
                            <encodingType>Xbuf</encodingType>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

Write Application Logic

The following is the message handler that executes the application logic

Code Block
languagejava
themeEmacsRDark
@EventHandler
public void onMessage(Message message, Repository repository) {
    repository.setCounter(repository.getCounter() + message.getValue());
    Event event = Event.create();
    event.setResult(repository.getCounter());
    sender.sendMessage(“events”, event);
}

...

What is most significant about the code above is how messaging, storage and transaction processing are fully integrated using Java without compromising on the non-functional aspects of the application. The X Platform ensures that the above code is invoked exactly once for an inbound message, is horizontally scalable and fully fault tolerant with zero data loss on process, machine or data center failure. It is this capability to enable fully integrated stateful and collaboration aware code without non-functional compromise that unleashes the full potential and power of multi-agent systems.

Get Hands On...?

Click HERE to get started with Talon.