工作流引擎使用詳解!工作流框架Activiti的詳細配置以及安裝使用

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"創建ProcessEngine","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Activiti流程引擎的配置文件是名爲","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"activiti.cfg.xml","attrs":{}},{"type":"text","text":"的XML文件.","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"注意與使用Spring方式創建流程引擎是不一樣的","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"使用org.activiti.engine.ProcessEngines類,獲得ProcessEngine:","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":"ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine()\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"它會在","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"classpath","attrs":{}},{"type":"text","text":"下搜索","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"activiti.cfg.xml","attrs":{}},{"type":"text","text":",並基於這個文件中的配置構建引擎","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n\n \n\n \n \n \n \n\n \n\n \n\n \n \n \n\n\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"配置文件中使用的","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ProcessEngineConfiguration","attrs":{}},{"type":"text","text":"可以通過編程方式創建,可以配置不同的","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"bean id","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":"ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault();\nProcessEngineConfiguration.createProcessEngineConfigurationFromResource(String resource);\nProcessEngineConfiguration.createProcessEngineConfigurationFromResource(String resource, String beanName); // 配置不同的bean id\nProcessEngineConfiguration.createProcessEngineConfigurationFromInputStream(InputStream inputStream);\nProcessEngineConfiguration.createProcessEngineConfigurationFromInputStream(InputStream inputStream, String beanName);\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"如果不使用配置文件進行配置,就會基於默認創建配置","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ProcessEngineConfiguration.createXXX()","attrs":{}},{"type":"text","text":" 方法都會返回","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ProcessEngineConfiguration","attrs":{}},{"type":"text","text":",後續可以調整成所需的對象. 在調用","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"buildProcessEngine()","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}},{"type":"strong","attrs":{}}],"text":"後, 就會創建一個","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ProcessEngine:","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":" ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration()\n .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE)\n .setJdbcUrl(\"jdbc:h2:mem:my-own-db;DB_CLOSE_DELAY=1000\")\n .setJobExecutorActivate(true)\n .buildProcessEngine();\n","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"ProcessEngineConfiguration bean","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"activiti.cfg.xml","attrs":{}},{"type":"text","text":"必須包含一個","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"id='processEngineConfiguration'","attrs":{}},{"type":"text","text":" 的bean","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":" \n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"這個bean會用來構建","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ProcessEngine.","attrs":{}},{"type":"text","text":" 有多個類可以用來定義","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"processEngineConfiguration.","attrs":{}},{"type":"text","text":" 這些類對應不同的環境,並設置了對應的默認值:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration:","attrs":{}},{"type":"text","text":" 單獨運行的流程引擎.Activiti會自己處理事務.默認數據庫只在引擎啓動時檢測(如果沒有Activiti的表或者表結構不正確就會拋出異常)","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration:","attrs":{}},{"type":"text","text":" 單元測試時的輔助類.Activiti會自己控制事務. 默認使用H2內存數據庫,數據庫表會在引擎啓動時創建,關閉時刪除.使用它時,不需要其他配置(除非使用job執行器或郵件功能)","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"org.activiti.spring.SpringProcessEngineConfiguration:","attrs":{}},{"type":"text","text":" 在Spring環境下使用流程引擎","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"org.activiti.engine.impl.cfg.JtaProcessEngineConfiguration:","attrs":{}},{"type":"text","text":" 單獨運行流程引擎,並使用JTA事務","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"數據庫配置","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"定義數據庫配置參數","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"基於數據庫配置參數定義數據庫連接配置","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"jdbcUrl:","attrs":{}},{"type":"text","text":" 數據庫的JDBC URL","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"jdbcDriver:","attrs":{}},{"type":"text","text":" 對應不同數據庫類型的驅動","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"jdbcUsername:","attrs":{}},{"type":"text","text":" 連接數據庫的用戶名","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"jdbcPassword:","attrs":{}},{"type":"text","text":" 連接數據庫的密碼","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"基於JDBC參數配置的數據庫連接 會使用默認的MyBatis連接池,配置MyBatis連接池:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"jdbcMaxActiveConnections:","attrs":{}},{"type":"text","text":" 連接池中處於被使用狀態的連接的最大值.默認爲","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"10","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"jdbcMaxIdleConnections:","attrs":{}},{"type":"text","text":" 連接池中處於空閒狀態的連接的最大值","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"jdbcMaxCheckoutTime:","attrs":{}},{"type":"text","text":" 連接被取出使用的最長時間,超過時間會被強制回收. 默認爲","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"20000(20秒)","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"jdbcMaxWaitTime:","attrs":{}},{"type":"text","text":" 這是一個底層配置,讓連接池可以在長時間無法獲得連接時, 打印一條日誌,並重新嘗試獲取一個連接.(避免因爲錯誤配置導致沉默的操作失敗) 默認爲","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"20000(20秒)","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"使用javax.sql.DataSource配置","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Activiti的發佈包中沒有這些類, 要把對應的類放到classpath下","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n \n \n \n \n \n\n\n\n\n \n ...\n\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"無論使用JDBC還是DataSource,都可以設置下面的配置:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"databaseType:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"一般不用設置,因爲可以自動通過數據庫連接的元數據獲取","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"只有自動檢測失敗時才需要設置.可能的值有:{h2,mysql,oracle,postgres,mssql,db2}","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"如果沒使用默認的H2數據庫就必須設置這項.這個配置會決定使用哪些創建/刪除腳本和查詢語句","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"databaseSchemaUpdate:","attrs":{}},{"type":"text","text":" 設置流程引擎啓動和關閉時如何處理數據庫表","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"false:默認,","attrs":{}},{"type":"text","text":" 檢查數據庫表的版本和依賴庫的版本,如果版本不匹配就拋出異常","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"true:","attrs":{}},{"type":"text","text":" 構建流程引擎時,執行檢查,如果需要就執行更新. 如果表不存在,就創建","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"create-drop:","attrs":{}},{"type":"text","text":" 構建流程引擎時創建數據庫表,關閉流程引擎時刪除這些表","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"JNDI數據庫配置","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在默認情況下,Activiti的數據庫配置會放在web應用的","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"WEB-INF/classes","attrs":{}},{"type":"text","text":"目錄下的","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"db.properties","attrs":{}},{"type":"text","text":"文件中. 這樣做比較繁瑣,因爲要用戶在每次發佈時,都","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"修改Activiti源碼中的db.properties並重新編譯war文件","attrs":{}},{"type":"text","text":",或者","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"解壓縮war文件,修改其中的db.properties","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"使用 ","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"JNDI(Java命名和目錄接口)","attrs":{}},{"type":"text","text":" 來獲取數據庫連接,連接是","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"由servlet容器管理","attrs":{}},{"type":"text","text":"的,可以","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"在war部署外邊管理配置.","attrs":{}},{"type":"text","text":" 與db.properties相比,它也允許對連接進行更多的配置","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"JNDI的使用","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"Activiti Explorer和Activiti Rest應用從db.properties轉換爲使用JNDI數據庫配置:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"需要打開原始的Spring配置文件:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"activiti-webapp-explorer/src/main/webapp/WEB-INF/activiti-standalone-context.xml","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"activiti-webapp-rest2/src/main/resources/activiti-context.xml","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"刪除","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"dbProperties","attrs":{}},{"type":"text","text":"和","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"dataSource","attrs":{}},{"type":"text","text":"兩個bean,然後添加如下bean:","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n \n\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"我們需要添加包含了默認的H2配置的context.xml文件","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"如果已經有了JNDI配置,會覆蓋這些配置.對應的配置文件","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"activiti-webapp-explorer2/src/main/webapp/META-INF/context.xml:","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n\n \n\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"如果是","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"Activiti REST","attrs":{}},{"type":"text","text":"應用,則添加","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"activiti-webapp-rest2/src/main/webapp/META-INF/context.xml:","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n\n \n\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"最後刪除Activiti Explorer和Activiti Rest兩個應用中不再使用的db.properties文件","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"JNDI的配置","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"JNDI數據庫配置會因爲使用的Servlet container不同而不同","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"Tomcat容器中的JNDI配置如下:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"JNDI資源配置在","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"CATALINA_BASE/conf/[enginename]/[hostname]/[warname].xml","attrs":{}},{"type":"text","text":"(對於Activiti Explorer來說,通常是在","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"CATALINA_BASE/conf/Catalina/localhost/activiti-explorer.war)","attrs":{}},{"type":"text","text":" 當應用第一次發佈時,會把這個文件從war中複製出來.所以如果這個文件已經存在了,需要替換它.修改JNDI資源讓應用連接mysql而不是H2:","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n \n \n \n","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"Activiti支持的數據庫","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"h2:","attrs":{}},{"type":"text","text":" 默認配置的數據庫","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"mysql","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"oracle","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"postgres","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"db2","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"mssql","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"創建數據庫表","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"創建數據庫表的方法:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"activiti-engine","attrs":{}},{"type":"text","text":"的jar放到classpath下","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"添加對應的數據庫驅動","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"把Activiti配置文件(activiti.cfg.xml)放到classpath下,指向你的數據庫","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"執行","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"DbSchemaCreate","attrs":{}},{"type":"text","text":"類的main方法","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"text"},"content":[{"type":"text","text":"SQL DDL語句可以從Activiti下載頁或Activiti發佈目錄裏找到,在database子目錄下.\n腳本也包含在引擎的jar中:activiti-engine-x.jar在org/activiti/db/create包下,drop目錄裏是刪除語句\n\n- SQL文件的命名方式如下:\n[activiti.{db}.{create|drop}.{type}.sql]\ntype 是:\n- engine:引擎執行的表,必須\n- identity:包含用戶,羣組,用戶與組之間的關係的表.這些表是可選的,只有使用引擎自帶的默認身份管理時才需要\n- history:包含歷史和審計信息的表,可選的.歷史級別設爲none時不會使用. 注意這也會引用一些需要把數據保存到歷史表中的功能\n","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"數據庫表名理解","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Activiti的表都以**ACT_**開頭, 第二部分是表示表的用途的兩個字母標識.用途和服務的API對應","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ACT_RE_*:","attrs":{}},{"type":"text","text":" ","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"RE","attrs":{}},{"type":"text","text":"表示","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"repository.","attrs":{}},{"type":"text","text":" 這個前綴的表包含了","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"流程定義和流程靜態資源","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ACT_RU_*:","attrs":{}},{"type":"text","text":" ","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"RU","attrs":{}},{"type":"text","text":"表示","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"runtime.","attrs":{}},{"type":"text","text":" 這些是運行時的表,包含","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"流程實例,任務,變量,異步任務等運行中的數據.","attrs":{}},{"type":"text","text":" Activiti只在流程實例執行過程中保存這些數據, 在流程結束時就會刪除這些記錄.這樣運行時表可以一直很小速度很快","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ACT_ID_*:","attrs":{}},{"type":"text","text":" ","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ID","attrs":{}},{"type":"text","text":" 表示","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"identity.","attrs":{}},{"type":"text","text":" 這些表包含","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"身份信息.","attrs":{}},{"type":"text","text":" 比如用戶,組等等","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ACT_HI_*:","attrs":{}},{"type":"text","text":" ","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"HI","attrs":{}},{"type":"text","text":" 表示","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"history.","attrs":{}},{"type":"text","text":" 這些表包含","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"歷史數據.","attrs":{}},{"type":"text","text":" 比如歷史流程實例, 變量,任務等等","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ACT_GE_*:","attrs":{}},{"type":"text","text":" ","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"通用數據.","attrs":{}},{"type":"text","text":" 用於不同場景下","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"數據庫升級","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在執行更新之前要先使用數據庫的","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"備份","attrs":{}},{"type":"text","text":"功能備份數據庫","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"默認情況下,每次構建流程引擎時都會進行版本檢測.這一切都在應用啓動或Activiti webapp啓動時發生.如果Activiti發現數據庫表的版本與依賴庫的版本不同,就會拋出異常","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"對activiti.cfg.xml配置文件進行配置來升級:","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n\n \n \n \n \n \n\n\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"然後,把對應的數據庫驅動放到classpath裏.升級應用的Activiti依賴,啓動一個新版本的Activiti指向包含舊版本的數據庫,將databaseSchemaUpdate設置爲true,Activiti會自動將數據庫表升級到新版本","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"當發現依賴和數據庫表版本不通過時,也可以執行更新升級DDL語句","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"也可以執行數據庫腳本,可以在Activiti下載頁找到","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"啓用Job執行器","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"JobExecutor是管理一系列線程的組件,可以觸發定時器(包含後續的異步消息).","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在單元測試場景下,很難使用多線程.因此API允許","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"查詢Job(ManagementService.createJobQuery)","attrs":{}},{"type":"text","text":" 和","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"執行Job (ManagementService.executeJob),","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"因此Job可以在單元測試中控制, 要避免與job執行器衝突,可以關閉它","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"默認,JobExecutor在流程引擎啓動時就會激活.","attrs":{}},{"type":"text","text":" 如果不想在流程引擎啓動後自動激活JobExecutor,可以設置","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"配置郵件服務器","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Activiti支持在業務流程中發送郵件,可以在配置中配置郵件服務器","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"配置SMTP郵件服務器來發送郵件","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"配置歷史存儲","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Activiti可以配置來定製歷史存儲信息","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"表達式和腳本暴露配置","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"默認情況下,","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"activiti.cfg.xml","attrs":{}},{"type":"text","text":"和Spring配置文件中所有bean 都可以在表達式和腳本中使用","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"如果要限制配置文件中的bean的可見性,可以通過配置流程引擎配置的beans來配置","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ProcessEngineConfiguration","attrs":{}},{"type":"text","text":"的beans是一個map.**當指定了這個參數,只有包含這個map中的bean可以在表達式和腳本中使用.**通過在map中指定的名稱來決定暴露的bean","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"配置部署緩存","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"因爲流程定義的數據是不會改變的,爲了避免每次使用訪問數據庫,所有流程定義在解析之後都會被緩存","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"默認情況下,不會限制這個緩存.如果想限制流程定義緩存,可以添加如下配置","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"這個配置會把默認的","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"HashMap","attrs":{}},{"type":"text","text":"緩存替換成","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"LRU緩存","attrs":{}},{"type":"text","text":"來提供限制. 這個配置的最佳值跟流程定義的總數有關,實際使用中會具體使用多少流程定義也有關","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"也可以注入自定義的緩存實現,這個bean必須實現","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"org.activiti.engine.impl.persistence.deploy.DeploymentCache","attrs":{}},{"type":"text","text":"接口","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n \n\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"類似的配置有","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"knowledgeBaseCacheLimit","attrs":{}},{"type":"text","text":"和","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"knowledgeBaseCache,","attrs":{}},{"type":"text","text":" 它們是配置規則緩存的.只有","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"流程中使用規則任務時才用","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"日誌","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"從Activiti 5.12開始,所有日誌(activiti,spring,,mybatis等等)都轉發給slf4j允許自定義日誌實現","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"引入Maven依賴log4j實現,需要添加版本","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n org.slf4j\n slf4j-log4j12\n\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"使用Maven的實例,忽略版本","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n org.slf4j\n jcl-over-slf4j\n\n","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"映射診斷上下文","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Activiti支持slf4j的","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"MDC","attrs":{}},{"type":"text","text":"功能, 如下的基礎信息會傳遞到日誌中記錄:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"流程定義ID:","attrs":{}},{"type":"text","text":" mdcProcessDefinitionID","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"流程實例ID:","attrs":{}},{"type":"text","text":" mdcProcessInstanceID","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"分支ID:","attrs":{}},{"type":"text","text":" mdcexecutionId","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"默認不會記錄這些信息,可以配置日誌使用期望的格式來顯示它們,擴展通常的日誌信息.","attrs":{}},{"type":"text","text":" 比如,通過log4j配置定義會讓日誌顯示上面的信息:","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"text"},"content":[{"type":"text","text":" log4j.appender.consoleAppender.layout.ConversionPattern =ProcessDefinitionId=%X{mdcProcessDefinitionID}\nexecutionId=%X{mdcExecutionId}mdcProcessInstanceID=%X{mdcProcessInstanceID} mdcBusinessKey=%X{mdcBusinessKey} %m%n\"\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"當系統進行高風險任務,日誌必須嚴格檢查時,這個功能就非常有用,要使用日誌分析的情況","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"事件處理","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Activiti中實現了一種事件機制,它允許在引擎觸發事件時獲得提醒","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"爲對應的事件類型註冊監聽器,在這個類型的任何時間觸發時都會收到提醒:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"可以添加引擎範圍的事件監聽器,可以通過配置添加引擎範圍的事件監聽器在運行階段使用API","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"添加","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"event-listener","attrs":{}},{"type":"text","text":"到特定流程定義的BPMN XML中","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"所有分發的事件,都是","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"org.activiti.engine.delegate.event.ActivitiEvent","attrs":{}},{"type":"text","text":"的子類.事件包含","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"type,executionId,processInstanceId和processDefinitionId.","attrs":{}},{"type":"text","text":" 對應的事件會包含","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"事件發生時對應上下文的額外信息","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"事件監聽器實現","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"實現事件監聽器要實現","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"org.activiti.engine.delegate.event.ActivitiEventListener.","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"下面監聽器的實現會把所有監聽到的事件打印到標準輸出中,包括job執行的事件異常:","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":"public class MyEventListener implements ActivitiEventListener {\n\n @Override\n public void onEvent(ActivitiEvent event) {\n switch (event.getType()) {\n\n case JOB_EXECUTION_SUCCESS:\n System.out.println(\"A job well done!\");\n break;\n\n case JOB_EXECUTION_FAILURE:\n System.out.println(\"A job has failed...\");\n break;\n\n default:\n System.out.println(\"Event received: \" + event.getType());\n }\n }\n\n @Override\n public boolean isFailOnException() {\n // The logic in the onEvent method of this listener is not critical, exceptions\n // can be ignored if logging fails...\n return false;\n }\n}\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"isFailOnException():","attrs":{}},{"type":"text","text":" 決定了當事件分發時","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"onEvent(..)","attrs":{}},{"type":"text","text":" 方法拋出異常時的行爲","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"返回false,會忽略異常","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"返回true,異常不會忽略,繼續向上傳播,迅速導致當前命令失敗","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"當事件是一個API調用的一部分時(或其他事務性操作,比如job執行), 事務就會回滾","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"當事件監聽器中的行爲不是業務性時,建議返回false","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"activiti提供了一些基礎的實現,實現了事件監聽器的常用場景可以用來作爲基類或監聽器實現的樣例","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"org.activiti.engine.delegate.event.BaseEntityEventListener:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"這個事件監聽器的基類可以用來監聽實體相關的事件,可以針對某一類型實體,也可以是全部實體","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"隱藏了類型檢測,並提供了三個需要重寫的方法:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":3,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"onCreate(..)","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":3,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"onUpdate(..)","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":3,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"onDelete(..)","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":3,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"當實體創建,更新,或刪除時調用","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"對於其他實體相關的事件,會調用","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"onEntityEvent(..)","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"事件監聽器的配置安裝","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"把事件監聽器配置到流程引擎配置中,會在流程引擎啓動時激活,並在引擎啓動過程中持續工作","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"eventListeners","attrs":{}},{"type":"text","text":"屬性需要","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"org.activiti.engine.delegate.event.ActivitiEventListener","attrs":{}},{"type":"text","text":"的隊列","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"通常,我們可以聲明一個內部的bean定義,或使用ref引用已定義的bean.下面的代碼,向配置添加了一個事件監聽器,任何事件觸發時都會提醒它,無論事件是什麼類型:","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n ...\n \n \n \n \n \n\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"爲了監聽特定類型的事件","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"可以使用","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"typedEventListeners","attrs":{}},{"type":"text","text":"屬性","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"它需要一個map參數","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"map的key是逗號分隔的事件名或單獨的事件名","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"map的value是org.activiti.engine.delegate.event.ActivitiEventListener隊列","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"下面的代碼演示了向配置中添加一個事件監聽器,可以監聽job執行成功或失敗:","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n ...\n \n \n \n \n \n \n \n \n \n\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"分發事件的順序是由監聽器添加時的順序決定的","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"首先,會調用所有普通的事件監聽器(eventListeners屬性),按照它們在list中的次序","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"然後,會調用所有對應類型的監聽器(typedEventListeners屬性),對應類型的事件被觸發","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"運行階段添加監聽器","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"通過API:","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"RuntimeService,","attrs":{}},{"type":"text","text":" 在運行階段添加或刪除額外的事件監聽器:","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":"/**\n * Adds an event-listener which will be notified of ALL events by the dispatcher.\n * @param listenerToAdd the listener to add\n */\nvoid addEventListener(ActivitiEventListener listenerToAdd);\n\n/**\n * Adds an event-listener which will only be notified when an event occurs, which type is in the given types.\n * @param listenerToAdd the listener to add\n * @param types types of events the listener should be notified for\n */\nvoid addEventListener(ActivitiEventListener listenerToAdd, ActivitiEventType... types);\n\n/**\n * Removes the given listener from this dispatcher. The listener will no longer be notified,\n * regardless of the type(s) it was registered for in the first place.\n * @param listenerToRemove listener to remove\n */\n void removeEventListener(ActivitiEventListener listenerToRemove);\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"運行階段添加的監聽器引擎重啓後就消失","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"流程定義添加監聽器","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"特定流程定義添加監聽器:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"監聽器只會監聽與這個流程定義相關的事件以及這個流程定義上發起的所有流程實例的事件","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"監聽器實現:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"可以使用全類名定義","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"引用實現了監聽器接口的表達式","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"配置爲拋出一個","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"message,signal,error","attrs":{}},{"type":"text","text":"的","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"BPMN事件","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":5},"content":[{"type":"text","text":"監聽器執行自定義邏輯","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"下面代碼爲一個流程定義添加了兩個監聽器:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"第一個監聽器會接收所有類型的事件,它是通過全類名定義的","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"第二個監聽器只接收作業成功或失敗的事件,它使用了定義在流程引擎配置中的beans屬性中的一個bean","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n \n \n \n \n ...\n\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"對於實體相關的事件,也可以設置爲針對某個流程定義的監聽器,實現只監聽發生在某個流程定義上的某個類型實體事件.下面的代碼演示瞭如何實現這種功能:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"第一個例子:用於監聽所有實體事件","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"第二個例子:用於監聽特定類型的事件","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n \n \n \n \n ...\n\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"entityType支持的值有:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"attachment","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"comment","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"execution","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"identity-link","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"job","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"process-instance","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"process-definition","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"task","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":5},"content":[{"type":"text","text":"監聽拋出BPMN事件","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"另一種處理事件的方法是","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"拋出一個BPMN事件:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"只針對與拋出一個activiti事件類型的BPMN事件,","attrs":{}},{"type":"text","text":" 拋出一個BPMN事件,在流程實例刪除時,會導致一個錯誤","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"下面的代碼演示瞭如何在流程實例中拋出一個signal,把signal拋出到外部流程(全局),在流程實例中拋出一個消息事件,在流程實例中拋出一個錯誤事件.除了使用","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"class","attrs":{}},{"type":"text","text":"或","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"delegateExpression,","attrs":{}},{"type":"text","text":" 還使用了","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"throwEvent","attrs":{}},{"type":"text","text":"屬性,通過額外屬性,指定了拋出事件的類型","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n \n \n \n\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n \n \n \n\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n \n \n \n\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"xml"},"content":[{"type":"text","text":"\n \n \n \n\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"如果需要聲明額外的邏輯,是否拋出BPMN事件,可以擴展activiti提供的監聽器類:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在子類中重寫","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"isValidEvent(ActivitiEvent event),","attrs":{}},{"type":"text","text":" 可以防止拋出BPMN事件.對應的類是:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"org.activiti.engine.impl.bpmn.helper.MessageThrowingEventListener","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"org.activiti.engine.test.api.event.SignalThrowingEventListenerTest","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"org.activiti.engine.impl.bpmn.helper.ErrorThrowingEventListener","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":5},"content":[{"type":"text","text":"流程定義監聽器注意點","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"事件監聽器只能聲明在","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"process","attrs":{}},{"type":"text","text":"元素中,作爲","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"extensionElements","attrs":{}},{"type":"text","text":"的子元素.監聽器不能定義在流程的單個activity下","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"delegateExpression","attrs":{}},{"type":"text","text":"中的表達式無法訪問","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"execution","attrs":{}},{"type":"text","text":"上下文,這與其他表達式不同(比如gateway).它","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"只能引用定義在流程引擎配置的beans屬性中聲明的bean,","attrs":{}},{"type":"text","text":" 或者使用spring(未使用beans屬性)中所有","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"實現了監聽器接口的spring-bean","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"使用監聽器的","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"class","attrs":{}},{"type":"text","text":"屬性時,只會創建一個實例.監聽器實現不會依賴成員變量,是多線程安全的","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"當一個非法的事件類型用在events屬性或throwEvent中時,流程定義發佈時就會拋出異常(會導致部署失敗)","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"如果class或delegateExecution由問題","attrs":{}},{"type":"text","text":":類不存在,不存在的bean引用,或代理類沒有實現監聽器接口","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在流程啓動時拋出異常","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在第一個有效的流程定義事件被監聽器接收時","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"所以要保證引用的類正確的放在classpath下,表達式也要引用一個有效的實例","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"通過API分發事件","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Activiti我們提供了通過API使用事件機制的方法,允許觸發定義在引擎中的任何自定義事件","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"建議只觸發類型爲","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"CUSTOM","attrs":{}},{"type":"text","text":"的","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ActivitiEvents.","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}},{"type":"strong","attrs":{}}],"text":"可以通過","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"RuntimeService","attrs":{}},{"type":"text","text":"觸發事件:","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":"/**\n * Dispatches the given event to any listeners that are registered.\n * @param event event to dispatch.\n *\n * @throws ActivitiException if an exception occurs when dispatching the event or when the {@link ActivitiEventDispatcher}\n * is disabled.\n * @throws ActivitiIllegalArgumentException when the given event is not suitable for dispatching.\n */\n void dispatchEvent(ActivitiEvent event);\n","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"支持的事件類型","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"引擎中每個事件類型都對應","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"org.activiti.engine.delegate.event.ActivitiEventType","attrs":{}},{"type":"text","text":"中的一個枚舉值","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"embedcomp","attrs":{"type":"table","data":{"content":"
事件名稱事件描述事件類型
ENGINE_CREATED監聽器監聽的流程引擎已經創建,準備好接受API調用ActivitiEvent
ENGINE_CLOSED監聽器監聽的流程引擎已經關閉,不再接受API調用ActivitiEvent
ENTITY_CREATED創建了一個新實體,實體包含在事件中ActivitiEntityEvent
ENTITY_INITIALIZED創建了一個新實體,初始化也完成了.如果這個實體的創建會包含子實體的創建,這個事件會在子實體都創建/初始化完成後被觸發,這是與ENTITY_CREATED的區別ActivitiEntityEvent
ENTITY_UPDATED更新了已存在的實體,實體包含在事件中ActivitiEntityEvent
ENTITY_DELETED刪除了已存在的實體,實體包含在事件中ActivitiEntityEvent
ENTITY_SUSPENDED暫停了已存在的實體,實體包含在事件中.會被ProcessDefinitions,ProcessInstances和Tasks拋出ActivitiEntityEvent
ENTITY_ACTIVATED激活了已存在的實體,實體包含在事件中.會被ProcessDefinitions,ProcessInstances和Tasks拋出ActivitiEntityEvent
JOB_EXECUTION_SUCCESS作業執行成功,job包含在事件中ActivitiEntityEvent
JOB_EXECUTION_FAILURE作業執行失敗,作業和異常信息包含在事件中ActivitiEntityEvent<br />ActivitiExceptionEvent
JOB_RETRIES_DECREMENTED因爲作業執行失敗,導致重試次數減少.作業包含在事件中ActivitiEntityEvent
TIMER_FIRED觸發了定時器,job包含在事件中ActivitiEntityEvent
JOB_CANCELED取消了一個作業.事件包含取消的作業.作業可以通過API調用取消,任務完成後對應的邊界定時器也會取消,在新流程定義發佈時也會取消ActivitiEntityEvent
ACTIVITY_STARTED一個節點開始執行ActivitiActivityEvent
ACTIVITY_COMPLETED一個節點成功結束ActivitiActivityEvent
ACTIVITY_SIGNALED一個節點收到了一個信號ActivitiSignalEvent
ACTIVITY_MESSAGE_RECEIVED一個節點收到了一個消息.在節點收到消息之前觸發,收到後,會觸發ACTIVITY_SIGNALACTIVITY_STARTED, 這會根據節點的類型:邊界事件,事件子流程開始事件ActivitiMessageEvent
ACTIVITY_ERROR_RECEIVED一個節點收到了一個錯誤事件.在節點實際處理錯誤之前觸發, 事件的activityId對應着處理錯誤的節點.這個事件後續會是ACTIVITY_SIGNALLEDACTIVITY_COMPLETE, 如果錯誤發送成功的話ActivitiErrorEvent
UNCAUGHT_BPMN_ERROR拋出了未捕獲的BPMN錯誤.流程沒有提供針對這個錯誤的處理器.事件的activityId爲空ActivitiErrorEvent
ACTIVITY_COMPENSATE一個節點將要被補償.事件包含了將要執行補償的節點idActivitiActivityEvent
VARIABLE_CREATED創建了一個變量.事件包含變量名,變量值和對應的分支或任務(如果存在)ActivitiVariableEvent
VARIABLE_UPDATED更新了一個變量.事件包含變量名,變量值和對應的分支或任務(如果存在)ActivitiVariableEvent
VARIABLE_DELETED刪除了一個變量.事件包含變量名,變量值和對應的分支或任務(如果存在)ActivitiVariableEvent
TASK_ASSIGNED任務被分配給了一個人員.事件包含任務ActivitiEntityEvent
TASK_CREATED創建了新任務.它位於ENTITY_CREATE事件之後.當任務是由流程創建時,這個事件會在TaskListener執行之前被執行ActivitiEntityEvent
TASK_COMPLETED任務完成.它會在ENTITY_DELETE事件之前觸發.當任務是流程一部分時,事件會在流程繼續運行之前, 後續事件將是**ACTIVITY_COMPLETE,**對應着完成任務的節點ActivitiEntityEvent
TASK_TIMEOUT任務已超時.在TIMER_FIRED事件之後,會觸發用戶任務的超時事件,當這個任務分配了一個定時器的時候ActivitiEntityEvent
PROCESS_COMPLETED流程已結束.在最後一個節點的ACTIVITY_COMPLETED事件之後觸發.當流程到達的狀態,沒有任何後續連線時,流程就會結束ActivitiEntityEvent
MEMBERSHIP_CREATED用戶被添加到一個組裏.事件包含了用戶和組的idActivitiMembershipEvent
MEMBERSHIP_DELETED用戶被從一個組中刪除.事件包含了用戶和組的idActivitiMembershipEvent
MEMBERSHIPS_DELETED所有成員被從一個組中刪除.在成員刪除之前觸發這個事件,所以他們都是可以訪問的.因爲性能方面的考慮,不會爲每個成員觸發單獨的MEMBERSHIP_DELETED事件ActivitiMembershipEvent
"}}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"引擎內部所有","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ENTITY_","attrs":{}},{"type":"text","text":"* 事件都是與實體相關的,實體事件與實體的對應關係:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"[ENTITY_CREATED],[ENTITY_INITIALIZED],[ENTITY_DELETED]:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Attachment","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Comment","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Deployment","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Execution","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Group","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"IdentityLink","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Job","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Model","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"ProcessDefinition","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"ProcessInstance","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Task","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"User","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ENTITY_UPDATED:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Attachment","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Deployment","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Execution","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Group","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"IdentityLink","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Job","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Model","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"ProcessDefinition","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"ProcessInstance","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Task","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"User","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ENTITY_SUSPENDED, ENTITY_ACTIVATED:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"ProcessDefinition","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"ProcessInstance","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Execution","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Task","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"注意","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"只有同一個流程引擎中的事件會發送給對應的監聽器","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"如果有很多引擎在同一個數據庫運行,事件只會發送給註冊到對應引擎的監聽器.其他引擎發生的事件不會發送給這個監聽器,無論實際上它們運行在同一個或不同的JVM中","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"對應的事件類型都包含對應的實體.根據類型或事件,這些實體不能再進行更新(比如,當實例以被刪除).可能的話,使用事件提供的","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"EngineServices","attrs":{}},{"type":"text","text":"來以安全的方式來操作引擎.即使如此,也要小心的對事件對應的實體進行更新,操作","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"沒有對應歷史的實體事件,因爲它們都有運行階段的對應實體","attrs":{}}]}]}],"attrs":{}}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章