Announcement Announcement Module
Collapse
No announcement yet.
scheduled:task starts 5 similar tasks.... How can I get rid of this feature? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • scheduled:task starts 5 similar tasks.... How can I get rid of this feature?

    hi,

    my scheduled task is fired 5 times parallel. I only need one. My coded is:

    Code:
    public class LdapMirrorJob extends AbstractJob {
    
        LdapMirrorSynchronizer ldapMirrorSynchronizer;
    	
    	public LdapMirrorJob(LdapMirrorSynchronizer ldapMirrorSynchronizer){
    		super();
    		this.ldapMirrorSynchronizer = ldapMirrorSynchronizer;
    	}
    
    	public void doJob(){
    		
    		logger.info("executing job: start (LdapMirrorJob)..." +(Calendar.getInstance().getTimeInMillis()));
           }
    config is:
    Code:
    <bean id="ldapSyncJob" class="com.sonymusicbuzz.globaldir.jobs.LdapMirrorJob" >
          <constructor-arg index="0" ref="ldapMirrorSynchronizer"/>
    </bean>
    
      <task:scheduler id="scheduler" pool-size="1" /><!-- pool-size="15" -->
        <task:scheduled-tasks>
          <task:scheduled ref="ldapSyncJob" method="doJob" cron="0 0/2 * * * ?"  /> 
        </task:scheduled-tasks>
    any idea why I have 5 times the message from doJob()?

    thx

  • #2
    hi again, slightly changed to strip out the code. Output is:
    Code:
    [#|2013-07-25T13:20:00.000+0200|INFO|sun-appserver2.1|javax.enterprise.system.stream.out|_ThreadID=30221;_ThreadName=pool-57-thread-1;|executing job: start testJob)...1374751200000, rnd=95|#]
    
    [#|2013-07-25T13:20:00.001+0200|INFO|sun-appserver2.1|javax.enterprise.system.stream.out|_ThreadID=30213;_ThreadName=pool-53-thread-1;|
    executing job: start testJob)...1374751200001, rnd=51|#]
    
    [#|2013-07-25T13:20:00.001+0200|INFO|sun-appserver2.1|javax.enterprise.system.stream.out|_ThreadID=30217;_ThreadName=pool-55-thread-1;|
    executing job: start testJob)...1374751200001, rnd=33|#]
    
    [#|2013-07-25T13:20:00.001+0200|INFO|sun-appserver2.1|javax.enterprise.system.stream.out|_ThreadID=30215;_ThreadName=pool-54-thread-1;|
    executing job: start testJob)...1374751200000, rnd=24|#]
    
    [#|2013-07-25T13:20:00.001+0200|INFO|sun-appserver2.1|javax.enterprise.system.stream.out|_ThreadID=30219;_ThreadName=pool-56-thread-1;|
    executing job: start testJob)...1374751200001, rnd=76|#]
    where the code is that simple:
    Code:
    public class TestJob {
    
    	public void doJob(){
    		Random rnd = new Random();
    		System.out.println("executing job: start testJob)..." +(Calendar.getInstance().getTimeInMillis())+", rnd="+rnd.nextInt(100));
    	}
    
    }
    and conifg is:
    Code:
    <task:scheduled ref="testJob" method="doJob" cron="0 0/2 * * * ?"  />
    it is spring 3.1.1.RELEASE on Glassdfish c3.1.2

    thx

    Comment


    • #3
      no idea?

      I have tried to have a static flag isRunning, but obviously it will block second time run, but initially all 5 instance is triggered... This drives me crazy.

      thx

      Comment


      • #4
        is this Spring Scheduler is Quartz based? Next property is set somewhere:
        org.quartz.threadPool.threadCount = 1

        thx

        Comment


        • #5
          hi, noone else encounters this problem? I have made different wars with java5,6,7 with almost all possible combination, and linux glassfish with spring 3.1.1.RELEASE starts multiple threads for my TestJob.

          Comment


          • #6
            something found. It is not a good explanation, but something. If glassfish server has multiple virtual hosts, and each virtual host has a linked (default) web module, then test.war is not linked to any of these virtual hosts and ports. Then gf starts as many times, as many virtual hosts configured. For me it was 5 on gf 2.1.1, and 4 on gf 3.1.2. Crazy.

            Comment


            • #7
              Originally posted by pogacsa View Post
              something found. It is not a good explanation, but something. If glassfish server has multiple virtual hosts, and each virtual host has a linked (default) web module, then test.war is not linked to any of these virtual hosts and ports. Then gf starts as many times, as many virtual hosts configured. For me it was 5 on gf 2.1.1, and 4 on gf 3.1.2. Crazy.
              enh I think you‘ve catched the point

              Comment

              Working...
              X