xdxTao opened a new issue #1918:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1918


   I don't see how the `springBootStarter` uses the listener in the document. 
Can it not be used?
   
   If I can, what's wrong with my writing?
   
   **MyListener**
   ```java
   import 
org.apache.shardingsphere.elasticjob.infra.listener.ElasticJobListener;
   import org.apache.shardingsphere.elasticjob.infra.listener.ShardingContexts;
   import org.springframework.stereotype.Component;
   
   @Component("simpleJobListener")
   public class MyJobListener implements ElasticJobListener {
       @Override
       public void beforeJobExecuted(ShardingContexts shardingContexts) {
           System.out.println("before:" + shardingContexts.getJobName());
       }
   
       @Override
       public void afterJobExecuted(ShardingContexts shardingContexts) {
           System.out.println("after:" + shardingContexts.getJobName());
       }
   
       @Override
       public String getType() {
           return "simpleJobListener";
       }
   }
   ```
   
   **MyYml**
   
   ```yml
   elasticjob:
     regCenter:
       #zookeeper 的ip:port
       serverLists: 127.0.0.1:2181
       #名命空间,自己定义就好了
       namespace: my-job13
     jobs:
       #你的这个定时任务名称,自定义名称
       oneSimpleJob:
         #定时任务的全路径名
         elasticJobClass: com.xdx97.elasticjob.job.OneSimpleJob
         #定时任务执行的cron表达式
         cron: 0/30 * * * * ?
         #分片数量
         shardingTotalCount: 1
         overwrite: true
         jobErrorHandlerType: EMAIL
         job-listener-types: simpleJobListener
   ```
   
   
   **In addition, please take another look #1917**
   
   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