#SummitNow Using Scheduler with Long Running Activiti Workflow Tasks 6 November 2013 (Barcelona) 14 November 2013 (Boston) Bill Young, Flatirons Solutions.

Slides:



Advertisements
Similar presentations
Sequence of characters Generalized form Expresses Pattern of strings in a Generalized notation.
Advertisements

And so to Code. Forward, Reverse, and Round-Trip Engineering Forward Engineering Reverse Engineering Round-Trip Engineering.
JTX Overview Overview of Job Tracking for ArcGIS (JTX)
Software Engineering Implementation Lecture 3 ASPI8-4 Anders P. Ravn, Feb 2004.
Identity and Equality Based on material by Michael Ernst, University of Washington.
Exception Handling – illustrated by Java mMIC-SFT November 2003 Anders P. Ravn Aalborg University.
CHAPTER 4 Queues. Queue  The queue, like the stack, is a widely used data structure  A queue differs from a stack in one important way  A stack is.
Asynchronous Job Processing Using Quartz.Net
1 JDBC Java Database Connectivity. 2 c.pdf
Advanced Java Programming – Eran Toch Methodologies in Information System Development Tutorial: Advanced Java Programming and Database connection Eran.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Phonegap Bridge – File System CIS 136 Building Mobile Apps 1.
An Introduction to Hibernate Matt Secoske
8/19/20151 Securing a Database Based on notes by Fei Li and Hong Li.
SQLite Database. SQLite Public domain database – Advantages Small (about 150 KB) – Used on devices with limited resources Each database contained within.
Training - Day 3 OJB. What is OR Mapping? OR Mapping is the mapping of relational database tables to objects (Java Objects in our case) Many OR Mapping.
Agenda What is Hibernate Spring Integration Questions Overview
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
Chapter 3 Introduction to Collections – Stacks Modified
Software Engineering 2003 Jyrki Nummenmaa 1 CASE Tools CASE = Computer-Aided Software Engineering A set of tools to (optimally) assist in each.
Configuring Identity Manager 2 (formerly DirXML ® ) for JDBC (w/DirXML) Jason Elsberry Software Engineer
EJB Framework.  As we know, EJB is the center of the J2EE architecture that provides a sturdy framework for building enterprise applications. The major.
Dbwebsites 2.1 Making Database backed Websites Session 2 The SQL… Where do we put the data?
Hive Facebook 2009.
Anti Orgla, Nortal AS Spring Framework
JDBC Tutorial MIE456 - Information Systems Infrastructure II Vinod Muthusamy November 4, 2004.
The rSmart Group JA-SIG 2007 All Materials © 2007 The rSmart Group Sakai - SIS Integration Using Data Extracts John Bush The rSmart Group JA-SIG June 2007.
MySQL Databases & PHP Integration Using PHP to write data to, and retrieve data from, a MySQL database.
Object Oriented Analysis and Design 1 Chapter 7 Database Design  UML Specification for Data Modeling  The Relational Data Model and Object Model  Persistence.
CS 160: Software Engineering October 6 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
1 Introduction to Database Systems CSE 444 Lecture 06 SQL in C#, Project October 5, 2007.
Partitioning Patterns How to partition complex actors and concepts into multiple classes. Layered Initialization Filter Composite.
Chapter 25 Databases. Chapter Scope Database concepts Tables and queries SQL statements Managing data in a database Java Foundations, 3rd Edition, Lewis/DePasquale/Chase25.
Exploring Quartz Scheduler
MySQL More… 1. More on SQL In MySQL, the Information Schema is the “Catalog” in the SQL standard SQL has three components: Data definition Data manipulation.
Creating competitive advantage Copyright © 2003 Enterprise Java Beans Presenter: Wickramanayake HMKSK Version:0.1 Last Updated:
Csci 490 / Engr 596 Special Topics / Special Projects Software Design and Scala Programming Spring Semester 2010 Lecture Notes.
COMP 321 Week 4. Overview Normalization Entity-Relationship Diagrams SQL JDBC/JDBC Drivers hsqldb Lab 4-1 Introduction.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool The problem fixed by ORM Advantage Hibernate Hibernate Basic –Hibernate sessionFactory –Hibernate Session.
Page 1 – Autumn 2009Steffen Vissing Andersen SDJ I1, Autumn 2009 Agenda: Java API Documentation Code Documenting (in javadoc format) Debugging.
Dependency Injection Frameworks Technion – Institute of Technology Author: Assaf Israel - Technion 2013 ©
RDF and Relational Databases
The Factory Method Pattern (Creational) ©SoftMoore ConsultingSlide 1.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Data Access with Spring.
More Java: Static and Final, Abstract Class and Interface, Exceptions, Collections Framework 1 CS300.
There are two types of MySQL instructions (Data Definition Language) DDL: Create database, create table, alter table,,,. (Data Manipulation Language) DML.
Using ADO.Net to Build a Login System Dr. Ron Eaglin.
Text 16 de mayo de 2009 Spring Framework Part III. Portable Service Abstractions Buenos Aires, June 2009.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Overview of the Spring Framework Introducing.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool Used in data layer of applications Implements JPA.
Kyung Hee University Class Diagramming Notation OOSD 담당조교 석사과정 이정환.
1 JDBC – Java Database Connectivity CS , Spring 2010.
Chapter 2 Java Struct 2. Content Basic MVC Architecture Struts 2 Overview Struts 2 - Architecture.
1 Documenting with Javadoc How to Write Doc Comments for the Javadoc TM Tool available from java.sun.com.
Csci 490 / Engr 596 Special Topics / Special Projects Software Design and Scala Programming Spring Semester 2010 Lecture Notes.
CS 440 Database Management Systems Stored procedures & OR mapping 1.
#SummitNow Workflow Dashboard Custom Dashlet (Replacement for My Tasks) 14 November 2013 Bill Young, Flatirons Solutions.
Data in Windows 10 UWP Andy Wigley XML, JSON, SQLite or EF Core ?
Lecture 1.21 SQL Introduction Steven Jones, Genome Sciences Centre.
Getting Activiti to “Talk” to an External Database Koorosh Vakhshoori Software Architect/Senior developer at Synopsys Inc.
Actions and Behaviours
CarbonData Data Load Design
JDBC – Java Database Connectivity
Java Servlets By: Tejashri Udavant..
Chapter 6: The Stack Abstract Data Type
Packages, Interfaces & Exception Handling
null, true, and false are also reserved.
Chapter 4 Queues.
Making Text for the Web part 6
Plug-In Architecture Pattern
Presentation transcript:

#SummitNow Using Scheduler with Long Running Activiti Workflow Tasks 6 November 2013 (Barcelona) 14 November 2013 (Boston) Bill Young, Flatirons Solutions

#SummitNow Overview Justification Problem Analysis Solution

#SummitNow Justification Manage Long Running (Batch-like) Processes in Workflow Queue Processes Limited Resources Throttle Running Jobs - Configuration

#SummitNow Sample Workflow

#SummitNow Problem Analysis Quartz Scheduler Available Activiti Doesn’t Provide Scheduling Activiti Does Provide Receive Tasks

#SummitNow Technologies Quartz Open Source Job Scheduling Library Already Integrated with Alfresco Java API

#SummitNow Technologies Activiti Open Source BPMN 2 Process Engine Heart of Alfresco Workflows (since 4.0)

#SummitNow Solution Split Tasks in Workflow Design Custom Scheduler Custom Jobs Custom Delegate Spring Configuration JDBC Job Store

#SummitNow Revised Workflow Diagram

#SummitNow Custom Delegate UML Diagram and Code

#SummitNow Custom Java Delegate

#SummitNow Abstract Java Delegate public abstract class AbstractCustomJavaDelegate extends BaseJavaDelegate { /** bean holding workflow settings */ private WorkflowServiceBean workflowSettings; /** the workflowSettings */ public WorkflowServiceBean getWorkflowSettings() { return workflowSettings; } /** value the workflowSettings to set */ public void setWorkflowSettings(final WorkflowServiceBean value) { this.workflowSettings = value; }

#SummitNow Abstract Scheduled Job Delegate public abstract class AbstractScheduledJobDelegate extends AbstractCustomJavaDelegate { /** Quartz Scheduler */ private Scheduler scheduler; /** Default Priority level */ private int defaultPriority; the scheduler */ public Scheduler getScheduler() { return scheduler; } value the scheduler to set */ public void setScheduler(final Scheduler value) { this.scheduler = value; } the defaultPriority */ public int getDefaultPriority() { return defaultPriority; } value the defaultPriority to set */ public void setDefaultPriority(final int value) { this.defaultPriority = value; }

#SummitNow Abstract Scheduled Job Delegate public Map getVariablesMap(final DelegateExecution execution) { Map variablesMap = new HashMap (); variablesMap.put(WORK_PACKAGE_ID_VAR, execution.getVariable(WORK_PACKAGE_ID_VAR)); variablesMap.put(WORKFLOW_DESC_VAR, execution.getVariable(WORKFLOW_DESC_VAR)); variablesMap.put(CONTENT_PACKAGE_VAR, execution.getVariable(CONTENT_PACKAGE_VAR)); variablesMap.put(WORKFLOW_DUE_DATE_VAR, execution.getVariable(WORKFLOW_DUE_DATE_VAR)); variablesMap.put(WORKFLOW_INSTANCE_ID, execution.getVariable(WORKFLOW_INSTANCE_ID)); variablesMap.put(TASK_OWNER, execution.getVariable(TASK_OWNER)); variablesMap.put(JOB_PRIORITY_VAR, Integer.valueOf(defaultPriority)); return variablesMap; }

#SummitNow Abstract Scheduled Job Delegate public void execute(final DelegateExecution execution) throws Exception { Map variablesMap = getVariablesMap(execution); String jobTraqId = (String) variablesMap.get(WORK_PACKAGE_ID_VAR); WorkflowInstance wkfInstance = getWorkflowSettings().getServiceRegistry().getWorkflowService().getWorkflowById( (String) variablesMap.get(WORKFLOW_INSTANCE_ID)); JobDetail jobDetail = new JobDetail(getJobPrefix() + jobTraqId, getJobsGroup(), getJobClass()); JobDataMap jobDataMap = new JobDataMap(); jobDataMap.put(JOB_TRAQ_ID, jobTraqId); jobDataMap.put(EXEC_VARIABLES, variablesMap); jobDataMap.put(WORKFLOW_INSTANCE, wkfInstance); jobDetail.setJobDataMap(jobDataMap); Trigger trigger = new SimpleTrigger(getTriggerPrefix() + jobTraqId, getTriggersGroup()); trigger.setPriority(((Integer) variablesMap.get(JOB_PRIORITY_VAR)).intValue()); getScheduler().scheduleJob(jobDetail, trigger); }

#SummitNow Concrete Scheduled Job Delegate public class IngestDelegate extends AbstractScheduledJobDelegate { public String getJobPrefix() { return INGESTION_JOB_PREFIX; } public String getJobsGroup() { return INGESTION_JOBS_GROUP; } public String getTriggerPrefix() { return INGESTION_TRIGGER_PREFIX; } public String getTriggersGroup() { return INGESTION_TRIGGERS_GROUP; } public Class getJobClass() { return ContentIngestionJob.class; } }

#SummitNow Bean Initialization

#SummitNow Workflow Settings Bean <bean id="CustomWorkflowSettings" class="com.flatirons.workflow.WorkflowServiceBean"> ${audit. alfresco.enabled}...

#SummitNow Java Delegate Beans <bean id="abstractJavaDelegate" parent="baseJavaDelegate" class="com.flatirons.workflow.AbstractCustomJavaDelegate" abstract="true"> <bean id="abstractScheduledJobDelegate" parent="abstractJavaDelegate" class="com.flatirons.workflow.AbstractScheduledJobDelegate“ abstract="true"> ${quartz.priority.default} <bean id="IngestDelegate" parent="abstractScheduledJobDelegate" class="com.flatirons.workflow.ingest.IngestDelegate">

#SummitNow Custom Scheduler UML diagram and code

#SummitNow Scheduler UML

#SummitNow Custom Std Scheduler public class FlatironsStdScheduler extends StdScheduler { /** bean holding workflow settings */ private WorkflowServiceBean workflowSettings; public FlatironsStdScheduler(final QuartzScheduler scheduler, final SchedulingContext schedulingContext) { super(scheduler, schedulingContext); } public WorkflowServiceBean getWorkflowSettings() { return workflowSettings; } public void setWorkflowSettings(final WorkflowServiceBean value) { workflowSettings = value; }

#SummitNow Scheduler Factory public class FlatironsSchedulerFactory extends StdSchedulerFactory { public FlatironsSchedulerFactory() { } protected Scheduler instantiate(final QuartzSchedulerResources resources, final QuartzScheduler scheduler) { SchedulingContext schedulingContext = new SchedulingContext(); schedulingContext.setInstanceId(resources.getInstanceId()); return new FlatironsStdScheduler(scheduler, schedulingContext); }

#SummitNow Scheduler Factory Bean public class FlatironsSchedulerFactoryBean extends SchedulerFactoryBean { private WorkflowServiceBean workflowSettings; public FlatironsSchedulerFactoryBean() { setSchedulerFactoryClass(FlatironsSchedulerFactory.class); } protected Scheduler createScheduler(final SchedulerFactory schedulerFactory, final String schedulerName) throws SchedulerException { FlatironsStdScheduler newScheduler = (FlatironsStdScheduler) super.createScheduler(schedulerFactory, schedulerName); newScheduler.setWorkflowSettings(this.workflowSettings); return newScheduler; }

#SummitNow Custom Jobs UML diagram and code

#SummitNow Jobs UML

#SummitNow Abstract Custom Job public abstract class FlatironsJob implements org.quartz.Job { public void execute(final JobExecutionContext context) throws JobExecutionException { try { JobDataMap jobDataMap = context.getMergedJobDataMap(); execute((WorkflowInstance) jobDataMap.get(WORKFLOW_INSTANCE), (FlatironsStdScheduler) context.getScheduler(), (Map ) jobDataMap.get(EXEC_VARIABLES)); } catch (Exception e) { throw new JobExecutionException(e); } finally { signalCompletion(null); } protected abstract void execute(WorkflowInstance workflowInstance, FlatironsStdScheduler scheduler, Map variablesMap) throws JobExecutionException; }

#SummitNow Concrete Custom Job public class ContentIngestionJob extends FlatironsJob { protected void execute(final WorkflowInstance workflowInstance, final FlatironsStdScheduler scheduler, final Map variablesMap) { ContentIngester contentIngester = new ContentIngester( scheduler.getWorkflowSettings(), variablesMap, workflowInstance); contentIngester.execute(); }

#SummitNow Spring Configuration <bean id="quartzIngestionSchedulerProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> 10 QRTZ_ING_ <bean id="ingestionScheduler" class="com.flatirons.workflow.scheduler.quartz.FlatironsSchedulerFactoryBean">

#SummitNow Quartz Properties org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool org.quartz.threadPool.makeThreadsDaemons=false org.quartz.scheduler.makeSchedulerThreadDaemon=true org.quartz.scheduler.instanceId=AUTO org.quartz.scheduler.jmx.export=true org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate org.quartz.jobStore.isClustered=false org.quartz.jobStore.clusterCheckinInterval=20000 org.quartz.jobStore.dataSource=myDS org.quartz.dataSource.myDS.driver=com.mysql.jdbc.Driver org.quartz.dataSource.myDS.URL=jdbc:mysql://localhost:3306/alfresco_quartz?useUnicode=yes&ch aracterEncoding=UTF-8 org.quartz.dataSource.myDS.user=quartz_usr org.quartz.dataSource.myDS.password=quartz...

#SummitNow JDBC Job Store create database if not exists alfresco_quartz; use alfresco_quartz; grant all on alfresco_quartz.* to identified by 'quartz'; grant all on alfresco_quartz.* to identified by 'quartz'; DROP TABLE IF EXISTS QRTZ_ING_JOB_DETAILS;... CREATE TABLE QRTZ_ING_JOB_DETAILS(... )... DROP TABLE IF EXISTS QRTZ_CON_JOB_DETAILS;... CREATE TABLE QRTZ_CON_JOB_DETAILS(... )...

#SummitNow Quartz Job Store mysql> show tables; | Tables_in_alfresco_quartz | |... | | QRTZ_CON_TRIGGERS | | QRTZ_CON_TRIGGER_LISTENERS | | QRTZ_ING_BLOB_TRIGGERS | | QRTZ_ING_CALENDARS | | QRTZ_ING_CRON_TRIGGERS | | QRTZ_ING_FIRED_TRIGGERS | | QRTZ_ING_JOB_DETAILS | | QRTZ_ING_JOB_LISTENERS | | QRTZ_ING_LOCKS | | QRTZ_ING_PAUSED_TRIGGER_GRPS | | QRTZ_ING_SCHEDULER_STATE | | QRTZ_ING_SIMPLE_TRIGGERS | | QRTZ_ING_TRIGGERS | | QRTZ_ING_TRIGGER_LISTENERS | |... |

#SummitNow Quartz Job Store mysql> desc QRTZ_ING_TRIGGERS; | Field | Type | Null | Key | Default | Extra | | TRIGGER_NAME | varchar(200) | NO | PRI | NULL | | | TRIGGER_GROUP | varchar(200) | NO | PRI | NULL | | | JOB_NAME | varchar(200) | NO | MUL | NULL | | | JOB_GROUP | varchar(200) | NO | | NULL | | | IS_VOLATILE | varchar(1) | NO | | NULL | | | DESCRIPTION | varchar(250) | YES | | NULL | | | NEXT_FIRE_TIME | bigint(13) | YES | | NULL | | | PREV_FIRE_TIME | bigint(13) | YES | | NULL | | | PRIORITY | int(11) | YES | | NULL | | | TRIGGER_STATE | varchar(16) | NO | | NULL | | | TRIGGER_TYPE | varchar(8) | NO | | NULL | | | START_TIME | bigint(13) | NO | | NULL | | | END_TIME | bigint(13) | YES | | NULL | | | CALENDAR_NAME | varchar(200) | YES | | NULL | | | MISFIRE_INSTR | smallint(2) | YES | | NULL | | | JOB_DATA | blob | YES | | NULL | | rows in set (0.02 sec)

#SummitNow Quartz Job Store mysql> select TRIGGER_NAME, JOB_NAME, PRIORITY, TRIGGER_STATE from QRTZ_ING_TRIGGERS; | TRIGGER_NAME | JOB_NAME | PRIORITY | TRIGGER_STATE | | IngestionTrigger_Summit E | IngestionJob_Summit E | 3 | COMPLETE | | IngestionTrigger_Summit F | IngestionJob_Summit F | 3 | WAITING | rows in set (0.00 sec)

#SummitNow Quartz Job Store mysql> desc QRTZ_ING_JOB_DETAILS; | Field | Type | Null | Key | Default | Extra | | JOB_NAME | varchar(200) | NO | PRI | NULL | | | JOB_GROUP | varchar(200) | NO | PRI | NULL | | | DESCRIPTION | varchar(250) | YES | | NULL | | | JOB_CLASS_NAME | varchar(250) | NO | | NULL | | | IS_DURABLE | varchar(1) | NO | | NULL | | | IS_VOLATILE | varchar(1) | NO | | NULL | | | IS_STATEFUL | varchar(1) | NO | | NULL | | | REQUESTS_RECOVERY | varchar(1) | NO | | NULL | | | JOB_DATA | blob | YES | | NULL | | rows in set (0.01 sec)

#SummitNow Quartz Job Store mysql> select JOB_NAME, JOB_CLASS_NAME from QRTZ_ING_JOB_DETAILS; | JOB_NAME | JOB_CLASS_NAME | | IngestionJob_Summit E | com.flatirons.workflow.scheduler.ContentIngestionJob | | IngestionJob_Summit F | com.flatirons.workflow.scheduler.ContentIngestionJob | rows in set (0.00 sec)

#SummitNow Additional Features Custom Page for Job Priority Clustering Remove Jobs from Queue

#SummitNow Contributors Sri Patil, Senior Developer, Flatirons

#SummitNow Questions

#SummitNow