Skip to content

Commit d494eba

Browse files
committed
add EventTraceContext
1 parent d75e646 commit d494eba

File tree

30 files changed

+246
-30
lines changed

30 files changed

+246
-30
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.codingapi.example.event;
2+
3+
import com.codingapi.springboot.framework.event.IEvent;
4+
5+
public class AEvent implements IEvent {
6+
7+
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.codingapi.example.event;
2+
3+
import com.codingapi.springboot.framework.event.IEvent;
4+
5+
public class BEvent implements IEvent {
6+
7+
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.codingapi.example.event;
2+
3+
import com.codingapi.springboot.framework.event.IEvent;
4+
5+
public class CEvent implements IEvent {
6+
7+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.codingapi.example.handler;
2+
3+
import com.codingapi.example.event.AEvent;
4+
import com.codingapi.example.event.BEvent;
5+
import com.codingapi.springboot.framework.event.EventPusher;
6+
import com.codingapi.springboot.framework.event.EventTraceContext;
7+
import com.codingapi.springboot.framework.event.IHandler;
8+
import lombok.extern.slf4j.Slf4j;
9+
import org.springframework.stereotype.Service;
10+
11+
@Slf4j
12+
@Service
13+
public class AHandler implements IHandler<AEvent> {
14+
15+
@Override
16+
public void handler(AEvent event) {
17+
log.info("a event:{},traceId:{}",event, EventTraceContext.getInstance().getListenerKey());
18+
19+
EventPusher.push(new BEvent());
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.codingapi.example.handler;
2+
3+
import com.codingapi.example.event.BEvent;
4+
import com.codingapi.example.event.CEvent;
5+
import com.codingapi.springboot.framework.event.EventPusher;
6+
import com.codingapi.springboot.framework.event.EventTraceContext;
7+
import com.codingapi.springboot.framework.event.IHandler;
8+
import lombok.extern.slf4j.Slf4j;
9+
import org.springframework.stereotype.Service;
10+
11+
@Slf4j
12+
@Service
13+
public class BHandler implements IHandler<BEvent> {
14+
15+
@Override
16+
public void handler(BEvent event) {
17+
log.info("b event:{},traceId:{}",event, EventTraceContext.getInstance().getListenerKey());
18+
19+
EventPusher.push(new CEvent());
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.codingapi.example.handler;
2+
3+
import com.codingapi.example.event.AEvent;
4+
import com.codingapi.example.event.CEvent;
5+
import com.codingapi.springboot.framework.event.EventPusher;
6+
import com.codingapi.springboot.framework.event.EventTraceContext;
7+
import com.codingapi.springboot.framework.event.IHandler;
8+
import lombok.extern.slf4j.Slf4j;
9+
import org.springframework.stereotype.Service;
10+
11+
@Slf4j
12+
@Service
13+
public class CHandler implements IHandler<CEvent> {
14+
15+
@Override
16+
public void handler(CEvent event) {
17+
log.info("c event:{},traceId:{}",event, EventTraceContext.getInstance().getListenerKey());
18+
19+
EventPusher.push(new AEvent());
20+
}
21+
}

example/example-application/src/main/java/com/codingapi/example/handler/TestHandler.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.codingapi.example.handler;
22

3+
import com.codingapi.example.event.AEvent;
34
import com.codingapi.example.event.TestEvent;
45
import com.codingapi.example.infra.entity.TestEntity;
56
import com.codingapi.example.infra.jpa.TestEntityRepository;
6-
import com.codingapi.springboot.framework.handler.IHandler;
7+
import com.codingapi.springboot.framework.event.EventPusher;
8+
import com.codingapi.springboot.framework.event.IHandler;
79
import lombok.AllArgsConstructor;
810
import org.springframework.stereotype.Repository;
911

@@ -18,8 +20,13 @@ public void handler(TestEvent event) {
1820
TestEntity entity = new TestEntity(event.getName()+"123");
1921
testEntityRepository.save(entity);
2022

21-
throw new IllegalArgumentException("123");
23+
new Thread(()->{
24+
EventPusher.push(new AEvent());
25+
}).start();
2226

27+
new Thread(()->{
28+
EventPusher.push(new AEvent());
29+
}).start();
2330
}
2431

2532

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/build/FlowWorkBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import com.codingapi.springboot.flow.matcher.OperatorMatcher;
1111
import com.codingapi.springboot.flow.trigger.OutTrigger;
1212
import com.codingapi.springboot.flow.user.IFlowOperator;
13-
import com.codingapi.springboot.flow.utils.RandomGenerator;
13+
import com.codingapi.springboot.framework.utils.RandomGenerator;
1414

1515
/**
1616
* 流程工作构建器

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/domain/FlowWork.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.codingapi.springboot.flow.build.SchemaReader;
44
import com.codingapi.springboot.flow.serializable.FlowWorkSerializable;
55
import com.codingapi.springboot.flow.user.IFlowOperator;
6-
import com.codingapi.springboot.flow.utils.RandomGenerator;
6+
import com.codingapi.springboot.framework.utils.RandomGenerator;
77
import lombok.AllArgsConstructor;
88
import lombok.Getter;
99
import lombok.Setter;

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/record/FlowProcess.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.codingapi.springboot.flow.record;
22

33
import com.codingapi.springboot.flow.user.IFlowOperator;
4-
import com.codingapi.springboot.flow.utils.RandomGenerator;
4+
import com.codingapi.springboot.framework.utils.RandomGenerator;
55
import lombok.AllArgsConstructor;
66
import lombok.Getter;
77

0 commit comments

Comments
 (0)