Forums Register Login

Duplicate threads created by @Schedule method

+Pie Number of slices to send: Send
I have a method that uses the @Schedule annotation.  It is suppose to create and execute one thread but two threads are getting created.



The messages that are created in the console.log are;
606225 [LargeThreadPool-thread-107] INFO com.uline.silverpopxmlapi.ftpdata.FTPFileCheck  - [USER:Unknown][TIER:DevClients] *** FTP job scheduled for 12/20/2016 17:52:08
606303 [LargeThreadPool-thread-121] INFO com.uline.silverpopxmlapi.ftpdata.FTPFileCheck  - [USER:Unknown][TIER:DevClients] *** FTP job scheduled for 12/20/2016 17:52:08

How do I keep the second thread from being created?

I am running on Liberty server.
+Pie Number of slices to send: Send
 

I have a method that uses the @Schedule annotation


Is this method on a Stateless Session Bean?

It is suppose to create and execute one thread but two threads are getting created.


This is typical behaviour when your application runs in a cluster. In that case you need to configure a persistent timer (persistent=true) in your Liberty server.
+Pie Number of slices to send: Send
 

Is this method on a Stateless Session Bean?


The method is on a @Singleton Bean.

It is suppose to create and execute one thread but two threads are getting created.


I get the error on my local machine doing unit testing also.
+Pie Number of slices to send: Send
 

The method is on a @Singleton Bean.


Yeah, I have seen this happening also with the @PostConstruct method of a Singleton. You might want to try a Stateless Session Bean.

Are you sure that the two threads are running? It might just be the Logger logging twice.
+Pie Number of slices to send: Send
 

Are you sure that the two threads are running? It might just be the Logger logging twice.



It is not the logger, the application sends emails of its progress; I am getting duplicate emails from the application also.
I am not sure what the container does when it creates the timer and the timer times out.

I will give the @Stateless @Session bean a try.
+Pie Number of slices to send: Send
I have tried a @Stateless @Session bean and I get the same duplicate thread being created.



Still getting duplicate threads from Websphere Liberty.
+Pie Number of slices to send: Send
 

Still getting duplicate threads from Websphere Liberty.


Sounds like a bug to me.

I don't know if you are deploying locally from the Eclipse-WAS-liberty plugin but that has given me unexpected results more than once. If so, try to deploy the ejb-jar or ear manually through the admin console.

Another thing I would check is the ejb-jar.xml: you don't have the same EJB declared in the ejb-jar.xml and by annotations, do you?
+Pie Number of slices to send: Send
 

Another thing I would check is the ejb-jar.xml: you don't have the same EJB declared in the ejb-jar.xml and by annotations, do you?



I do not,  my ejb-jar file is empty.

Here are the EJB annotations I am using:

RunSilverpopReportBean


SilverpopTimer


My method is annotated using the @Schedule annotation:


Still submits a duplicate job.
Nothing up my sleeve ... and ... presto! A tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1575 times.
Similar Threads
to understand which *.MF to use
@Timeout applies to incremental scheduler?
Error While Starting JBoss 5.1.0 GA!!!
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 05:26:46.