java - Simple Work Flow (SWF) Workflow with Spring without xml -
currently working on spring annotation based dependency injection activity worker , workflow worker per documentation.i have defined beans inside spring boot application. each worker defined in separate maven module. issue facing when while running activityworker spring boot module stays active , start looking activities workflow worker stops after starting module message '
unregistering jmx-exposed beans on shutdown
my implementation following:
@activities(version = "2.2") @activityregistrationoptions(defaulttaskscheduletostarttimeoutseconds = 300, defaulttaskstarttoclosetimeoutseconds = 100) public interface tempactivities { public greetwrapper getname(); public void say(string what); /* public integer doprocess(); public int sum(integer num);*/ } public class tempactivitiesimpl implements tempactivities { greetwrapper greetobj = new greetwrapper(); public tempactivitiesimpl() { // todo auto-generated constructor stub } @override public greetwrapper getname() { greetobj.setgreet("world"); return greetobj; } @override public void say(string what) { system.out.println(what); } } @workflow(dataconverter = greetwrapper.class) @workflowregistrationoptions(defaultexecutionstarttoclosetimeoutseconds = 3600) public interface tempworkflow { @execute(name = "tempworkflow", version = "2.2") public void greet(); } public class tempworkflowimpl implements tempworkflow { private tempactivitiesclient activitiesclientimpl = new tempactivitiesclientimpl(); private decisioncontextprovider contextprovider = new decisioncontextproviderimpl(); private workflowclock clock = contextprovider.getdecisioncontext().getworkflowclock(); @override public void greet() { greet1(0); } public void greet1(int count, promise < ? > ...waitfor) { if (count == 3) { return; } promise < greetwrapper > name = activitiesclientimpl.getname(); promise < string > greeting = getgreeting(name); activitiesclientimpl.say(greeting); promise < void > timer = clock.createtimer(30); greet1(count + 1, timer); } @asynchronous public promise < string > getgreeting(promise < greetwrapper > name) { string greeting = "hello " + name.get().getgreet(); system.out.println("greeting: " + greeting); return promise.aspromise(greeting); } }
here activity worker beans
@configuration public class appconfig { public string getactivitytasklistname() { return "helloworldtasklist"; } public string getdomainname() { return "helloworldwalkthrough2"; } public string getworkflowtasklistname() { return "helloworldworkflow"; } public string getendpoint() { string endpoint = "https://swf.us-east-1.amazonaws.com"; return endpoint; } string swfaccessid = system.getenv("aws_access_key_id"); string swfsecretkey = system.getenv("aws_secret_access_key"); /*@autowired tempactivities tempactivitiesimpl; @autowired tempworkflow tempworkflowimpl; */ @bean public clientconfiguration clientconfiguration() { clientconfiguration config = new clientconfiguration(); config.withsockettimeout(70 * 1000); return config; } @bean public awscredentials basicawscredentials() { basicawscredentials basicawscredentials = new basicawscredentials(swfaccessid, swfsecretkey); return basicawscredentials; } @bean public amazonsimpleworkflow amazonsimpleworkflowclient() { amazonsimpleworkflow amazonsimpleworkflowclient = new amazonsimpleworkflowclient(basicawscredentials(), clientconfiguration()); amazonsimpleworkflowclient.setendpoint(getendpoint()); return amazonsimpleworkflowclient; } @bean public tempactivitiesclient tempactivitiesclient() { tempactivitiesclient tempactivitiesclient = new tempactivitiesclientimpl(); return tempactivitiesclient; } @bean public springactivityworker springactivityworker() throws instantiationexception, illegalaccessexception, securityexception, nosuchmethodexception { springactivityworker activityworker = new springactivityworker(amazonsimpleworkflowclient(), getdomainname(), getworkflowtasklistname()); activityworker.addactivitiesimplementation(new tempactivitiesimpl()); return activityworker; } }
here workflow worker beans
public class workflowappconfig { public string getactivitytasklistname() { return "helloworldtasklist"; } public string getdomainname() { return "helloworldwalkthrough2"; } public string getworkflowtasklistname() { return "helloworldworkflow"; } public string getendpoint() { string endpoint = "https://swf.us-east-1.amazonaws.com"; return endpoint; } string swfaccessid = system.getenv("aws_access_key_id"); string swfsecretkey = system.getenv("aws_secret_access_key"); /*@autowired tempactivities tempactivitiesimpl;*/ @autowired tempworkflow tempworkflowimpl; @bean @scope("workflow") public clientconfiguration clientconfiguration() { clientconfiguration config = new clientconfiguration(); config.withsockettimeout(70 * 1000); return config; } @bean @scope("workflow") public awscredentials basicawscredentials() { basicawscredentials basicawscredentials = new basicawscredentials(swfaccessid, swfsecretkey); return basicawscredentials; } @bean @scope("workflow") public amazonsimpleworkflow amazonsimpleworkflowclient() { amazonsimpleworkflow amazonsimpleworkflowclient = new amazonsimpleworkflowclient(basicawscredentials(), clientconfiguration()); amazonsimpleworkflowclient.setendpoint(getendpoint()); return amazonsimpleworkflowclient; } @bean @scope("workflow") public tempactivitiesclient activitiesclientimpl() { return new tempactivitiesclientimpl(); } @bean @scope("workflow") public springworkflowworker springworkflowworker() throws instantiationexception, illegalaccessexception { springworkflowworker workflowworker = new springworkflowworker(amazonsimpleworkflowclient(), getdomainname(), getworkflowtasklistname()); workflowworker.addworkflowimplementation(tempworkflowimpl); workflowworker.setregisterdomain(true); // workflowworker.setdomainretentionperiodindays(1); return workflowworker; } @bean public customscopeconfigurer customscope() { customscopeconfigurer configurer = new customscopeconfigurer(); map < string, object > workflowscope = new hashmap < string, object > (); workflowscope.put("workflow", new workflowscope()); configurer.setscopes(workflowscope); return configurer; } }
Comments
Post a Comment