Skip to content

Commit

Permalink
README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
sizegang1 committed Mar 6, 2022
1 parent 9a9572a commit 682cb99
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class AService implements AsyncTask<DataContext, DataContext>, ParaExecto
@Override
public void callback(boolean success, DataContext param, TaskResult<DataContext> workResult) {
if (success) {
System.out.println("AService 成功");
// System.out.println("AService 成功");
} else {
System.out.println("AService 失败");
}
Expand All @@ -33,16 +33,15 @@ public void callback(boolean success, DataContext param, TaskResult<DataContext>
@Override
public DataContext task(DataContext params, GobrsAsyncSupport support) {
try {
// System.out.println(1/0);
Thread.sleep(1000);
System.out.println("AService 执行完了");
// System.out.println("AService 执行完了");

} catch (InterruptedException e) {
e.printStackTrace();
}
byte[] result = new byte[1024*1024];
// byte[] result = new byte[1024*1024];
Map h = new HashMap();
h.put("result", result);
h.put("result", h);
params.setResult(h);
return params;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class BService implements AsyncTask<DataContext, Map>, SerExector {
@Override
public void callback(boolean success, DataContext param, TaskResult<Map> workResult) {
if (success) {
System.out.println("BService 成功");
// System.out.println("BService 成功");
} else {
System.out.println("BService 失败");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,26 @@ public class EService implements AsyncTask<DataContext, DataContext>, ParaExecto
@Override
public void callback(boolean success, DataContext param, TaskResult<DataContext> workResult) {
if (success) {
System.out.println("EService 成功");
// System.out.println("EService 成功");
} else {
System.out.println("EService 失败");
}
}

@Override
public DataContext task(DataContext params, GobrsAsyncSupport support) {
stopTaskFlow(support, 100);
try {
// System.out.println(1/0);
Thread.sleep(500);


} catch (InterruptedException e) {
e.printStackTrace();
}
// byte[] result = new byte[1024 * 1024];
Map h = new HashMap();
h.put("result", "我是EService 的 结果 恭喜你拿到");
params.setResult(h);
return params;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class FService implements AsyncTask<DataContext, Map>, SerExector {
@Override
public void callback(boolean success, DataContext param, TaskResult<Map> workResult) {
if (success) {
System.out.println("FService 成功");
// System.out.println("FService 成功");
} else {
System.out.println("FService 失败");
}
Expand All @@ -32,8 +32,8 @@ public void callback(boolean success, DataContext param, TaskResult<Map> workRes
@Override
public Map task(DataContext params, GobrsAsyncSupport support) {
try {
DataContext result = getResult(support, EService.class, DataContext.class);
System.out.println(JSONObject.toJSONString(result.getResult()));
// DataContext result = getResult(support, EService.class, DataContext.class);
// System.out.println(JSONObject.toJSONString(result.getResult()));
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@ public void testGobrs(HttpServletRequest httpServletRequest) {
DataContext dataContext = new DataContext();
dataContext.setHttpServletRequest(httpServletRequest);
AsyncResult asyncResult = taskFlow.taskFlow("test", dataContext, 100000);

if(asyncResult.getExpCode().equals(100)){
// 业务一
}else if(asyncResult.getExpCode().equals(200)){
// 业务二
}

}


Expand Down
2 changes: 1 addition & 1 deletion gobrs-async-example/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ server:
spring:
gobrs:
async:
rules: '[{name: "test", content: "AService->BService,CService,GService,DService, FService:not;EService->FService"}]'
rules: '[{name: "test", content: "AService->BService;EService->FService"}]'
# rules: '[{name: "test", content: "BService->CService->EService->DService:not;AService->DService:not"}]'
task-interrupt: true #局部异常是否打断主流程

0 comments on commit 682cb99

Please sign in to comment.