Subscribing to Events Using Flows
You can subscribe to events using flows and BPMs. This section describes how to subscribe to events by using flows.
In Creating a Custom Event, an event that records employment status changes has been created. This section describes how to subscribe to the event by using a flow. After subscription, you can use the event sending API to simulate the scenario where the recruitment manager provides the hiring result. In this scenario, the system will automatically send an email to the personnel department based on the hiring result to inform the personnel department whether to handle related procedures.
Subscribing to Events Using Flows
- Create a flow by referring to Creating a Flow.
Figure 1 Adding a flow
Table 1 Parameters for adding a flow Parameter
Description
Label
Flow label, which is displayed on the page.
Value: 1–64 characters.
Example: EmployResultNotifySubscription.
Name
Unique identifier of the flow in the system, which cannot be changed after being created. The following requirements must be met:
- The value cannot exceed 64 characters, including the prefix namespace.
To prevent duplicate data names among different tenants, each tenant must define a unique namespace when first creating an application. A tenant can create only one namespace. After being created, the namespace cannot be modified.
- Start with a letter and can contain only letters, digits, and underscores (_). It cannot end with an underscore (_).
Example: EmployResultNotifySubscription.
Type
Select a type from the drop-down list. Options:
- Autolaunched Flow: Automatically starts flow. After an API is called, the logic defined by the flow is executed immediately.
- Event Trigger: A flow that is triggered by an event. The logic defined in the flow is executed only when the event is triggered.
Example: Event Trigger.
Event
Select the event created in Creating a Custom Event. Ensure that the event is enabled.
Description
Enter the description of the flow.
Value: 1–255 characters.
- The value cannot exceed 64 characters, including the prefix namespace.
- On the left of the flow design page, choose Logic and drag the Decision diagram element to the canvas.
Decision: Checks current conditions and determines the operation to be performed based on the check result. The logic is similar to judgment of the if statement. In this example, you need to set three judgment branches: the candidate is hired, the candidate is not hired, and others.
Figure 2 Dragging the Decision diagram element to the canvas - Select the Decision diagram element, click
, and set branch condition parameters.
Figure 3 Configuring branch conditionsFigure 4 unpassEditable result, that is, all judgment conditions. Default conditions have been preset in the system. That is, when all other conditions are not met, the branch is triggered.
In this example, the following two judgment conditions need to be added:
- Pass: The candidate is hired. If the candidate is hired, set Result, which is a parameter of the Boolean type, to the global constant {!$GlobalConstant.True}, indicating that the result is true, that is, the candidate is hired.
- Unpass: The candidate is not hired. If the candidate fails to be hired, set Result, which is a parameter of the Boolean type, to the global constant {!$GlobalConstant.False}, indicating that the result is false, that is, the candidate is rejected.
- Choose Basic on the left of the flow design page and drag the Send Email diagram element to the canvas.
The Send Email API is used to send emails. In this example, you need to send different emails to the personnel department based on the hiring result.
- If a candidate is hired, send an email to notify the personnel department, requiring it to handle related procedures.
- If the candidate is not hired, send an email about the result to the personnel department.
- If the event times out (default branch), send an email to the recruitment manager to check whether the recruitment manager provides the recruitment result.
- The following describes how to set email sending parameters if the candidate is hired.
- Select the Send Email diagram element, click
, and set basic information.
Figure 5 Setting basic information about email sending - Click
to set email sending parameters.
Figure 6 Setting email sending parametersTable 2 Email sending parameters Parameter
Description
Email Config
To manually configure email information, click Manually. To select an email template, click Template.
Example: Manually.
Subject
Enter the email subject.
Example: Interview Result.
Body
Email content. Use the event variable Namespace_EmployResultNotify__e. You can drag the event variable from the variable.
Address
Email address of the recipient.
- Text: Enter text.
- Collection: Drag a collection variable.
In this example, enter the address of the email recipient.
- Select the Send Email diagram element, click
- Refer 5 to configure the email to be sent if the candidate is rejected or the event times out.
- Connect all elements, as shown in Figure 7.
- In the upper part of the flow design page, click
to save the settings.
- After the settings are saved, click
to activate the flow.
After this flow is enabled, the logic defined in the flow is executed when the EmployResultNotify event is triggered.
Verification
After the EmployResultNotify event is subscribed to using the flow, the recruitment manager needs to provide the hiring result. The manager of the personnel department can receive the email containing information about whether the candidate is hired only after the recruitment manager sets a value for Result. That is, you need to configure event sending so that the subscriber can receive the event.
In this section, we can create a flow to set Result for candidate Lily to simulate event sending.
- Create a flow by referring to Creating a Flow.
Figure 8 Creating SendEvent
- Choose Basic on the left of the flow design page and drag the Send Event diagram element to the canvas.
Send Event is provided by the system for sending events.
Figure 9 Dragging the Send Event diagram element to the canvas - Configure the Send Event diagram element.
Assume that candidate Lily is hired. In Context, click the plus sign (+) next to Variable, add a variable, and set event sending parameters.
- Click
. In Context, create variable0.
Figure 10 Adding a variable - Select the send event diagram element, click
, and set basic information.
Figure 11 Setting basic information about the event to be sent - Click
to set the sending event.
Figure 12 Page for configuring the sending eventTable 3 Parameters for sending events Parameter
Description
Event
Select the event to be sent. In this example, select the event created in Creating a Custom Event.
Partition Key
If a custom parameter is selected from the event as the partition key of the Kafka, events will be routed based on this key. Events with the same key will be routed to the same Kafka. If no key is specified, events will be randomly routed to different partitions to enhance concurrent processing performance.
Send to external
The system provides a Kafka topic named BINGO_SYS_TOPIC for connections to Huawei Cloud Astro Zero.
- If this parameter is not selected, event data will be sent to the default topic.
- If this parameter is selected, event data will be sent to other Kafka topics connected to Huawei Cloud Astro Zero.
This parameter is deselected by default.
Delay sending event until transaction ends (committed or rolled back)
Event sending can be delayed until a transaction ends.
This parameter is deselected by default.
Target/Source
Value of the event custom parameter. Click Add Row to add a parameter and assign a value to it.
- Click
- Connect the Start and Send Email diagram elements.
Figure 13 Connecting diagram elements
- In the upper part of the flow design page, click
to save the settings.
- Click
to activate the flow.
- Set input parameters and click Run. The event can be sent only after the flow is executed.
The email recipient receives the email, indicating that the verification succeeded.
Figure 14 Sending an event
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot