Development Model


The following are the ingredients of a Talon application that a microservice developer works with:
XML Models
A message model
One message model shared across multiple microservices
State models (optional)
One state model per microservice
User code
The HA Policy Declarer
Lifecycle Methods
Microservice Initializers
Message Filters & Handlers
Platform configuration
Message & State Models
The Application Data Modeler (ADM) component of Talon employes an XML-based modeling language to define application messages and microservice stores. These XML models are inputs for the Talon code generator, which produces Plain Old Java Objects (POJOs) for the application's business logic. These objects are optimized for performance, enhancing developer productivity by managing object serialization, transport and persistence.
The following are sample message and state models
See Modeling Message and State for more information on modeling messages and state.
User Code
The following is the user code for a basic Talon microservice. This illustrative microservice processes a HelloRequest message by updating a counter in its database and returns a HelloReply message with the updated counter value and an arbitrary string.
The Talon runtime drives all user code within a Talon microservice. User-written code falls into the following two categories:
Lifecycle methods
Message handlers
Lifecycle Methods
The Talon runtime oversees the lifecycle of a Talon application by executing user-defined methods to handle various lifecycle functions:
Accessor Methods The Talon runtime invokes such methods to gather user-specific data necessary for its operation. The
getStateFactory()method above is invoked to obtain the factory used to instantiate the root object of the microservice's store. This ensures Talon can instantiation the microservice store at the appropriate point in microservice lifecycleInjection Methods The Talon runtime invokes such methods to supply the user code with handles to Talon runtime objects for use by the user code in its operation. The
setMessageSender()method above us an example of such a method. Talon invokes this method, if implemented, to supply the user code with a an instance of theAepMessageSenderobject that the user code uses to send outbound messages.Notification Methods The Talon runtime invokes such methods to notify the user of lifecycle and alert related events. The
init()and theonMessagingPrestart()methods are examples of such methods. Theinit()method is invoked to notify the user code that the main microservice class -HelloService- was just loaded whileonMessagingPrestart()is invoked to notify the user code that the Talon runtime is about to connect to the underlying configured messaging bus.
Message Handlers
Business logic within Talon microservices is driven by messages. This means all business logic is executed through message handlers, which are methods marked with the @EventHandler annotation and recognized by their method signature. The onMessage() method above is an example of a message handler.
Message Handlers are single-threaded and should generally be non-blocking. They consume messages, perform business logic, query and/or update state and send outbound messages. The Talon runtime ensures that message receipt, state updates, and outbound sends are atomic, reliable, and loss-free, even in case of failures.
See Authoring User Code for more information on writing event and message handlers.
Last updated

