Spring  Integration  in jBPM 4 Andries Inzé [email_address] http://andries.inze.be
About me <ul><li>President of </li></ul><ul><li>Technical Project Leader at  </li></ul><ul><li>Helping out with  </li></ul>
Content <ul><li>Why do we need Spring Integration? </li></ul><ul><li>What’s In It For Us? </li></ul><ul><li>Architecture o...
Why do we need it? <ul><li>Previous efforts on jBPM 3 </li></ul><ul><ul><li>Spring Modules (jBPM 3.0-3.1 but not up!) </li...
WIIFY <ul><li>Deep integration, making the necessary changes </li></ul><ul><ul><li>No need for hacks </li></ul></ul><ul><l...
How much is realized? <ul><li>Scope 4.0.0.GA    minimal scope jBPM 3 </li></ul><ul><li>Further   Easy extension and inte...
Content <ul><li>Why do we need Spring Integration? </li></ul><ul><li>What’s In It For Us? </li></ul><ul><li>Architecture o...
jBPM 4 Architecture <ul><li>Dependency Lookup </li></ul><ul><li>Transaction Management </li></ul><ul><li>Activity </li></ul>
jBPM 4 Architecture <ul><li>Dependency Lookup </li></ul><ul><li>Transaction Management </li></ul><ul><li>Activity </li></ul>
jBPM 4 Architecture Dependency Lookup Environment Process Service Execution Service Management Service Hibernate Session F...
jBPM 4 Architecture Dependency Lookup (2) ProcessEngineContext TransactionContext Hibernate Session Hibernate Session Fact...
jBPM 4 Architecture Dependency Lookup (3) SpringContext ProcessEngineContext TransactionContext Hibernate Session Factory ...
jBPM 4 Architecture <ul><li>Dependency Lookup </li></ul><ul><li>Transaction Management </li></ul><ul><li>Activity </li></ul>
Transaction Handling Process Service Execution Service History Service Command Service Commands Service API
Transaction Handling (2) <ul><li>Configuration Details for jBPM </li></ul>Process Service Execution Service History Servic...
Transaction Handling (3) <ul><li>Configuration Details for Spring </li></ul>Process Service Execution Service History Serv...
Transaction Handling (4) <ul><li>A discrepancy between Spring and jBPM. </li></ul><ul><ul><li>Spring    Transaction per s...
jBPM 4 Architecture <ul><li>Dependency Lookup </li></ul><ul><li>Transaction Management </li></ul><ul><li>Activity </li></ul>
Activity <ul><li>Central focus of jBPM 4 </li></ul><ul><ul><li><task />, <java />, <esb />, <sql />, … </li></ul></ul><ul>...
SpringBeanActivity <ul><li><? xml  version = &quot;1.0&quot;  encoding = &quot;UTF-8&quot; ?> </li></ul><ul><li>< process ...
Content <ul><li>Why do we need Spring Integration? </li></ul><ul><li>What’s In It For Us? </li></ul><ul><li>Architecture o...
Configuration <ul><li>Minimal Spring Configuration </li></ul><ul><li>< beans ... </li></ul><ul><li>< bean  id = &quot;conf...
Configuration (2) <ul><li>Typical jBPM Configuration </li></ul><ul><li><?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&...
Configuration (3) <ul><li>Process-engine-context configuration </li></ul><ul><li>< process-engine-context > </li></ul><ul>...
Configuration (4) <ul><li>Transaction-context configuration </li></ul><ul><li><transaction-context> </li></ul><ul><ul><li>...
Configuration (4) < bean  id = &quot;processEngine&quot;  factory-bean = &quot;jbpmConfiguration&quot;  factory-method = &...
Content <ul><li>Why do we need Spring Integration? </li></ul><ul><li>What’s In It For Us? </li></ul><ul><li>Architecture o...
<ul><li>AbstractTransactional SpringJbpmTestCase </li></ul><ul><li>Only for Spring-Transaction strategy </li></ul><ul><li>...
AbstractTransactional SpringJbpmTestCase public   class  FindExecutionTest  extends  AbstractTransactionalSpringJbpmTestCa...
JbpmTestCase public   class  FindExecutionTest  extends  JbpmTestCase { public   void  testFindExecutionById() { deployJpd...
Best practice <ul><li>Split up the hibernate cfg files </li></ul><ul><li>Use Spring transaction handling when possible </l...
Future <ul><li>Feedback from community </li></ul><ul><li>Test if everything works as intended (Timers/async/…) </li></ul><...
Q&A [email_address]
Upcoming SlideShare
Loading in...5
×

Spring integration with jBPM4

8,370

Published on

Published in: Technology
1 Comment
10 Likes
Statistics
Notes
  • I have just downloaded jBPM4 beta 1 and can not see spring tag in the jPDL schema definition. I am assuming this is experimental at this point?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
8,370
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
1
Likes
10
Embeds 0
No embeds

No notes for slide

Spring integration with jBPM4

  1. 1. Spring Integration in jBPM 4 Andries Inzé [email_address] http://andries.inze.be
  2. 2. About me <ul><li>President of </li></ul><ul><li>Technical Project Leader at </li></ul><ul><li>Helping out with </li></ul>
  3. 3. Content <ul><li>Why do we need Spring Integration? </li></ul><ul><li>What’s In It For Us? </li></ul><ul><li>Architecture of jBPM 4 and Spring Integration </li></ul><ul><li>Configuration </li></ul><ul><li>Testing jBPM 4 with Spring Integration </li></ul><ul><li>Q&A </li></ul>
  4. 4. Why do we need it? <ul><li>Previous efforts on jBPM 3 </li></ul><ul><ul><li>Spring Modules (jBPM 3.0-3.1 but not up!) </li></ul></ul><ul><ul><li>Home brew frameworks </li></ul></ul><ul><ul><li>http://www.jorambarrez.be </li></ul></ul>
  5. 5. WIIFY <ul><li>Deep integration, making the necessary changes </li></ul><ul><ul><li>No need for hacks </li></ul></ul><ul><li>Part of the jBPM 4 test suite </li></ul><ul><li>Expertise and insight of the jBPM Dev Team. </li></ul>What’s In It For YOU ?
  6. 6. How much is realized? <ul><li>Scope 4.0.0.GA  minimal scope jBPM 3 </li></ul><ul><li>Further  Easy extension and integration </li></ul><ul><li>Spring Integration is ready but will not be fully supported in first release  looking for feedback! </li></ul>
  7. 7. Content <ul><li>Why do we need Spring Integration? </li></ul><ul><li>What’s In It For Us? </li></ul><ul><li>Architecture of jBPM 4 and Spring Integration </li></ul><ul><li>Configuration </li></ul><ul><li>Testing jBPM 4 with Spring Integration </li></ul><ul><li>Q&A </li></ul>
  8. 8. jBPM 4 Architecture <ul><li>Dependency Lookup </li></ul><ul><li>Transaction Management </li></ul><ul><li>Activity </li></ul>
  9. 9. jBPM 4 Architecture <ul><li>Dependency Lookup </li></ul><ul><li>Transaction Management </li></ul><ul><li>Activity </li></ul>
  10. 10. jBPM 4 Architecture Dependency Lookup Environment Process Service Execution Service Management Service Hibernate Session Factory Transaction Manager … <ul><li>Dependency resolution at runtime </li></ul>
  11. 11. jBPM 4 Architecture Dependency Lookup (2) ProcessEngineContext TransactionContext Hibernate Session Hibernate Session Factory
  12. 12. jBPM 4 Architecture Dependency Lookup (3) SpringContext ProcessEngineContext TransactionContext Hibernate Session Factory Transaction Manager … Activity Hibernate Session
  13. 13. jBPM 4 Architecture <ul><li>Dependency Lookup </li></ul><ul><li>Transaction Management </li></ul><ul><li>Activity </li></ul>
  14. 14. Transaction Handling Process Service Execution Service History Service Command Service Commands Service API
  15. 15. Transaction Handling (2) <ul><li>Configuration Details for jBPM </li></ul>Process Service Execution Service History Service Command Service Standard Transaction Interceptor
  16. 16. Transaction Handling (3) <ul><li>Configuration Details for Spring </li></ul>Process Service Execution Service History Service Command Service Business Service Transaction Interceptor
  17. 17. Transaction Handling (4) <ul><li>A discrepancy between Spring and jBPM. </li></ul><ul><ul><li>Spring  Transaction per service call </li></ul></ul><ul><ul><li>jBPM  Transaction per Command </li></ul></ul><ul><li>Spring Integration provides support for the two! </li></ul>
  18. 18. jBPM 4 Architecture <ul><li>Dependency Lookup </li></ul><ul><li>Transaction Management </li></ul><ul><li>Activity </li></ul>
  19. 19. Activity <ul><li>Central focus of jBPM 4 </li></ul><ul><ul><li><task />, <java />, <esb />, <sql />, … </li></ul></ul><ul><li>SpringBeanActivity </li></ul><ul><li>Expression Language ( JSR 223, Juel) </li></ul><ul><ul><li>#{myBean.property} </li></ul></ul>< hql name = &quot;count activities&quot; var = &quot;activities&quot; unique = &quot;true&quot; > < query > select count(*) from org.jbpm.pvm.internal.model.ActivityImpl </ query > < transition to = &quot;wait&quot; /> </ hql >
  20. 20. SpringBeanActivity <ul><li><? xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot; ?> </li></ul><ul><li>< process name = &quot;Spring&quot; > </li></ul><ul><li>< start > </li></ul><ul><li>< transition to = &quot;test&quot; /> </li></ul><ul><li></ start > </li></ul><ul><li>< spring name = &quot; test &quot; > </li></ul><ul><ul><li>< bean > testBean </ bean > </li></ul></ul><ul><ul><li>< method > testMethodWithParameters </ method > </li></ul></ul><ul><ul><li>< parameters > </li></ul></ul><ul><ul><li>< string value = “J-Spring&quot; /> </li></ul></ul><ul><ul><li></ parameters > </li></ul></ul><ul><ul><li>< transition to = “finish&quot; /> </li></ul></ul><ul><li></ spring > </li></ul><ul><li>< end name = “finish&quot; /> </li></ul><ul><li></ process > </li></ul>
  21. 21. Content <ul><li>Why do we need Spring Integration? </li></ul><ul><li>What’s In It For Us? </li></ul><ul><li>Architecture of jBPM 4 and Spring Integration </li></ul><ul><li>Configuration </li></ul><ul><li>Testing jBPM 4 with Spring Integration </li></ul><ul><li>Q&A </li></ul>
  22. 22. Configuration <ul><li>Minimal Spring Configuration </li></ul><ul><li>< beans ... </li></ul><ul><li>< bean id = &quot;configuration&quot; class = &quot;org.jbpm.spring.cfg.SpringConfigurationFactoryBean&quot; > </li></ul><ul><li>< property name = &quot;jbpmConfigurationLocation&quot; value = “my/jbpm.cfg.xml&quot; /> </li></ul><ul><li></ bean > </li></ul><ul><li>< bean id = &quot;sessionFactory&quot; class = &quot;org.springframework.orm.hibernate3.LocalSessionFactoryBean&quot; > </li></ul><ul><li>< property name = &quot;configLocation&quot; value = &quot;classpath:my/hibernate.jbpm.cfg.xml&quot; /> </li></ul><ul><li></ bean > </li></ul><ul><li>< bean id = &quot;transactionManager“ </li></ul><ul><li> class = &quot;org.springframework.orm.hibernate3.HibernateTransactionManager&quot; > </li></ul><ul><li>< property name = &quot;sessionFactory&quot; ref = &quot;sessionFactory&quot; /> </li></ul><ul><li></ bean > </li></ul><ul><li>< bean id = &quot;dataSource&quot; class = &quot;org.springframework.jdbc.datasource.DriverManagerDataSource&quot; > </li></ul><ul><ul><li>< property name = &quot;driverClassName&quot; value = &quot;org.hsqldb.jdbcDriver&quot; /> </li></ul></ul><ul><ul><li>< property name = &quot;url&quot; value = &quot;jdbc:hsqldb:mem:.&quot; /> </li></ul></ul><ul><ul><li>< property name = &quot;username&quot; value = &quot;sa&quot; /> </li></ul></ul><ul><ul><li>< property name = &quot;password&quot; value = &quot;&quot; /> </li></ul></ul><ul><li></ bean > </li></ul><ul><li></ beans > </li></ul>
  23. 23. Configuration (2) <ul><li>Typical jBPM Configuration </li></ul><ul><li><?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> </li></ul><ul><li><jbpm-configuration xmlns=&quot;http://jbpm.org/xsd/cfg&quot;> </li></ul><ul><ul><li><process-engine-context> </li></ul></ul><ul><ul><li>… </li></ul></ul><ul><ul><li></process-engine-context> </li></ul></ul><ul><ul><li><transaction-context> </li></ul></ul><ul><ul><li>… </li></ul></ul><ul><ul><li></transaction-context> </li></ul></ul><ul><li></jbpm-configuration> </li></ul>
  24. 24. Configuration (3) <ul><li>Process-engine-context configuration </li></ul><ul><li>< process-engine-context > </li></ul><ul><ul><li>< repository-service /> </li></ul></ul><ul><ul><li>< repository-cache /> </li></ul></ul><ul><ul><li>< execution-service /> </li></ul></ul><ul><ul><li>< history-service /> </li></ul></ul><ul><ul><li>< management-service /> </li></ul></ul><ul><ul><li>< task-service /> </li></ul></ul><ul><ul><li>< identity-service /> </li></ul></ul><ul><ul><li>< command-service > </li></ul></ul><ul><ul><ul><li>< retry-interceptor /> </li></ul></ul></ul><ul><ul><ul><li>< environment-interceptor /> </li></ul></ul></ul><ul><ul><ul><li>< standard-transaction-interceptor /> </li></ul></ul></ul><ul><ul><li></ command-service > </li></ul></ul><ul><ul><li>< hibernate-configuration > </li></ul></ul><ul><ul><li>< cfg resource = &quot;org/jbpm/pvm/spring/hibernate.jbpm.cfg.xml&quot; /> </li></ul></ul><ul><ul><li></ hibernate-configuration > … </li></ul></ul><ul><li></ process-engine-context > </li></ul>
  25. 25. Configuration (4) <ul><li>Transaction-context configuration </li></ul><ul><li><transaction-context> </li></ul><ul><ul><li><transaction /> </li></ul></ul><ul><ul><li><repository-session /> </li></ul></ul><ul><ul><li><pvm-db-session /> </li></ul></ul><ul><ul><li><job-db-session /> </li></ul></ul><ul><ul><li><task-db-session /> </li></ul></ul><ul><ul><li><message-session /> </li></ul></ul><ul><ul><li><timer-session /> </li></ul></ul><ul><ul><li><history-session /> </li></ul></ul><ul><li><hibernate-session current = &quot;true /> </li></ul><ul><ul><li><identity-session /> </li></ul></ul><ul><li></transaction-context> </li></ul>
  26. 26. Configuration (4) < bean id = &quot;processEngine&quot; factory-bean = &quot;jbpmConfiguration&quot; factory-method = &quot;buildProcessEngine&quot; /> < bean id = &quot;executionService&quot; factory-bean = &quot;processEngine&quot; factory-method = &quot;getExecutionService&quot; /> … <ul><li>Exposing Services </li></ul>
  27. 27. Content <ul><li>Why do we need Spring Integration? </li></ul><ul><li>What’s In It For Us? </li></ul><ul><li>Architecture of jBPM 4 and Spring Integration </li></ul><ul><li>Configuration </li></ul><ul><li>Testing jBPM 4 with Spring Integration </li></ul><ul><li>Q&A </li></ul>
  28. 28. <ul><li>AbstractTransactional SpringJbpmTestCase </li></ul><ul><li>Only for Spring-Transaction strategy </li></ul><ul><li>Transactional </li></ul><ul><li>Rollback after test </li></ul><ul><li>JbpmTestCase </li></ul><ul><li>Only for jBPM-Transaction strategy </li></ul><ul><li>Not transactional </li></ul><ul><li>Performs client side cleanup  destructive on existing data </li></ul>jBPM Testing
  29. 29. AbstractTransactional SpringJbpmTestCase public class FindExecutionTest extends AbstractTransactionalSpringJbpmTestCase { protected String[] getConfigLocations() { return new String[]{ &quot;org/jbpm/spring/test/applicationContext.xml&quot; }; } public void testFindExecutionById () { deployJpdlXmlString( &quot;<process name='p'>&quot; + &quot; <start>&quot; + &quot; <transition to='a' />&quot; + &quot; </start>&quot; + &quot; <state name='a' />&quot; + &quot;</process>&quot; ); Execution execution = executionService .startProcessInstanceByKey( &quot;p&quot; ); execution = executionService .findExecution(execution.getId()); assertNotNull(execution); assertEquals( &quot;a&quot; , execution.getActivityName()); }
  30. 30. JbpmTestCase public class FindExecutionTest extends JbpmTestCase { public void testFindExecutionById() { deployJpdlXmlString( &quot;<process name='p'>&quot; + &quot; <start>&quot; + &quot; <transition to='a' />&quot; + &quot; </start>&quot; + &quot; <state name='a' />&quot; + &quot;</process>&quot; ); Execution execution = executionService .startProcessInstanceByKey( &quot;p&quot; ); // take the id and see if the execution service can still find it back execution = executionService .findExecution(execution.getId()); assertNotNull(execution); assertEquals( &quot;a&quot; , execution.getActivityName()); }
  31. 31. Best practice <ul><li>Split up the hibernate cfg files </li></ul><ul><li>Use Spring transaction handling when possible </li></ul><ul><li>Write small tests and reuse them </li></ul><ul><li>Add test-applicationContext.xml to overwrite non-transactional activities (like file-IO) </li></ul>
  32. 32. Future <ul><li>Feedback from community </li></ul><ul><li>Test if everything works as intended (Timers/async/…) </li></ul><ul><li>Test Spring 2.5 and up </li></ul><ul><li>More SWF-like syntax </li></ul><ul><ul><li>DSL e.g. assertCurrentActivityEquals </li></ul></ul><ul><ul><li>Mock sub processes </li></ul></ul><ul><ul><li>… </li></ul></ul><ul><li>Helping out? </li></ul>
  33. 33. Q&A [email_address]

×