JBPM-任务到期发邮件实现

本文介绍如何使用JBPM定义并执行一个简单的邮件发送流程。主要包括:定义jpdl流程文件实现邮件发送功能,配置邮件属性,以及通过Java代码部署和启动流程。

1. jpdl定义

    当任务到期后VerRanLiu 给 dove 发一封邮件,默认格式可以指定。

<?xml version="1.0" encoding="UTF-8"?>

<process name="InlineMail" xmlns="http://jbpm.org/4.4/jpdl">

	<start g="20,25,80,40">
		<transition to="send rectify note" />
	</start>

	<mail g="99,25,115,45" name="send rectify note">
		<to addresses="dove@localhost" />
		<subject>rectify</subject>
		<html>
		<table><tr><td>${newspaper}</td><td>${date}</td> 
			<td>reporting bb dayorder doubleplusungood refs unpersons rewrite fullwise upsub antefiling</td> </tr></table>
		</html>
		<transition to="wait" />
	</mail>

	<state g="240,25,98,45" name="wait" />

</process>

 

 

2. 修改jbpm.mail.properties 文件,设置默认发件人

mail.smtp.host	localhost
mail.smtp.port	25
mail.from		VerRanLiu@localhost

 

3. 执行此流程

package com.spring.mail;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.jbpm.api.Configuration;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.ProcessInstance;

public class ProcessEngineLearn {

	public static String deployProcess(ProcessEngine pe, String jpdlPath) {
		return pe.getRepositoryService().createDeployment()
				.addResourceFromClasspath(jpdlPath).deploy();
	}

	public static void deleteProcessInst(ProcessEngine pe, String processInstId) {
		pe.getRepositoryService().deleteDeployment(processInstId);
	}

	public static ProcessInstance excuteProcess(ProcessEngine pe, String key,
			Map<String, Object> variables) {
		return pe.getExecutionService().startProcessInstanceByKey(key,
				variables);
	}

	/**
	 * @param args
	 * @throws InterruptedException
	 */
	public static void main(String[] args) throws InterruptedException {
		ProcessEngine pe = new Configuration().buildProcessEngine();
		deployProcess(pe, "com\\spring\\mail\\mail.jpdl.xml");
		Map<String, Object> variables = new HashMap<String, Object>();
		variables.put("newspaper", "Hello");
		variables.put("date", new Date().toLocaleString());
		excuteProcess(pe, "InlineMail", variables);
		System.out.println(variables.get("newspaper"));
	}

}

 

4. 通过上节部署的claors webmail应用查看邮件

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值