Deploy BPMN String (not File)

Hi,
so far I used java.io.Files and the repositoryServcie to deploy a process into the workflowengine

DeploymentWithDefinitions d = repositoryService.createDeployment()
 							.addInputStream(fileName,new FileInputStream(convFile))
 							.name(fileName)
 						    .deployWithResult();

But what if I only have a BPMN-String available? How do I deploy a BPMN-String?

Thnaks and best regards
Roland

Hi,

the addInputStream method just needs an input stream. Hence you could probably replace FileInputStream with something like;

InputStream is = new ByteArrayInputStream(str.getBytes());

where str is your String

regards

Rob

Check out this method: https://docs.camunda.org/javadoc/camunda-bpm-platform/7.8/org/camunda/bpm/engine/repository/DeploymentBuilder.html#addString(java.lang.String,%20java.lang.String)

1 Like

Hi Rob, Thorben

thanks for your reply. I tried the addString() method. Works like charme. The only thing one has to remember is to put the “.bpmn” suffix to the resourcename, otherwise the deployment will fail.

See suffix requirements for resource names: https://docs.camunda.org/javadoc/camunda-bpm-platform/7.8/org/camunda/bpm/engine/repository/DeploymentBuilder.html .

Thank you very much
Roland

1 Like