{"id":22480,"date":"2024-03-15T23:39:48","date_gmt":"2024-03-15T23:39:48","guid":{"rendered":"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/"},"modified":"2024-03-21T22:59:02","modified_gmt":"2024-03-21T22:59:02","slug":"how-to-modify-a-deployed-process-in-activiti","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/","title":{"rendered":"How to modify a deployed process in activiti?"},"content":{"rendered":"<p>To modify a deployed process, the use of the API provided by Activiti is possible.<\/p>\n<p>Here is an example code demonstrating how to modify a deployed process.<\/p>\n<pre class=\"post-pre\"><code><span class=\"hljs-comment\">\/\/ \u83b7\u53d6RepositoryService<\/span>\r\n<span class=\"hljs-type\">RepositoryService<\/span> <span class=\"hljs-variable\">repositoryService<\/span> <span class=\"hljs-operator\">=<\/span> processEngine.getRepositoryService();\r\n\r\n<span class=\"hljs-comment\">\/\/ \u67e5\u8be2\u5df2\u90e8\u7f72\u7684\u6d41\u7a0b\u5b9a\u4e49<\/span>\r\n<span class=\"hljs-type\">ProcessDefinition<\/span> <span class=\"hljs-variable\">processDefinition<\/span> <span class=\"hljs-operator\">=<\/span> repositoryService.createProcessDefinitionQuery()\r\n    .processDefinitionKey(<span class=\"hljs-string\">\"processKey\"<\/span>)\r\n    .latestVersion()\r\n    .singleResult();\r\n\r\n<span class=\"hljs-comment\">\/\/ \u83b7\u53d6\u6d41\u7a0b\u5b9a\u4e49\u7684\u8d44\u6e90\u540d\u79f0<\/span>\r\n<span class=\"hljs-type\">String<\/span> <span class=\"hljs-variable\">resourceName<\/span> <span class=\"hljs-operator\">=<\/span> processDefinition.getResourceName();\r\n\r\n<span class=\"hljs-comment\">\/\/ \u8bfb\u53d6\u6d41\u7a0b\u5b9a\u4e49\u7684\u8d44\u6e90\u6587\u4ef6<\/span>\r\n<span class=\"hljs-type\">InputStream<\/span> <span class=\"hljs-variable\">inputStream<\/span> <span class=\"hljs-operator\">=<\/span> repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), resourceName);\r\n\r\n<span class=\"hljs-comment\">\/\/ \u5c06\u8d44\u6e90\u6587\u4ef6\u8f6c\u6362\u4e3aBpmnModel\u5bf9\u8c61<\/span>\r\n<span class=\"hljs-type\">BpmnModel<\/span> <span class=\"hljs-variable\">bpmnModel<\/span> <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">BpmnXMLConverter<\/span>().convertToBpmnModel(<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">InputStreamSource<\/span>(inputStream), <span class=\"hljs-literal\">false<\/span>, <span class=\"hljs-literal\">false<\/span>, <span class=\"hljs-string\">\"UTF-8\"<\/span>);\r\n\r\n<span class=\"hljs-comment\">\/\/ \u5bf9BpmnModel\u8fdb\u884c\u4fee\u6539<\/span>\r\n<span class=\"hljs-comment\">\/\/ ...<\/span>\r\n\r\n<span class=\"hljs-comment\">\/\/ \u5c06\u4fee\u6539\u540e\u7684BpmnModel\u8f6c\u6362\u4e3a\u5b57\u8282\u6570\u7ec4<\/span>\r\n<span class=\"hljs-type\">byte<\/span>[] bpmnBytes = <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">BpmnXMLConverter<\/span>().convertToXML(bpmnModel);\r\n\r\n<span class=\"hljs-comment\">\/\/ \u90e8\u7f72\u4fee\u6539\u540e\u7684\u6d41\u7a0b\u5b9a\u4e49<\/span>\r\n<span class=\"hljs-type\">Deployment<\/span> <span class=\"hljs-variable\">deployment<\/span> <span class=\"hljs-operator\">=<\/span> repositoryService.createDeployment()\r\n    .addBytes(resourceName, bpmnBytes)\r\n    .deploy();\r\n<\/code><\/pre>\n<p>In order to modify a process definition, the RepositoryService needs to be obtained first. Then, the createProcessDefinitionQuery() method can be used to query the deployed process definitions, with conditions such as the key or name of the process definition. Next, the process definition ID and resource name from the query results can be used to retrieve the resource file of the process definition through the getResourceAsStream() method. After converting the resource file to a BpmnModel object, modifications can be made. Once the modifications are complete, the convertToXML() method can be used to convert the BpmnModel to a byte array. A new deployment object can then be created using the createDeployment() method, and the modified byte array can be added to the deployment object using the addBytes() method. Finally, the deploy() method can be used to deploy the modified process definition.<\/p>\n<p>It is important to note that making changes to deployed processes may impact processes instances that are already in progress, so before modifying a process definition, the potential effects on existing process instances should be considered and properly managed.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To modify a deployed process, the use of the API provided by Activiti is possible. Here is an example code demonstrating how to modify a deployed process. \/\/ \u83b7\u53d6RepositoryService RepositoryService repositoryService = processEngine.getRepositoryService(); \/\/ \u67e5\u8be2\u5df2\u90e8\u7f72\u7684\u6d41\u7a0b\u5b9a\u4e49 ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() .processDefinitionKey(&#8220;processKey&#8221;) .latestVersion() .singleResult(); \/\/ \u83b7\u53d6\u6d41\u7a0b\u5b9a\u4e49\u7684\u8d44\u6e90\u540d\u79f0 String resourceName = processDefinition.getResourceName(); \/\/ \u8bfb\u53d6\u6d41\u7a0b\u5b9a\u4e49\u7684\u8d44\u6e90\u6587\u4ef6 InputStream inputStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), resourceName); [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-22480","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to modify a deployed process in activiti? - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to modify a deployed process in activiti?\" \/>\n<meta property=\"og:description\" content=\"To modify a deployed process, the use of the API provided by Activiti is possible. Here is an example code demonstrating how to modify a deployed process. \/\/ \u83b7\u53d6RepositoryService RepositoryService repositoryService = processEngine.getRepositoryService(); \/\/ \u67e5\u8be2\u5df2\u90e8\u7f72\u7684\u6d41\u7a0b\u5b9a\u4e49 ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() .processDefinitionKey(&quot;processKey&quot;) .latestVersion() .singleResult(); \/\/ \u83b7\u53d6\u6d41\u7a0b\u5b9a\u4e49\u7684\u8d44\u6e90\u540d\u79f0 String resourceName = processDefinition.getResourceName(); \/\/ \u8bfb\u53d6\u6d41\u7a0b\u5b9a\u4e49\u7684\u8d44\u6e90\u6587\u4ef6 InputStream inputStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), resourceName); [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-15T23:39:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-21T22:59:02+00:00\" \/>\n<meta name=\"author\" content=\"Sophia Anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:site\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sophia Anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/\"},\"author\":{\"name\":\"Sophia Anderson\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/19a24313de9c988db3d69226b4a40a30\"},\"headline\":\"How to modify a deployed process in activiti?\",\"datePublished\":\"2024-03-15T23:39:48+00:00\",\"dateModified\":\"2024-03-21T22:59:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/\"},\"wordCount\":214,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/\",\"name\":\"How to modify a deployed process in activiti? - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\"},\"datePublished\":\"2024-03-15T23:39:48+00:00\",\"dateModified\":\"2024-03-21T22:59:02+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.silicloud.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to modify a deployed process in activiti?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"name\":\"Silicon Cloud Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\",\"name\":\"Silicon Cloud Blog\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"contentUrl\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"width\":1024,\"height\":1024,\"caption\":\"Silicon Cloud Blog\"},\"image\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\",\"https:\/\/twitter.com\/SiliCloudGlobal\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/19a24313de9c988db3d69226b4a40a30\",\"name\":\"Sophia Anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c726c09aa40e37115fb5c62d0c3ed62c16ca255d3763e2e3ae83a70ddf8c2175?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c726c09aa40e37115fb5c62d0c3ed62c16ca255d3763e2e3ae83a70ddf8c2175?s=96&d=mm&r=g\",\"caption\":\"Sophia Anderson\"},\"url\":\"https:\/\/www.silicloud.com\/blog\/author\/sophiaanderson\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to modify a deployed process in activiti? - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/","og_locale":"en_US","og_type":"article","og_title":"How to modify a deployed process in activiti?","og_description":"To modify a deployed process, the use of the API provided by Activiti is possible. Here is an example code demonstrating how to modify a deployed process. \/\/ \u83b7\u53d6RepositoryService RepositoryService repositoryService = processEngine.getRepositoryService(); \/\/ \u67e5\u8be2\u5df2\u90e8\u7f72\u7684\u6d41\u7a0b\u5b9a\u4e49 ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() .processDefinitionKey(\"processKey\") .latestVersion() .singleResult(); \/\/ \u83b7\u53d6\u6d41\u7a0b\u5b9a\u4e49\u7684\u8d44\u6e90\u540d\u79f0 String resourceName = processDefinition.getResourceName(); \/\/ \u8bfb\u53d6\u6d41\u7a0b\u5b9a\u4e49\u7684\u8d44\u6e90\u6587\u4ef6 InputStream inputStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), resourceName); [&hellip;]","og_url":"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/","og_site_name":"Blog - Silicon Cloud","article_publisher":"https:\/\/www.facebook.com\/SiliCloudGlobal\/","article_published_time":"2024-03-15T23:39:48+00:00","article_modified_time":"2024-03-21T22:59:02+00:00","author":"Sophia Anderson","twitter_card":"summary_large_image","twitter_creator":"@SiliCloudGlobal","twitter_site":"@SiliCloudGlobal","twitter_misc":{"Written by":"Sophia Anderson","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/#article","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/"},"author":{"name":"Sophia Anderson","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/19a24313de9c988db3d69226b4a40a30"},"headline":"How to modify a deployed process in activiti?","datePublished":"2024-03-15T23:39:48+00:00","dateModified":"2024-03-21T22:59:02+00:00","mainEntityOfPage":{"@id":"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/"},"wordCount":214,"commentCount":0,"publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/","url":"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/","name":"How to modify a deployed process in activiti? - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/#website"},"datePublished":"2024-03-15T23:39:48+00:00","dateModified":"2024-03-21T22:59:02+00:00","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/blog\/how-to-modify-a-deployed-process-in-activiti\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.silicloud.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to modify a deployed process in activiti?"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/blog\/#website","url":"https:\/\/www.silicloud.com\/blog\/","name":"Silicon Cloud Blog","description":"","publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.silicloud.com\/blog\/#organization","name":"Silicon Cloud Blog","url":"https:\/\/www.silicloud.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","contentUrl":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","width":1024,"height":1024,"caption":"Silicon Cloud Blog"},"image":{"@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/SiliCloudGlobal\/","https:\/\/twitter.com\/SiliCloudGlobal"]},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/19a24313de9c988db3d69226b4a40a30","name":"Sophia Anderson","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c726c09aa40e37115fb5c62d0c3ed62c16ca255d3763e2e3ae83a70ddf8c2175?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c726c09aa40e37115fb5c62d0c3ed62c16ca255d3763e2e3ae83a70ddf8c2175?s=96&d=mm&r=g","caption":"Sophia Anderson"},"url":"https:\/\/www.silicloud.com\/blog\/author\/sophiaanderson\/"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/22480","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/comments?post=22480"}],"version-history":[{"count":1,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/22480\/revisions"}],"predecessor-version":[{"id":56405,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/22480\/revisions\/56405"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/media?parent=22480"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/categories?post=22480"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/tags?post=22480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}