vcjmhg opened a new issue #7232:
URL: https://github.com/apache/skywalking/issues/7232


   Please answer these questions before submitting your issue.
   
   - Why do you submit this issue?
   - [X] Question or discussion
   - [ ] Bug
   - [ ] Requirement
   - [ ] Feature or performance improvement
   
   ___
   ### Question
   - What do you want to know?
    I am implementing a zeebe plugin, but encountered the following problem:
   I want to match the implementation class of the 
`io.zeebe.client.api.worker.JobHandler` interface, when I write the 
`JobHandlerInstrumentation` just like this:
   ```java
   public class JobHandlerInstrumentation extends 
ClassInstanceMethodsEnhancePluginDefine {
   
       private static final String ENHANCE_CLASS = 
"io.zeebe.client.api.worker.JobHandler";
       private static final String ENHANCE_METHOD = "handle";
       private static final String INTERCEPTOR_CLASS = 
"org.apache.skywalking.apm.plugin.zeebe.client.JobHandlerInterceptor";
   
       @Override
       protected ClassMatch enhanceClass() {
           return HierarchyMatch.byHierarchyMatch(ENHANCE_CLASS);
       }
   
       @Override
       public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
           return new ConstructorInterceptPoint[0];
       }
   
       @Override
       public InstanceMethodsInterceptPoint[] 
getInstanceMethodsInterceptPoints() {
           return new InstanceMethodsInterceptPoint[] {
               new InstanceMethodsInterceptPoint() {
                   @Override
                   public ElementMatcher<MethodDescription> getMethodsMatcher() 
{
                       return ElementMatchers.named(ENHANCE_METHOD);
                   }
   
                   @Override
                   public String getMethodsInterceptor() {
                       return INTERCEPTOR_CLASS;
                   }
   
                   @Override
                   public boolean isOverrideArgs() {
                       return false;
                   }
               }
           };
       }
   }
   ```
   but it can't match the class `ExampleJobHandler` and the method `handle` 
which has implement `io.zeebe.client.api.worker.JobHandler`.
   ```java
   public class ExampleJobHandler implements JobHandler {
       @Override
       public void handle(final JobClient client, final ActivatedJob job) {
           // here: business logic that is executed with every job
           RestTemplate restTemplate = new RestTemplate();
           ResponseEntity<String> result = 
restTemplate.getForEntity("http://localhost:8080/zeebe-client-1.x-scenario/hello";,
 String.class);
           System.out.println(result.getBody());
           System.out.println(job);
           client.newCompleteCommand(job.getKey()).send().join();
           JobWorkerCreator.setStop(true);
       }
   }
   ```
   When the agent start, I debug it and find that the matcher seems to be 
normal.
   
   
![image](https://user-images.githubusercontent.com/55177318/124242603-7cf0fe80-db4f-11eb-9177-2ce42fd3c2b2.png)
   
   but the INTERCEPTOR_CLASS doesn't work.
   **I want to know if there is a problem with the `JobHandlerInstrumentation ` 
class?**
   AND
   Is there any way I can distinguish the situation below:
   1. The class `ExampleJobHandler` matched successfully, but the method 
`handle()` did not succeed.
   2. The class did not match successfully
   
   Thank you!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to