Quantcast
Channel: Active questions tagged atlassian-plugin-sdk - Stack Overflow
Viewing all articles
Browse latest Browse all 282

@Scheduled in Spring Doesn't work on Tomcat

$
0
0

Hello Brilliant people out there,

I've created a Jira plugin to do a specific task for us and i need to schedule this plugin call every few hours. I'm trying to use Spring annotations @Scheduled(fixedDelay = 6*1000) on the method and @Component@EnableScheduling on my Bean class. My bean also uses InitializingBean, DisposableBean to do few bits and pieces for us before and after bean is created & before destruction.

Now when i perform my tests on local machine (using JUnit) the method call gets scheduled and works fine . What seems very strange that when this plugin is put into Jira which is deployed on Tomcat it doesn't seem to schedule . The afterPropertiesSet & destroy methods are being called up properly but not @Scheduled(fixedDelay = 6*1000)

I've done a lot of research about this from last few days and also have got alternate solution using Atlassian Schedulers but I fail to understand why @Scheduled(fixedDelay = 6*1000) doesn't work ?

I've tried to put all the relevant information but if something is missing please ask :-) Thank you for your help!!

@Component
@EnableScheduling
public class RemedyJiraIntegrationListener implements InitializingBean, DisposableBean {

RemedyJiraIntegration remedyJiraIntegration = null;

public RemedyJiraIntegrationListener() {

    remedyJiraIntegration = RemedyJiraIntegrationSingletonInstance.getInstance();
}

/**
     * Called when the plugin has been enabled.
     * @throws Exception
     */

    @Override
    public void afterPropertiesSet() throws Exception {

        LoggingUtility.writeRemedyJiraLog("Installation of a plugin has scheduled a Job at : " + new Date());
// To-do

    }


    @Scheduled(fixedDelay = 6*1000)
    public void scheduleFixedRateTask() {

        LoggingUtility.writeRemedyJiraLog("Fixed rate task - " + System.currentTimeMillis() / 1000);
        System.out.println(
            "Fixed rate task - " + System.currentTimeMillis() / 1000);
}

    /**
     * Called when the plugin is being disabled or uninstalled.
     * @throws Exception
     */
    @Override
    @PreDestroy
    public void destroy() throws Exception {

        LoggingUtility.writeRemedyJiraLog("Uninstallation or disablement of a Plugin started at : " + new Date());
// To-do

    }

}


Viewing all articles
Browse latest Browse all 282

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>