You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "weiro-9-w7 (via GitHub)" <gi...@apache.org> on 2024/08/14 06:16:32 UTC

[I] How to extend AbstractDistributeOnceElasticJobListener and config by using SPI [shardingsphere-elasticjob]

weiro-9-w7 opened a new issue, #2430:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/2430

   ## Question
   
   **For English only**, other languages will not accept.
   
   Before asking a question, make sure you have:
   
   - Googled your question.
   - Searched open and closed [GitHub issues](https://github.com/apache/shardingsphere-elasticjob/issues).
   - Read documentation: [ElasticJob Doc](https://shardingsphere.apache.org/elasticjob/current/en/overview/).
   
   Please pay attention on issues you submitted, because we maybe need more details. 
   If no response anymore and we cannot reproduce it on current information, we will **close it**.
   
   1.  create class and extend AbstractDistributeOnceElasticJobListener
        @Slf4j
         public class DistributeOnceJobJobListener extends AbstractDistributeOnceElasticJobListener implements ElasticJobListener {
         
           public DistributeOnceJobJobListener(long startedTimeoutMilliseconds, long completedTimeoutMilliseconds) {
             super(startedTimeoutMilliseconds, completedTimeoutMilliseconds);
           }
         
           @Override
           public void doBeforeJobExecutedAtLastStarted(ShardingContexts shardingContexts) {
             log.info(shardingContexts.getJobName() + " begin distribute job executed");
           }
         
           @Override
           public void doAfterJobExecutedAtLastCompleted(ShardingContexts shardingContexts) {
             log.info(shardingContexts.getJobName() + " end distribute job executed");
           }
         
           @Override
           public String getType() {
             return "distributeOnceJobListener";
           }
         }
   3.  config the org.apache.shardingsphere.elasticjob.infra.listener.ElasticJobListener and specify the class
        org.example.elatisjobtest.job.DistributeOnceJobJobListener
   5.  start the app and throw exception, ServiceLoader can't find the Constructor
   
        Caused by: java.lang.NoSuchMethodException: org.example.elatisjobtest.job.DistributeOnceJobJobListener.<init>()
   	at java.base/java.lang.Class.getConstructor0(Class.java:3585) ~[na:na]
   	at java.base/java.lang.Class.getConstructor(Class.java:2271) ~[na:na]
   	at java.base/java.util.ServiceLoader$1.run(ServiceLoader.java:666) ~[na:na]
   	at java.base/java.util.ServiceLoader$1.run(ServiceLoader.java:663) ~[na:na]
   	at java.base/java.security.AccessController.doPrivileged(AccessController.java:569) ~[na:na]
   	at java.base/java.util.ServiceLoader.getConstructor(ServiceLoader.java:674) ~[na:na]
   	... 44 common frames omitted
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How to extend AbstractDistributeOnceElasticJobListener and config by using SPI [shardingsphere-elasticjob]

Posted by "weiro-9-w7 (via GitHub)" <gi...@apache.org>.
weiro-9-w7 commented on issue #2430:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/2430#issuecomment-2287982619

   elastic - job version is 3.0.4


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How to extend AbstractDistributeOnceElasticJobListener and config by using SPI [shardingsphere-elasticjob]

Posted by "weiro-9-w7 (via GitHub)" <gi...@apache.org>.
weiro-9-w7 closed issue #2430: How to extend AbstractDistributeOnceElasticJobListener and config by using  SPI
URL: https://github.com/apache/shardingsphere-elasticjob/issues/2430


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org