An originating task is associated with a Service Component Architecture
(SCA) component. When the task is started, it invokes the SCA component. Start
an originating task asynchronously only if the associated SCA component can
be called asynchronously.
Why and when to perform this task
Such an SCA component can, for example, be implemented as a long-running
process or a one-way operation.
This scenario creates an instance of
a task template and passes some customer data.
Steps for this task
- Optional: List the task templates to find the name
of the originating task you want to run.
This step is optional
if you already know the name of the task.
TaskTemplate[] taskTemplates = task.queryTaskTemplates
("TASK_TEMPL.KIND=TASK_TEMPL.KIND.KIND_ORIGINATING",
"TASK_TEMPL.NAME",
new Integer(50),
(TimeZone)null);
The results are sorted
by name. The query returns an array containing the first 50 sorted originating
templates.
- Create an input message of the appropriate type.
TaskTemplate template = taskTemplates[0];
// create a message for the selected task
ClientObjectWrapper input = task.createInputMessage( template.getID());
DataObject myMessage = null ;
if ( input.getObject()!= null && input.getObject() instanceof DataObject )
{
myMessage = (DataObject)input.getObject();
//set the parts in the message, for example, a customer name
myMessage.setString("CustomerName", "Smith");
}
- Create the task and run it asynchronously.
The example
uses the createAndStartTask method to create and run the task.
task.createAndStartTask( template.getName(),
template.getNamespace(),
input,
(ReplyHandlerWrapper)null);