Request Handlers
A handler is a Java or Kotlin class implementing the RequestHandler interface.
Handlers are registered via the @Handler annotation,
and they're invoked when an external message is received that matches the path
annotation parameter.
Request Matching
Incoming requests are matched against potential handlers per two possible routing patterns:
-
Path routing: Match according to request endpoint path (Routing.Path).
-
Content routing: Match according to request content via XPath or JSON expression (Routing.Content).
Base Handlers
Typically a request handler will interpret the message payload and do one of the following:
- Run a workflow process
- Notify a waiting process
- Respond directly through programmatic logic
Handlers commonly may perform other tasks as well:
- Validate the request
- Determine master request ID
- Populate process input values
- Create an acknowledgment response
MDW provides the BaseHandler,
implementation with helper methods for performing the tasks listed above. Also, there are specialized base
classes to extend for running or notifying processes:
-
ProcessRunHandler:
Implement getProcess()
to specify the process to run, and override getInputValues()
to populate a map of input variables.
-
ProcessNotifyHandler:
Implement
getEventName()
to specify the unique event name to notify.
Creating a Handler
To create a RequestHandler implementation in MDW Studio, right-click on a package name in the Project
tool window, and select New > MDW Handler.
Old-style .evth Assets
Previously MDW used .evth assets to register handlers. This type of asset is now deprecated and replaced
by the RequestHandler mechanism described above. The CLI provides
a convert
command that can create a RequestHandler from an evth asset:
mdw convert --input=assets/com/example/request/MyOldEventHandler.evth