Service Task
Service tasks in tSM form the backbone of automated workflows, enabling robust integration and efficient process execution. By leveraging scripting, connectors, and tSM services, service tasks ensure that complex operations are handled seamlessly, improving overall operational productivity.
Key Features
- Automation: Service tasks are designed exclusively for automated execution, ensuring consistency and efficiency in workflows.
- Scripting Integration: tSM uses scripting as the primary method of communication within the process, enabling dynamic interactions between process variables and system logic.
- Seamless Integration: Service tasks support a wide range of connectors and tSM services to interact with APIs, databases, messaging systems, and more.
Scripting in Service Tasks
tSM scripting enables service tasks to interact directly with process variables, states, and owning entity properties. This approach ensures precise control over task execution and data flow.
Core Concepts in tSM Scripting
-
Process Variables:
#execution
,#variables
, and#variablesLocal
allow interaction with the process state and variables.- For example:
#variables.taskPriority = "High"
dynamically assigns a priority during task execution.
-
Owning Entity Variables:
- Variables like
#ticket
,#order
, and#customer
represent the owning entity of the task. These are used to map properties to and from method calls. - Example:
<bpmn:serviceTask id="updateTicketStatus" name="Update Ticket Status"
camunda:expression="#ticket.status = 'RESOLVED'" />
- Variables like
-
tSM Business Services:
- Use services like
@commentService
or@notificationService
to perform specific business operations. - Example:
<bpmn:serviceTask id="addComment" name="Add Comment"
camunda:expression="#{@commentService.createComment({ownerId: #ticket.id, comment: 'Task completed'})}" />
- Use services like
Mapping Variables and Results
- Mapping Parameters: Map process variables and owning entity properties to method parameters in service calls.
- Result Handling: Automatically update owning entity or process variables with the results of method execution within the script.
Example:
<bpmn:serviceTask id="createComment" name="Create Comment" camunda:exclusive="false"
camunda:expression="#{@commentPublicService.createComment({ "ownerId": #ticket.id, "ownerType": "Ticket", "comment": "Example comment" })}"
tsm:description="<p></p>" tsm:color="#f6f4e0">
<bpmn:documentation>Example comment</bpmn:documentation>
<bpmn:extensionElements>
<camunda:executionListener expression="#{@logPublicService.createLog({ "logTypeCode": "Comment.Log", "ownerType": "Ticket", "ownerId": #ticket.id, "request": "Just sample of log to a service task", "startDate": #now(), "endDate": #now() })}" event="end" tsm:name="Log action" />
</bpmn:extensionElements>
<bpmn:incoming>Flow_173g8gj</bpmn:incoming>
<bpmn:outgoing>Flow_1sldk9d</bpmn:outgoing>
</bpmn:serviceTask>
Connectors Overview
tSM provides a variety of connectors to enable seamless integration with external systems and devices:
Generic Connectors
- REST/SOAP Client: For API interactions.
- Database Client: For executing SQL queries.
- Messaging: Integration with Kafka or JMS for message-based communication.
- SSH, SNMP: For direct device access and management.
Integration Connectors
- Public Registers: Access to address and company data.
- Communication Platforms: Google Chat, MS Teams.
- Project and Network Management: Jira, Netbox.
- NMS Systems: Cisco, Huawei, Fortimanager integrations.
- Infrastructure Tools: Netconf, Ansible, Terraform.
- On-Demand Integration: Custom connectors for legacy systems.
tSM Out-of-the-Box Services
tSM includes over 100 pre-configured services to streamline integration and automation. Examples include:
- Catalog Service: Manage product catalogs.
- Inventory Service: Handle network and infrastructure inventories.
- Customer Service: Manage customer-related data and operations.
- Address Service: Validate and process address information.
- Notification Service: Send alerts via multiple channels (email, SMS, in-app).
- Formatter Service: Format data for reporting or processing.
- Spreadsheet Service: Automate operations on spreadsheet files.
Design Guidelines for Service Tasks
Task Logic and Visibility
- Dedicated Tasks: Each service task should represent a distinct, visible business operation.
- Helper Actions: Use helper scripts for logging, variable calculation, or other auxiliary tasks. Avoid embedding business logic in these actions. If an incident occurs, the task should be easily identifiable and traceable. Only whole tasks could be retried or skipped, not separate actions.
Example:
<bpmn:serviceTask id="fetchOrderDetails" name="Fetch Order Details" camunda:expression="#{orderService.getDetails(#order.id)}">
<bpmn:extensionElements>
<camunda:executionListener expression="#{@logService.info('Order details fetched for Order ID: ' + #order.id)}" event="end" />
</bpmn:extensionElements>
</bpmn:serviceTask>
Input and Output Mapping
- Use
#variables
and#variablesLocal
properties directly within scripts. - Avoid explicit input/output mappings unless necessary for process clarity.