camunda-workflow 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58f9e45eda5edf72f257ab51baba32f2220b0827a288d7a8b2ab273ff2835738
4
- data.tar.gz: db225b2cda8437c4bec69cf70f351037174c35bef5a0dbf57155162e813ff996
3
+ metadata.gz: a0d3b0b64c74b94ea30da234937034f57514ccc70c88d39b249ec4d58d6656f5
4
+ data.tar.gz: 7cf0641100c47867188ff70bb420798345a178ae76ad46142100e893cc39c4a2
5
5
  SHA512:
6
- metadata.gz: 184e3cca0f5ac05638470045b50aa053a7f31ff36be976e8ed429d5bdd6b4270643e8b2d79d38fb448f8d256ce5d6e7f8c9b303e12451c43e05609ac174e2344
7
- data.tar.gz: 73b2bb72fa227bf85cd9fe5f9d54e3f61040b9760d0157d43ea90530de12fb4856b51aa7869fd45aeffb13cdfa84b2fc509b803a255af2352edc6ca47c25f72f
6
+ metadata.gz: e454dd0b2ed5c3380ff19243ae7899b3a59a378e2bc50b60e8e5032f88cfd3b8347a75c18aaf10badfaa376d7afca52725daf010c33c899633c02b586665ccbb
7
+ data.tar.gz: c2274f504b54e1d15c7d8af1313bb791f4242bbd5fbfae4ef7af3dbacadbc26ca44a4763e80701ced9e64c43a7e0112c9c01114fb779ad02fcfb517d0e5621df
@@ -1,5 +1,46 @@
1
1
  # Changelog
2
2
 
3
+ ## [Unreleased](https://github.com/amalagaura/camunda-workflow/tree/HEAD)
4
+
5
+ [Full Changelog](https://github.com/amalagaura/camunda-workflow/compare/v0.2.0...HEAD)
6
+
7
+ **Closed issues:**
8
+
9
+ - Remove check for what bpmn\_perform returns. Ignore if not a hash. [\#27](https://github.com/amalagaura/camunda-workflow/issues/27)
10
+
11
+ ## [v0.2.0](https://github.com/amalagaura/camunda-workflow/tree/v0.2.0) (2019-12-20)
12
+
13
+ [Full Changelog](https://github.com/amalagaura/camunda-workflow/compare/v0.1.5...v0.2.0)
14
+
15
+ **Closed issues:**
16
+
17
+ - Change the diagrams symlink to resources and change the symlink structure [\#25](https://github.com/amalagaura/camunda-workflow/issues/25)
18
+ - remove listen note since it seems to have gone away [\#23](https://github.com/amalagaura/camunda-workflow/issues/23)
19
+ - Rename fetch\_and\_execute to fetch\_and\_queue [\#22](https://github.com/amalagaura/camunda-workflow/issues/22)
20
+ - Add a backtrace silencer to remove extra backtrace information from exceptions reported to Camunda [\#18](https://github.com/amalagaura/camunda-workflow/issues/18)
21
+
22
+ **Merged pull requests:**
23
+
24
+ - Ignore if a Hash is not returned from bpmn\_perform [\#28](https://github.com/amalagaura/camunda-workflow/pull/28) ([amalagaura](https://github.com/amalagaura))
25
+ - Change symlink structure and change bpmn/diagrams to bpmn/resources [\#26](https://github.com/amalagaura/camunda-workflow/pull/26) ([amalagaura](https://github.com/amalagaura))
26
+ - Change fetch\_and\_execute to fetch\_and\_queue [\#24](https://github.com/amalagaura/camunda-workflow/pull/24) ([amalagaura](https://github.com/amalagaura))
27
+ - Add backtrace cleaner to only relevant lines for error incidents [\#21](https://github.com/amalagaura/camunda-workflow/pull/21) ([amalagaura](https://github.com/amalagaura))
28
+
29
+ ## [v0.1.5](https://github.com/amalagaura/camunda-workflow/tree/v0.1.5) (2019-12-19)
30
+
31
+ [Full Changelog](https://github.com/amalagaura/camunda-workflow/compare/v0.1.4...v0.1.5)
32
+
33
+ **Closed issues:**
34
+
35
+ - Add some more screenshots [\#16](https://github.com/amalagaura/camunda-workflow/issues/16)
36
+
37
+ **Merged pull requests:**
38
+
39
+ - Upgrading gems and changing bpmn error message [\#20](https://github.com/amalagaura/camunda-workflow/pull/20) ([amalagaura](https://github.com/amalagaura))
40
+ - Rake feature [\#19](https://github.com/amalagaura/camunda-workflow/pull/19) ([curatingbits](https://github.com/curatingbits))
41
+ - Update readme with screenshots [\#17](https://github.com/amalagaura/camunda-workflow/pull/17) ([amalagaura](https://github.com/amalagaura))
42
+ - Add assert scenario test for sample.bpmn [\#15](https://github.com/amalagaura/camunda-workflow/pull/15) ([curatingbits](https://github.com/curatingbits))
43
+
3
44
  ## [v0.1.4](https://github.com/amalagaura/camunda-workflow/tree/v0.1.4) (2019-12-11)
4
45
 
5
46
  [Full Changelog](https://github.com/amalagaura/camunda-workflow/compare/v0.1.3...v0.1.4)
@@ -26,6 +67,7 @@
26
67
 
27
68
  - Raise Submission errors if Camunda does not accept completion [\#11](https://github.com/amalagaura/camunda-workflow/pull/11) ([amalagaura](https://github.com/amalagaura))
28
69
  - Allow Poller to not exit its loop when there is a missing class and report error [\#8](https://github.com/amalagaura/camunda-workflow/pull/8) ([amalagaura](https://github.com/amalagaura))
70
+ - Add rubocop rspec [\#6](https://github.com/amalagaura/camunda-workflow/pull/6) ([amalagaura](https://github.com/amalagaura))
29
71
 
30
72
  ## [v0.1.2](https://github.com/amalagaura/camunda-workflow/tree/v0.1.2) (2019-11-27)
31
73
 
@@ -33,7 +75,6 @@
33
75
 
34
76
  **Merged pull requests:**
35
77
 
36
- - Add rubocop rspec [\#6](https://github.com/amalagaura/camunda-workflow/pull/6) ([amalagaura](https://github.com/amalagaura))
37
78
  - Correct find\_by\_business\_key\_and\_task\_definition\_key! [\#5](https://github.com/amalagaura/camunda-workflow/pull/5) ([amalagaura](https://github.com/amalagaura))
38
79
  - added authentication via templates for spring\\_boot generator and Her [\#4](https://github.com/amalagaura/camunda-workflow/pull/4) ([curatingbits](https://github.com/curatingbits))
39
80
  - Refactor to return proper Her models after responses [\#3](https://github.com/amalagaura/camunda-workflow/pull/3) ([amalagaura](https://github.com/amalagaura))
@@ -7,7 +7,7 @@ Make sure whatever you are adding has specs. We should be able to maintain 100%
7
7
 
8
8
  ### Camunda interactions
9
9
 
10
- We are using VCR to record interactions with a local Camunda engine. If you wish to try this run a camunda engine listening on `/rest`. `/rest` is the default of the spring boot application that we generate with this gem. This is different from the default `/rest-engine` of the default downloadable distribution.
10
+ We are using VCR to record interactions with a local Camunda engine.
11
11
 
12
12
  You can for instance upgrade the Camunda version, delete the `spec/vcr` folder and then re-run the specs with `bundle exec rspec`
13
13
 
@@ -17,4 +17,4 @@ This project is in the worldwide [public domain](LICENSE.md). As stated in [CONT
17
17
 
18
18
  > This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/).
19
19
  >
20
- > All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.
20
+ > All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.
data/README.md CHANGED
@@ -1,136 +1,142 @@
1
- [![Build Status](https://travis-ci.com/amalagaura/camunda-workflow.svg?branch=master)](https://travis-ci.com/amalagaura/camunda-workflow)
1
+ [![Build Status](https://travis-ci.com/amalagaura/camunda-workflow.svg?branch=master)](https://travis-ci.com/amalagaura/camunda-workflow)
2
2
  [![Gem Version](https://badge.fury.io/rb/camunda-workflow.svg)](https://badge.fury.io/rb/camunda-workflow)
3
3
  [![Inline docs](http://inch-ci.org/github/amalagaura/camunda-workflow.svg?branch=master)](http://inch-ci.org/github/amalagaura/camunda-workflow)
4
4
  # Camunda Workflow
5
5
 
6
6
  ## An opinionated interface to Camunda for Ruby/Rails apps
7
7
 
8
- [Her](https://github.com/remiprev/her) is used to communicate with the [Camunda REST API](https://docs.camunda.org/manual/latest/reference/rest/) with a Ruby class corresponding to a Camunda external task.
8
+ Camunda Workflow uses [Her](https://github.com/remiprev/her) to communicate with the [Camunda REST API](https://docs.camunda.org/manual/latest/reference/rest/). It executes [External Service Tasks](https://docs.camunda.org/manual/latest/user-guide/process-engine/external-tasks/) using a Ruby class corresponding to each Camunda external task.
9
9
 
10
- ### Add to your Gemfile
11
- ```ruby
12
- gem 'camunda-workflow'
13
- ```
14
10
 
15
11
  ## Camunda Integration with Ruby
16
- The process definitions key becomes the module name of your implementation classes and must be set to the name of a ruby style constant.
17
-
18
- ![image](https://user-images.githubusercontent.com/498234/70742441-899ecf00-1ceb-11ea-9eb8-42dbb08dbd2d.png)
19
12
 
13
+ The Camunda model process definition key is the module name of your implementation classes.
14
+
15
+ ![image](https://user-images.githubusercontent.com/498234/71268690-82934480-231b-11ea-9c58-0500b7ace028.png)
20
16
 
21
- An external task is created with a Ruby class name for the id. And the process definition key should be set as the topic name.
17
+ An external task is created with a Ruby class name for the id. And the process definition key should be set as the topic name.
22
18
 
23
- ![image](https://user-images.githubusercontent.com/498234/70742635-fd40dc00-1ceb-11ea-8518-0fa5f6ea8028.png)
19
+ ![image](https://user-images.githubusercontent.com/498234/71268753-af475c00-231b-11ea-8b39-89d2f306539b.png)
24
20
 
25
- Tasks are pulled and fetched and locked and then run. We expect classes (ActiveJob) to implement each external task.
21
+ Tasks are fetched, locked and then queued. We expect classes (ActiveJob) to implement each external task. So, according to the above screenshots, the poller and queuer will expect a class called `SomeProcess::SomeTask` to be implemented in your app.
26
22
 
27
23
  ### Integration with your worker classes
28
24
 
29
- The module `ExternalTaskJob` should be included in your job implementation classes. The job implementation classes can inherit from `ActiveJob::Base`, or use `Sidekiq::Worker` or use some other system for job queuing.
25
+ Worker classes should inherit from `CamundaJob`. It is generated with `rails g camunda:install`.
30
26
 
31
- Currently we call `perform_later` on job implementation classes. If we want to make this more flexible, we need to make the method used to queue jobs configurable. `perform_later` for ActiveJob, `perform_async` for Sidekiq, or `perform` if no background task system is used.
27
+ `perform` is implemented on `Camunda::ExternalTaskJob`. It calls `bpmn_perform` with variables from Camunda and returns the results back to Camunda.
28
+ ```
29
+ class CamundaJob < ApplicationJob
30
+ # If using Sidekiq, change to include Sidekiq::Worker instead of inheriting from ApplicationJob
31
+ include Camunda::ExternalTaskJob
32
+ end
32
33
 
33
- ### Implementing `bpmn_perform`
34
+ class SomeProcess::SomeTask < CamundaJob
35
+ def bpmn_perform(variables)
36
+ do_something(variables[:foo])
34
37
 
35
- `bpmn_perform` is your implementation of the service task.
38
+ # A hash returned will become variables in the Camunda BPMN process instance
39
+ { foo: 'bar', foo2: { json: "str" }, array_var: ["str"] }
40
+ end
41
+ end
42
+ ```
43
+
44
+ ### Exceptions create Camunda incidents
45
+ If your implementation throws an exception, it is caught and then sent to Camunda with a stack trace.
46
+ ![image](https://user-images.githubusercontent.com/498234/71266361-35f93a80-2316-11ea-96ed-6501ef68f849.png)
36
47
 
48
+ ![image](https://user-images.githubusercontent.com/498234/71269561-a22b6c80-231d-11ea-80af-b748ba7eb09a.png)
37
49
  ### Supporting bpmn exceptions
38
50
 
39
- Camunda supports throwing bpmn exceptions on a service task to communicate logic errors and not underlying code errors. These expected errors are thrown with
51
+ Camunda supports throwing bpmn exceptions on a service task to communicate logic errors and not underlying code errors. These expected errors are thrown with
40
52
  ```ruby
41
- raise Camunda::BpmnError.new error_code: 'bpmn-error', message: "Special BPMN error", variables: { bpmn: 'error' }
53
+ class SomeProcess::SomeTask < CamundaJob
54
+ def bpmn_perform(variables)
55
+ result = do_something(variables[:foo])
56
+
57
+ if result == :expected
58
+ { foo: 'bar', foo2: { json: "str" }, array_var: ["str"] }
59
+ else
60
+ raise Camunda::BpmnError.new error_code: 'bpmn-error', message: "Special BPMN error", variables: { bpmn: 'error' }
61
+ end
62
+ end
63
+ end
42
64
  ```
43
65
 
44
66
  ## Generators
45
67
 
46
- ### BPMN ActiveJob install
68
+ ### Java Spring Boot App install
69
+ ```bash
70
+ rails generate camunda:spring_boot
71
+ ```
72
+ Creates a skeleton Java Spring Boot app, which also contains the minimal files to run unit tests on a BPMN file. The Spring boot app can be used to
73
+ start a Camunda instance with a REST api and also be deployed to PCF by generating a Spring Boot jar and pushing it.
74
+
75
+ ### BPMN ActiveJob install
47
76
  ```bash
48
77
  rails generate camunda:install
49
78
  ```
50
-
51
- Creates `app/jobs/camunda_job.rb`. A class which inherits from ApplicationJob and includes `ExternalTaskJob`. It can be changed to include
52
- Sidekiq::Worker instead.
79
+ Creates `app/jobs/camunda_job.rb`. A class that inherits from ApplicationJob and includes `ExternalTaskJob`. It can be changed to include `Sidekiq::Worker` instead.
53
80
 
54
81
  All of the BPMN worker classes will inherit from this class
55
82
 
56
- ### Java Spring Boot App install
57
- ```bash
58
- rails generate camunda:spring_boot
59
- ```
60
- Creates a skeleton Java Spring Boot app, which also contains the minimal files to run unit tests on a BPMN file. This can be used to
61
- start a Camunda instance with a REST api. This can also be deployed to PCF by generating a Spring Boot jar and pushing it.
62
-
63
83
  ### BPMN Classes
64
84
  ```bash
65
85
  rails generate camunda:bpmn_classes
66
86
  ```
67
-
68
- Parses the BPMN file and creates task classes according to the ID of the process file and the ID of
69
- each task. It checks each task and only creates it if the topic name is the same as the process ID. This
70
- allows one to have some tasks be handled outside the Rails app. It confirms that the ID's are valid Ruby constant names.
87
+ Parses the BPMN file and creates task classes according to the ID of the process file and the ID of each task. It checks each task and only creates it if the topic name is the same as the process ID. This allows one to have some tasks be handled outside the Rails app. It confirms that the ID's are valid Ruby constant names.
71
88
 
72
89
  #### Starting the Camunda server for development
73
90
 
74
- [Java 7](https://www.java.com/en/) and [Apache Maven](https://maven.apache.org/install.html) are requirements to run
75
- [Spring](https://docs.spring.io/spring-boot/docs/1.5.21.RELEASE/reference/html/getting-started-system-requirements.html).
76
- Make sure all requirements for Spring are satisfied before starting Camunda engine via spring boot.
91
+ [Java 7](https://www.java.com/en/) and [Apache Maven](https://maven.apache.org/install.html) are requirements to run the Camunda server. We are using the [Spring](https://docs.spring.io/spring-boot/docs/1.5.21.RELEASE/reference/html/getting-started-system-requirements.html) distribution. The Camunda application has a `pom.xml`, which Maven uses to install the required dependencies.
77
92
 
78
- Start the application:
93
+ Start the application:
79
94
  ```bash
80
- cd bpmn/java_app
81
- ```
82
- ```bash
95
+ cd bpmn/java_app
83
96
  mvn spring-boot:run
84
- ```
85
- The following Rake commands are available to maintain the spring boot server.
86
97
 
87
- ```Bash
88
- # Install the spring-boot app dependencies.
89
- rake camunda:install
90
- ```
91
- We suggest (not required) running the install command before running the spring boot server for the first time or if the pom.xml file is updated. The
92
- install cleans up artifacts created by prior builds and installs the package dependencies into the local repository.
93
-
94
- ```bash
95
- # Start the Camunda spring boot app
98
+ # Or use the included rake task:
99
+ # Start the Camunda spring boot app with `mvn spring-boot:run`
96
100
  rake camunda:run
97
101
  ```
98
102
 
103
+ If you create Java based unit tests for your bpmn file they can be run with an included rake task as well.
104
+
105
+
106
+ #### Running java unit tests
99
107
  ```bash
100
- # Runs spring boot test suite
108
+ cd bpmn/java_app
109
+ mvn clean test
110
+
111
+ # Or use the included rake task:
112
+ # Runs spring boot test suite with `mvn clean test`
101
113
  rake camunda:test
102
114
  ```
103
-
104
-
105
- Camunda-workflow defaults to an in-memory, h2 database engine. If you rather use a Postgres database engine, comment out the
106
- h2 database engine settings in the `pom.xml` file located in `bpmn/java_app`. Default settings for using Postgres are available in the `pom.xml` file.
107
- You will need to create a Postgres database on localhost called `camunda`.
108
115
 
109
- #### Engine Route Prefix using the Java Spring Boot app
110
- The default engine route prefix for the provided Java Spring Boot app is `rest`. If you choose to download and use the Camunda distribution,
111
- the engine prefix is `rest-engine`. Camunda-workflow is configured to use `rest-engine`.
116
+ Camunda-workflow defaults to an in-memory, h2 database engine. If you rather use a Postgres database engine, comment out the h2 database engine settings in the `pom.xml` file located in `bpmn/java_app`. Default settings for using Postgres are available in the `pom.xml` file.
117
+ You will need to create a Postgres database on localhost called `camunda`.
112
118
 
113
- To override the default engine route prefix to allow your rails application to use the route prefix of `rest`, you need to add an initializer file
114
- in your rails app with the below code.
119
+ ### Configuration
120
+ #### Engine Route Prefix of the Java Spring Boot app
121
+ The default engine route prefix for the provided Java Spring Boot app is `rest`. If you choose to download and use the Camunda distribution, the engine prefix is `rest-engine`. Camunda-workflow is configured to use `rest` by default.
115
122
 
123
+ To override the default engine route prefix, you need to add an initializer file in your rails app.
116
124
 
117
125
  ```ruby
118
126
  # filename initializers/camunda.rb
119
127
  Camunda::Workflow.configure do |config|
120
- config.engine_route_prefix = 'rest'
128
+ config.engine_route_prefix = 'rest-engine'
121
129
  end
122
130
  ```
123
131
  #### Enable HTTP Basic Auth for Java Spring Boot app
124
- To add authentication to Camunda's REST API within the Java Spring Boot app change the `camunda.authentication` variable located in the
125
- `application.properties` (bpmn/java_app/src/main/resources) file to `true`. Creating an environment variable `ENV['CAMUNDA_AUTH']` and setting a value of `true` or `false` will
126
- set the value as well. When HTTP Basic Auth is enabled, it's required that a user with the appropriate permissions is setup in Camunda.
127
- Otherwise, the request will return as `401 unauthorized`. Users are set up within the admin dashboard of Camunda and used to authenticate by passing an Authorization header during requests to the REST API. Below is how to configure
128
- the `camunda_user` and `camunda_password` to be used in the header request to authenticate using HTTP Basic Auth.
132
+
133
+ Authentication can be enabled in the Camunda Java Spring Boot app by setting an environment variable `CAMUNDA_AUTH` to `true` or `false` or by setting the `camunda.authentication` variable located in the `application.properties` (bpmn/java_app/src/main/resources) file to `true`.
134
+
135
+ When HTTP Basic Auth is enabled, it's required that a user with the appropriate permissions is setup in Camunda. Otherwise, the request will return as `401 unauthorized`. Users are set up within the admin dashboard of Camunda and used to authenticate by passing an Authorization header during requests to the REST API. Below is how to configure the `camunda_user` and `camunda_password` to be used in the header request to authenticate using HTTP Basic Auth.
129
136
 
130
137
  ```ruby
131
138
  # filename initializers/camunda.rb
132
139
  Camunda::Workflow.configure do |config|
133
- config.engine_route_prefix = 'rest'
134
140
  config.camunda_user = ENV['CAMUNDA_USER']
135
141
  config.camunda_password = ENV['CAMUNDA_PASSWORD']
136
142
  end
@@ -145,19 +151,18 @@ The jar is in `target/camunda-bpm-springboot.jar`
145
151
 
146
152
  It will fail to start. Create a postgres database as a service in PCF and bind it to the application. The Springboot application is configured for Postgres and will then be able to start.
147
153
 
148
- #### Running java unit tests
149
- ```bash
150
- # Run in bpmn/java_app directory
151
- mvn clean test
154
+ ## Usage
155
+
156
+ ### Add to your Gemfile
157
+ ```ruby
158
+ gem 'camunda-workflow'
152
159
  ```
153
160
 
154
- ## Usage
155
161
  ### Deploying a model
156
- Uses a default name, etc. Below outlines how to deploy a process using the included sample.bpmn
157
- file created by the generator. Alternatively you can deploy using Camunda Modeler
162
+ Uses a default name, etc. Below outlines how to deploy a process using the included sample.bpmn file created by the generator. Alternatively you can deploy using Camunda Modeler
158
163
 
159
164
  ```ruby
160
- Camunda::Deployment.create file_name: 'bpmn/diagrams/sample.bpmn'
165
+ Camunda::Deployment.create file_name: 'bpmn/diagrams/sample.bpmn'
161
166
  ```
162
167
  ### Processes
163
168
 
@@ -176,47 +181,44 @@ will be converted to:
176
181
 
177
182
  #### Destroy a process
178
183
  ```ruby
179
- Camunda::ProcessInstance.destroy_existing start_response.id
180
- ```
184
+ Camunda::ProcessInstance.destroy_existing start_response.id
185
+ ```
181
186
 
182
187
  ### Tasks
183
188
 
184
189
  #### Fetch tasks and queue with ActiveJob
185
190
 
186
- The poller will run as an infinite loop with long polling to fetch tasks, queue, and run them. Topic is the process definition key,
187
- as show in the screenshot example from the Camunda Modeler.
191
+ The poller runs an infinite loop with long polling to fetch tasks, queue, and run them. The topic is the process definition key, as shown in the screenshot example from the Camunda Modeler.
192
+
193
+ Below will run the poller to fetch, lock, and run a task for the example process definition located in the `starting a process` detailed above.
188
194
 
189
- Below will run the poller to fetch, lock, and run a task for the example process definition located in
190
- the `starting a process` detailed above.
195
+ Poller will need to run in a separate process or thread and needs to be running constantly in order to poll Camunda and queue jobs.
191
196
 
192
197
  ```ruby
193
- Camunda::Poller.fetch_and_execute %w[CamundaWorkflow]
194
- ```
198
+ Camunda::Poller.fetch_and_queue %w[CamundaWorkflow]
199
+ ```
195
200
 
196
- #### Fetch tasks
197
- For testing from the console
201
+ #### Fetch tasks For testing from the console
198
202
 
199
203
  ```ruby
200
- tasks = Camunda::ExternalTask.fetch_and_lock %w[CamundaWorkflow]
201
- ```
202
-
204
+ tasks = Camunda::ExternalTask.fetch_and_lock %w[CamundaWorkflow]
205
+ ```
203
206
  #### Run a task
204
207
 
205
208
  ```ruby
206
- tasks.each(&:run_now)
207
- ```
209
+ tasks.each(&:run_now)
210
+ ```
208
211
 
209
212
 
210
213
  ### User Tasks
211
214
  #### Mark a user task complete
212
215
  ```ruby
213
- task = Camunda::Task.find_by_business_key_and_task_definition_key!(instance_business_key, task_key)
214
- # Or you can query Camunda::Task with other parameters like assignee
215
- task.complete!(var1: 'value')
216
+ # Or you can query Camunda::Task with other parameters like assignee task.complete!(var1: 'value')
217
+ Camunda::Task.find_by_business_key_and_task_definition_key!(instance_business_key, task_key).complete!
216
218
  ```
217
219
 
218
220
  ### Rspec Helpers
219
- RSpec helpers can will validate your application to make sure it has a class for every External task in a given BPMN file.
221
+ RSpec helpers validate your application to make sure it has a class for every External task in a given BPMN file.
220
222
  ```ruby
221
223
  require 'camunda/matchers'
222
224
 
@@ -228,30 +230,6 @@ RSpec.describe "BPMN Diagrams" do
228
230
  end
229
231
  end
230
232
  ```
231
- #### Note:
232
-
233
- If you get an error
234
-
235
- ** ERROR: directory is already being watched! **
236
-
237
- Directory: bpmn/java_app/src/main/resources
238
- is already being watched through: bpmn/diagrams
239
-
240
- MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
241
-
242
- It is because ActionMailer preview causes test/mailers/previews to get added to the Rails EventedFileChecker
243
- by default. RSpec is supposed to override it, but it is not
244
- appropriately overridden for EventedFileChecker and/or you don't have spec/mailers/preview existing. If that
245
- directory does not exist, it goes to the first common directory that exists, which is your Rails root folder.
246
- So EventedFileChecker is listening to your entire Rails folder. Not a big problem, but it causes a problem
247
- for our created symlink.
248
-
249
- So add:
250
-
251
- config.action_mailer.show_previews = false
252
-
253
- to your `development.rb` file to solve listen errors about a symlink. Unless you are using ActionMailer
254
- previews, in which case you should have the directory created already.
255
233
 
256
234
  ## Contributing
257
235
 
@@ -10,7 +10,7 @@ class Camunda::Deployment < Camunda::Model
10
10
  # Deploys a new process definition to Camunda and returns an instance of Camunda::ProcessDefinition.
11
11
  # @note Only supporting .create which uses a POST on deployment/create.
12
12
  # @example
13
- # pd = Camunda::Deployment.create(file_names: ['bpmn/diagrams/sample.bpmn']).first
13
+ # pd = Camunda::Deployment.create(file_names: ['bpmn/resources/sample.bpmn']).first
14
14
  # @param files_names [Array<String>] file paths of the bpmn file for deployment
15
15
  # @param tenant_id [String] supplied when a single Camunda installation should serve more than one tenant
16
16
  # @param deployment_source [String] the source of where the deployment occurred.
@@ -1,4 +1,5 @@
1
1
  require 'active_support/core_ext/string/inflections.rb'
2
+ require 'active_support/backtrace_cleaner'
2
3
  # External Tasks are the task entity for camunda. We can query the topic and lock the task. After the task
3
4
  # is locked, the external task of the process instance can be worked and completed. Below is an excerpt from the Camunda
4
5
  # documentation regarding the ExternalTask process.
@@ -41,7 +42,9 @@ class Camunda::ExternalTask < Camunda::Model
41
42
  variables_information = "Input variables are #{input_variables.inspect}\n\n" if input_variables.present?
42
43
  self.class.post_raw("#{collection_path}/#{id}/failure",
43
44
  workerId: worker_id, errorMessage: exception.message,
44
- errorDetails: variables_information.to_s + exception.full_message)[:response]
45
+ errorDetails:
46
+ variables_information.to_s +
47
+ backtrace_cleaner.clean(exception.backtrace).join("\n"))[:response]
45
48
  end
46
49
 
47
50
  # Reports the error to Camunda and creates an incident for the process instance.
@@ -144,6 +147,17 @@ class Camunda::ExternalTask < Camunda::Model
144
147
  raise Camunda::MissingImplementationClass, task_class_name unless klass
145
148
  end
146
149
  end
150
+
151
+ private
152
+
153
+ def backtrace_cleaner
154
+ @backtrace_cleaner ||= ActiveSupport::BacktraceCleaner.new.tap do |bc|
155
+ Camunda::Workflow.configuration.backtrace_silencer_lines.each do |line|
156
+ bc.add_silencer { |exception_line| exception_line =~ /#{line}/ }
157
+ end
158
+ end
159
+ end
160
+
147
161
  # If the BPMN file expects a variable and the variable isn't supplied with an SubmissionError will be raised
148
162
  # indicating that the variable does not exist.
149
163
  class SubmissionError < StandardError
@@ -13,8 +13,7 @@ module Camunda::ExternalTaskJob
13
13
  # @raise [Camunda::ExternalTask::SubmissionError] if Camunda does not accept the submission of the task
14
14
  def perform(id, input_variables)
15
15
  output_variables = bpmn_perform(input_variables)
16
- output_variables = {} if output_variables.nil?
17
- raise ArgumentError, "Expected a hash, got #{output_variables}" unless output_variables.is_a?(Hash)
16
+ output_variables = {} unless output_variables.is_a?(Hash)
18
17
 
19
18
  report_completion id, output_variables
20
19
  rescue Camunda::BpmnError => e
@@ -1,13 +1,19 @@
1
1
  # The poller will run as an infinite loop with long polling to fetch tasks, queue, and run them.
2
- # Topic is the process definition key. Below will run the poller to fetch, lock, and run a task for the
2
+ # Topic is the process definition key. Below will run the poller to fetch, lock, and queue a task for the
3
3
  # example process definition with an id of CamundaWorkflow.
4
4
  # @example
5
- # Camunda::Poller.fetch_and_execute %w[CamundaWorkflow]
5
+ # Camunda::Poller.fetch_and_queue %w[CamundaWorkflow]
6
6
  class Camunda::Poller
7
+ # @deprecated Please use {#fetch_and_queue} instead
8
+ def self.fetch_and_execute(topics, lock_duration: nil, long_polling_duration: nil)
9
+ warn "[DEPRECATION] `fetch_and_execute` is deprecated. Please use `fetch_and_queue` instead."
10
+ fetch_and_queue(topics, lock_duration: lock_duration, long_polling_duration: long_polling_duration)
11
+ end
12
+
7
13
  # @param topics [Array] process definition keys
8
14
  # @param lock_duration [Integer] lock duration time, default time is set in Camunda::Workflow.configuration
9
15
  # @param long_polling_duration [Integer] long polling time, default is set to Camunda::Workflow.configuration
10
- def self.fetch_and_execute(topics, lock_duration: nil, long_polling_duration: nil)
16
+ def self.fetch_and_queue(topics, lock_duration: nil, long_polling_duration: nil)
11
17
  loop do
12
18
  Camunda::ExternalTask
13
19
  .fetch_and_lock(topics, lock_duration: lock_duration, long_polling_duration: long_polling_duration).each do |task|
@@ -61,16 +61,20 @@ module Camunda
61
61
  # Camunda password is supplied with the Camunda user to authenticate using HTTP Basic Auth.
62
62
  # @return [String] Camunda password for HTTP Basic Auth
63
63
  attr_accessor :camunda_password
64
+ # Can configure the backtrace silencer
65
+ # @return [Array<String>] List of backtrace silencer strings which are used to clean incident backtraces
66
+ attr_accessor :backtrace_silencer_lines
64
67
 
65
68
  def initialize
66
69
  @engine_url = 'http://localhost:8080'
67
- @engine_route_prefix = 'rest-engine'
70
+ @engine_route_prefix = 'rest'
68
71
  @camunda_user = ''
69
72
  @camunda_password = ''
70
73
  @worker_id = '0'
71
74
  @lock_duration = 14.days
72
75
  @max_polling_tasks = 2
73
76
  @long_polling_duration = 30.seconds
77
+ @backtrace_silencer_lines = %w[gems/activesupport gems/sidekiq gems/activejob gems/i18n gems/actionpack]
74
78
  @tenant_id = if defined?(Rails)
75
79
  Rails.env.test? ? 'test-environment' : nil
76
80
  end
@@ -1,5 +1,5 @@
1
1
  module Camunda
2
2
  module Workflow
3
- VERSION = '0.1.5'.freeze
3
+ VERSION = '0.2.0'.freeze
4
4
  end
5
5
  end
@@ -9,4 +9,4 @@ Example:
9
9
 
10
10
  with a sample BPMN file and Unit Test.
11
11
 
12
- The suggested location for your BPMN file is in `bpmn/diagrams`. `bpmn/java_app/src/main/resources` is a symlink to that.
12
+ The suggested location for your BPMN file is in `bpmn/resources` which symlinks to `bpmn/java_app/src/main/resources`.
@@ -5,30 +5,31 @@ module Camunda
5
5
  # Spring Boot jar and pushing it.
6
6
  class SpringBootGenerator < Rails::Generators::Base
7
7
  source_root File.expand_path('templates', __dir__)
8
- class_option :app_path, type: :string, default: 'bpmn/java_app'
9
- class_option :diagram_path, type: :string, default: 'bpmn/diagrams'
8
+ class_option :bpmn_folder_name, type: :string, default: 'bpmn'
9
+ class_option :java_app_folder_name, type: :string, default: 'java_app'
10
+ class_option :resources_folder_name, type: :string, default: 'resources'
10
11
 
11
- # Links resources to a top level diagrams folder
12
+ # Links resources to the java app resources folder
12
13
  def link_resources_folder
13
- create_link File.join(bpmn_app_path, 'src/main/resources/'), File.join('../../../diagrams')
14
- end
15
-
16
- # Copies a sample bpmn file to help demonstrate the usage for camunda-workflow
17
- def copy_sample_bpmn
18
- copy_file 'sample.bpmn', File.join(diagram_path, 'sample.bpmn'), ''
19
- copy_file 'ProcessScenarioTest.java', File.join(bpmn_app_path, 'src/test/java/unittest/ProcessScenarioTest.java')
14
+ create_link resources_path, File.join(java_app_folder_name, 'src/main/resources/')
20
15
  end
21
16
 
22
17
  # Copies all spring boot files into a rails application and provides a Camunda engine for testing.
23
18
  def copy_java_app_files
24
- copy_file 'pom.xml', File.join(bpmn_app_path, 'pom.xml')
25
- copy_file 'camunda.cfg.xml', File.join(bpmn_app_path, 'src/test/resources/camunda.cfg.xml')
26
- copy_file 'logback.xml', File.join(bpmn_app_path, 'src/main/resources/logback.xml')
27
- copy_file 'application.properties', File.join(bpmn_app_path, 'src/main/resources/application.properties')
28
- copy_file 'Camunda.java', File.join(bpmn_app_path, 'src/main/java/camunda/Camunda.java')
19
+ copy_file 'pom.xml', File.join(java_app_path, 'pom.xml')
20
+ copy_file 'camunda.cfg.xml', File.join(java_app_path, 'src/test/resources/camunda.cfg.xml')
21
+ copy_file 'logback.xml', File.join(java_app_path, 'src/main/resources/logback.xml')
22
+ copy_file 'application.properties', File.join(java_app_path, 'src/main/resources/application.properties')
23
+ copy_file 'Camunda.java', File.join(java_app_path, 'src/main/java/camunda/Camunda.java')
29
24
  copy_file 'camunda.rake', 'lib/tasks/camunda.rake'
30
25
  end
31
26
 
27
+ # Copies a sample bpmn file to help demonstrate the usage for camunda-workflow
28
+ def copy_sample_bpmn
29
+ copy_file 'sample.bpmn', File.join(resources_path, 'sample.bpmn')
30
+ copy_file 'ProcessScenarioTest.java', File.join(java_app_path, 'src/test/java/unittest/ProcessScenarioTest.java')
31
+ end
32
+
32
33
  # Add spring boot files to .gitignore
33
34
  def add_to_ignores
34
35
  ignores = %w[.gitignore]
@@ -36,7 +37,7 @@ module Camunda
36
37
  ignores.each do |file|
37
38
  append_to_file file do
38
39
  "\n# BPMN Java app\n" +
39
- File.join(bpmn_app_path, 'target') +
40
+ File.join(java_app_path, 'target') +
40
41
  "\n"
41
42
  end
42
43
  end
@@ -73,12 +74,24 @@ module Camunda
73
74
 
74
75
  private
75
76
 
76
- def bpmn_app_path
77
- options['app_path']
77
+ def bpmn_folder_name
78
+ options['bpmn_folder_name']
79
+ end
80
+
81
+ def java_app_folder_name
82
+ options['java_app_folder_name']
83
+ end
84
+
85
+ def resources_folder_name
86
+ options['resources_folder_name']
87
+ end
88
+
89
+ def resources_path
90
+ File.join(bpmn_folder_name, resources_folder_name)
78
91
  end
79
92
 
80
- def diagram_path
81
- options['diagram_path']
93
+ def java_app_path
94
+ File.join(bpmn_folder_name, java_app_folder_name)
82
95
  end
83
96
  end
84
97
  end
@@ -15,11 +15,6 @@ namespace :camunda do
15
15
  # Runs spring boot test suite e.g. mvn test.
16
16
  desc 'Runs test suite for Camunda spring-boot application'
17
17
  task :test do
18
- system('mvn test', chdir: mvn_path)
19
- end
20
- # Installs the spring-boot app dependencies mvn clean install.
21
- desc 'Installs spring-boot dependencies for Camunda spring-boot app.'
22
- task :install do
23
- system('mvn clean install -DskipTests=true', chdir: mvn_path)
18
+ system('mvn clean test', chdir: mvn_path)
24
19
  end
25
20
  end
@@ -12,10 +12,10 @@
12
12
  <description>A Process Application for [Camunda BPM](http://docs.camunda.org).</description>
13
13
 
14
14
  <properties>
15
- <camunda.version>7.12.0-alpha3</camunda.version>
15
+ <camunda.version>7.12.0</camunda.version>
16
16
  <!--
17
17
  Adjust if you want to use Camunda Enterprise Edition (EE):
18
- <camunda.version>7.11.0-ee</camunda.version>
18
+ <camunda.version>7.12.0-ee</camunda.version>
19
19
  Make sure you also switch to the ee webapp dependency
20
20
  and EE repository below
21
21
  -->
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: camunda-workflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ankur Sethi