### Message Start Event API Usage Source: https://docs.awspaas.com/reference-guide/aws-paas-process-event-reference-guide/startevents/message_start_event Demonstrates how to use the AWS SDK to start a process instance by sending an internal message to a Message Start Event. ```APIDOC ## Message Start Event API Usage ### Description This section details how to programmatically trigger a process instance using a Message Start Event by sending internal messages via the AWS SDK. ### Method Programmatic invocation using SDK ### Endpoint N/A (SDK method) ### Parameters #### Request Body - **messageName** (String) - Required - The name of the message to send, which must match the message variable name defined in the process. - **correlationKey** (String) - Optional - A key for correlating messages (if applicable). - **payload** (Map) - Optional - A map containing initial data to be passed to the process instance. ### Request Example ```java // Sending a basic internal message to start a process SDK.getProcessAPI().startByMessage("Alibaba-B2B-Order"); // Sending a message with initial data Map payload = new HashMap<>(); payload.put("OrderNo", "008"); SDK.getProcessAPI().startByMessage("Alibaba-B2B-Order", null, payload); ``` ### Response #### Success Response - **ProcessInstanceId** (String) - The unique identifier of the newly started process instance. #### Response Example (Successful execution of the SDK method initiates the process; a specific JSON response is not typically returned for this operation, but rather the process starts execution.) ### Error Handling - If the `messageName` does not match any deployed Message Start Events, the process will not start. - If the `payload` contains invalid data types, the process initialization may fail. - `SDK.getProcessAPI().startByMessage()` might throw exceptions for underlying system errors. ``` -------------------------------- ### Initiate Process with Internal Message (Java) Source: https://docs.awspaas.com/reference-guide/aws-paas-process-event-reference-guide/startevents/message_start_event Demonstrates how to initiate a process by sending an internal message using the AWS SDK. This is useful for starting a process based on specific internal events or message payloads. It allows for the optional initialization of process data. ```java SDK.getProcessAPI().startByMessage("Alibaba-B2B-Order"); Map payload = new HashMap<>(); payload.put("OrderNo", "008"); SDK.getProcessAPI().startByMessage("Alibaba-B2B-Order", null, payload); ``` -------------------------------- ### Send Internal Message with AWS SDK Source: https://docs.awspaas.com/reference-guide/aws-paas-process-event-reference-guide/intermediateevents/message_intermediate_throwing_event Demonstrates how to send an internal message using the AWS SDK to trigger a specific task or event. It shows examples of sending a message with and without a payload, allowing for flexible data passing. ```java //Send a name Alibaba-B2B-Order internal message, match and complete the interrupted task with order number 201702040007 SDK.getTaskAPI().messageEventReceived("Alibaba-B2B-Order", "201702040007"); //Initialize data Map payload = new HashMap<>(); payload.put("CustomerNo", "888"); SDK.getTaskAPI().messageEventReceived("Alibaba-B2B-Order", "201702040007", payload); ``` -------------------------------- ### Process Instance Creation and Version Selection Source: https://docs.awspaas.com/reference-guide/aws-paas-process-event-reference-guide/appendix/process_model_version Details on how the engine selects the appropriate process version when creating process instances, triggered by API calls or start events. It also outlines API parameters like 'processDefId' and their behavior across different environments (DEV, PRD, QAS, TEST). ```APIDOC ## Process Instance Creation and Version Selection ### Description This section describes how the AWS PaaS engine intelligently selects a process version based on the current operating environment. This selection occurs when a developer uses `ProcessAPI` to create a specified process instance or when a signal start event or message start event is triggered. ### Related APIs * `ProcessAPI.createShortProcessInstance` * `ProcessAPI.createProcessInstance` * `ProcessAPI.createSubProcessInstance` * `ProcessAPI.signalStartEventReceived` * `ProcessAPI.startByMessage` ### API Parameter `processDefId` Scenarios #### DEV Environment | `processDefId` Value (Process Definition ID or Process Version ID) | | -------------------------------------------------------------------- | | Process Model ID (different from Process Version ID) | | Process Version ID | **Behavior:** * **Process Model ID:** Uses the process model ID if a version is available. Throws an error if the version is disabled. * **Process Version ID:** Prioritizes the 'Design' version, followed by the 'Production' version. Throws an error if no available version is found. #### PRD, QAS, TEST Environments | `processDefId` Value (Process Definition ID or Process Version ID) | | -------------------------------------------------------------------- | | Process Model ID (different from Process Version ID) | | Process Version ID | **Behavior:** * **Process Model ID:** Uses the process model ID if a version is available. Throws an error if the version is disabled. * **Process Version ID:** Prioritizes the 'Production' version, followed by the 'Design' version. Throws an error if no available version is found. Developers can also use `RepositoryAPI` to obtain available process model IDs. ### SDK Example for `getRepositoryAPI().getProcessDefIdOfWork()` ```java // Intelligently returns the process version ID that can be started based on the current AWS PaaS operating environment //@param id A Process Model ID or Process Version ID String processDefId = SDK.getRepositoryAPI().getProcessDefIdOfWork(String id); //@return A process definition ID; returns an empty string if no available process is found if (!UtilString.isEmpty(processDefId)) { // ... process logic ... } ``` ### Signal Start and Message Start Scenarios #### DEV Environment * Prioritizes the 'Design' version. * Candidates include the 'Production' version. * Throws an error if no available version is found. #### PRD, QAS, TEST Environments * Prioritizes the 'Production' version. * Candidates include the 'Design' version. * Throws an error if no available version is found. ``` -------------------------------- ### Signal Intermediate Throwing Event - Java SDK Usage Source: https://docs.awspaas.com/reference-guide/aws-paas-process-event-reference-guide/intermediateevents/signal_intermediate_throwing_event Demonstrates how to use the SDK to throw a signal event in Java. This includes sending a signal with a specific name and optional payload. It is useful for decoupling process components and triggering actions in other parts of a workflow or system. ```java Map payload = new HashMap<>(); payload.put("OrderNo", "009"); SDK.getTaskAPI().signalEventReceived("CRM-Order", "vip", payload); ``` -------------------------------- ### Get Process Definition ID for Environment (Java) Source: https://docs.awspaas.com/reference-guide/aws-paas-process-event-reference-guide/appendix/process_model_version This Java code snippet demonstrates how to retrieve a process definition ID suitable for the current AWS PaaS operating environment. It takes a process model ID or version ID as input and returns a valid process definition ID, or an empty string if none is available. This is crucial for ensuring the correct process version is selected. ```java //根据当前AWS PaaS的运行环境,智能返回可启动的流程版本Id //@param id 一个流程模型Id或流程版本Id String processDefId= SDK.getRepositoryAPI().getProcessDefIdOfWork(String id); //@return 一个流程定义Id,没有可用流程返回空串 if(!UtilString.isEmpty(processDefId)){ //... } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.