本文整理汇总了Java中org.activiti.engine.RuntimeService.signalEventReceived方法的典型用法代码示例。如果您正苦于以下问题:Java RuntimeService.signalEventReceived方法的具体用法?Java RuntimeService.signalEventReceived怎么用?Java RuntimeService.signalEventReceived使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.activiti.engine.RuntimeService
的用法示例。
在下文中一共展示了RuntimeService.signalEventReceived方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: triggerSignalEvent
import org.activiti.engine.RuntimeService; //导入方法依赖的package包/类
/**
* Trigger a signal event on all executions for a specific business key.
*
* @see <a href="http://www.activiti.org/userguide/index.html#bpmnSignalEventDefinition" />
* @see CoreSignals
*/
protected void triggerSignalEvent(ProcessEngine processEngine, String businessKey, String signalName) {
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
.processInstanceBusinessKey(businessKey).singleResult();
List<Execution> executions = runtimeService.createExecutionQuery()
.processInstanceId(processInstance.getProcessInstanceId())
.signalEventSubscriptionName(signalName).list();
if (executions.isEmpty()) {
throw new NoSuchElementException(String.format("No executions found waiting " +
"for signal '%s' on process %s", signalName, businessKey));
}
for (Execution execution : executions) {
LOG.info("Sending '{}' signal to execution {} for process {}",
new Object[]{signalName, execution.getId(), businessKey});
runtimeService.signalEventReceived(signalName, execution.getId());
}
}
示例2: main
import org.activiti.engine.RuntimeService; //导入方法依赖的package包/类
public static void main(String[] args) {
// 创建流程引擎
ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
// 得到流程存储服务组件
RepositoryService repositoryService = engine.getRepositoryService();
// 得到运行时服务组件
RuntimeService runtimeService = engine.getRuntimeService();
TaskService taskService = engine.getTaskService();
// 部署流程文件
repositoryService.createDeployment()
.addClasspathResource("bpmn/SignalCatchingEvent.bpmn").deploy();
// 启动流程
runtimeService.startProcessInstanceByKey("scProcess");
Task firstTask = taskService.createTaskQuery().singleResult();
taskService.complete(firstTask.getId());
// 此时会出现并行的两个流程分支,查找用户任务并完成
Task payTask = taskService.createTaskQuery().singleResult();
// 完成任务
taskService.complete(payTask.getId());
// 发送信号完成支付
runtimeService.signalEventReceived("finishPay");
Task finishTask = taskService.createTaskQuery().singleResult();
System.out.println("当前流程任务:" + finishTask.getName());
}
示例3: executeExecutionAction
import org.activiti.engine.RuntimeService; //导入方法依赖的package包/类
@PUT
@Path("/")
public Response executeExecutionAction(ExecutionActionRequest actionRequest) {
if (!ExecutionActionRequest.ACTION_SIGNAL_EVENT_RECEIVED.equals(actionRequest.getAction())) {
throw new ActivitiIllegalArgumentException("Illegal action: '" + actionRequest.getAction() +"'.");
}
if (actionRequest.getSignalName() == null) {
throw new ActivitiIllegalArgumentException("Signal name is required.");
}
RuntimeService runtimeService = BPMNOSGIService.getRuntimeService();
if (actionRequest.getVariables() != null) {
runtimeService.signalEventReceived(actionRequest.getSignalName(), getVariablesToSet(actionRequest));
} else {
runtimeService.signalEventReceived(actionRequest.getSignalName());
}
return Response.ok().status(Response.Status.NO_CONTENT).build();
}
示例4: main
import org.activiti.engine.RuntimeService; //导入方法依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
// 创建流程引擎
ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
// 得到流程存储服务组件
RepositoryService repositoryService = engine.getRepositoryService();
// 得到运行时服务组件
RuntimeService runtimeService = engine.getRuntimeService();
// 获取流程任务组件
TaskService taskService = engine.getTaskService();
// 部署流程文件
repositoryService.createDeployment()
.addClasspathResource("bpmn/SignalBoundaryEvent.bpmn").deploy();
// 启动2个流程实例
ProcessInstance pi1 = runtimeService
.startProcessInstanceByKey("sbProcess");
ProcessInstance pi2 = runtimeService
.startProcessInstanceByKey("sbProcess");
// 查找第一个流程实例中签订合同的任务
Task pi1Task = taskService.createTaskQuery()
.processInstanceId(pi1.getId()).singleResult();
taskService.complete(pi1Task.getId());
// 查找第二个流程实例中签订合同的任务
Task pi2Task = taskService.createTaskQuery()
.processInstanceId(pi2.getId()).singleResult();
taskService.complete(pi2Task.getId());
// 此时执行流到达确认合同任务,发送一次信号
runtimeService.signalEventReceived("contactChangeSignal");
// 查询全部的任务
List<Task> tasks = taskService.createTaskQuery().list();
// 输出结果
for (Task task : tasks) {
System.out.println(task.getProcessInstanceId() + "---"
+ task.getName());
}
}
示例5: performExecutionAction
import org.activiti.engine.RuntimeService; //导入方法依赖的package包/类
/**
* Execute an action on an execution
* @param executionId
* @param actionRequest
* @return Response
*/
@PUT
@Path("/{executionId}")
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
@Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
public Response performExecutionAction(@PathParam("executionId") String executionId, ExecutionActionRequest
actionRequest) {
Execution execution = getExecutionFromRequest(executionId);
RuntimeService runtimeService = BPMNOSGIService.getRuntimeService();
if (ExecutionActionRequest.ACTION_SIGNAL.equals(actionRequest.getAction())) {
if (actionRequest.getVariables() != null) {
runtimeService.signal(execution.getId(), getVariablesToSet(actionRequest));
} else {
runtimeService.signal(execution.getId());
}
} else if (ExecutionActionRequest.ACTION_SIGNAL_EVENT_RECEIVED.equals(actionRequest.getAction())) {
if (actionRequest.getSignalName() == null) {
throw new ActivitiIllegalArgumentException("Signal name is required");
}
if (actionRequest.getVariables() != null) {
runtimeService.signalEventReceived(actionRequest.getSignalName(), execution.getId(),
getVariablesToSet(actionRequest));
} else {
runtimeService.signalEventReceived(actionRequest.getSignalName(), execution.getId());
}
} else if (ExecutionActionRequest.ACTION_MESSAGE_EVENT_RECEIVED.equals(actionRequest.getAction())) {
if (actionRequest.getMessageName() == null) {
throw new ActivitiIllegalArgumentException("Message name is required");
}
if (actionRequest.getVariables() != null) {
runtimeService.messageEventReceived(actionRequest.getMessageName(), execution.getId(),
getVariablesToSet(actionRequest));
} else {
runtimeService.messageEventReceived(actionRequest.getMessageName(), execution.getId());
}
} else {
throw new ActivitiIllegalArgumentException("Invalid action: '" + actionRequest.getAction() + "'.");
}
Response.ResponseBuilder response = Response.ok();
// Re-fetch the execution, could have changed due to action or even completed
execution = runtimeService.createExecutionQuery().executionId(execution.getId()).singleResult();
if (execution == null) {
// Execution is finished, return empty body to inform user
response.status(Response.Status.NO_CONTENT);
} else {
response.entity(new RestResponseFactory()
.createExecutionResponse(execution, uriInfo.getBaseUri().toString())).build();
}
return response.build();
}
示例6: signalEventReceived
import org.activiti.engine.RuntimeService; //导入方法依赖的package包/类
@POST
@Path("/")
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Response signalEventReceived(SignalEventReceivedRequest signalRequest) {
RestResponseFactory restResponseFactory = new RestResponseFactory();
RuntimeService runtimeService = BPMNOSGIService.getRuntimeService();
if (signalRequest.getSignalName() == null) {
throw new ActivitiIllegalArgumentException("signalName is required");
}
Map<String, Object> signalVariables = null;
if (signalRequest.getVariables() != null) {
signalVariables = new HashMap<String, Object>();
for (RestVariable variable : signalRequest.getVariables()) {
if (variable.getName() == null) {
throw new ActivitiIllegalArgumentException("Variable name is required.");
}
signalVariables.put(variable.getName(), restResponseFactory.getVariableValue(variable));
}
}
if (signalRequest.isAsync()) {
if (signalVariables != null) {
throw new ActivitiIllegalArgumentException("Async signals cannot take variables as payload");
}
if (signalRequest.isCustomTenantSet()) {
runtimeService.signalEventReceivedAsyncWithTenantId(signalRequest.getSignalName(),
signalRequest.getTenantId());
} else {
runtimeService.signalEventReceivedAsync(signalRequest.getSignalName());
}
return Response.ok().status(Response.Status.ACCEPTED).build();
} else {
if (signalRequest.isCustomTenantSet()) {
runtimeService.signalEventReceivedWithTenantId(signalRequest.getSignalName(), signalVariables,
signalRequest.getTenantId());
} else {
runtimeService.signalEventReceived(signalRequest.getSignalName(), signalVariables);
}
return Response.ok().status(Response.Status.NO_CONTENT).build();
}
}