Comments (10)
Hello, @Sudheer786 !
- I'm not sure how the issue is related to the Spring Integration and its Samples.
- I'm not aware in any issue on the matter regarding Java versions.
- I see you use
@Scheduled
againstprivate static
method. Weird. How about to try the same for normalpublic
method?
from spring-integration-samples.
Hi Artem,
I made it as a static method as I need it running before the class gets Initialized,
here are the complete details,
- The below Code is working fine on my local set up(windows , jdk 1.8,Tomcat 7)
- the same Code is not working on the Development box (Linux,jdk 1.7,Tomcat 7)
Server Details:
Linux r007ppn0c 2.6.32-358.23.2.el6.x86_64 #1 SMP Sat Sep 14 05:32:37 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
jdk1.7.0_21/bin/java -Djava.util.logging.config.file=/xjp/appserver_1/tomcat/apache-tomcat-7.0.42/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms4096m -Xmx4096m -XX:PermSize=256m -XX:MaxPermSize=512m -Denv=Dev_CNJ -Dgrails.env=Dev_CNJ -Djava.awt.headless=true -Dliquibase.should.run=false -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseParNewGC -XX:NewSize=512m -XX:MaxNewSize=512m -XX:+UseConcMarkSweepGC -XX:+DisableExplicitGC -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:/xjp/tomcat/apache-tomcat-7.0.42/logs/gc.log -Dderby.system.home=/xjp/appserver_1/tomcat/apache-tomcat-7.0.42/derby -Dspring.profiles.active=Dev,ldap-properties -Ddomain=Dev -Ddivision=BNYMellon -DdataCenter=CNJ -Dcom.sun.management.jmxremote=ptql:State.Name.eq=java,Args.*.ew=catalina.base=/xjp/appserver_1/tomcat/apache-tomcat-7.0.42 -Djava.endorsed.dirs=/xjp/appserver_1/tomcat/apache-tomcat-7.0.42/endorsed -classpath /xjp/appserver_1/tomcat/apache-tomcat-7.0.42/bin/bootstrap.jar:/xjp/appserver_1/tomcat/apache-tomcat-7.0.42/bin/tomcat-juli.jar -Dcatalina.base=/xjp/appserver_1/tomcat/apache-tomcat-7.0.42 -Dcatalina.home=/xjp/appserver_1/tomcat/apache-tomcat-7.0.42 -Djava.io.tmpdir=/xjp/appserver_1/tomcat/apache-tomcat-7.0.42/temp org.apache.catalina.startup.Bootstrap start
Listener Code is as below:
@Configuration
@EnableScheduling
public class CSVFileProcessor {
@Scheduled(fixedRate = 10000)
public static synchronized void pollDirectory() {
System.out.println("***started Polling***");
faxFolder = Paths.get(folderPath);
try {
watchService = FileSystems.getDefault().newWatchService();
faxFolder.register(watchService,
StandardWatchEventKinds.ENTRY_CREATE);
do {
WatchKey watchKey = null;
try {
watchKey = watchService.take();
} catch (InterruptedException e) {
System.out.println("Interrupted Exception cause "
+ e.getMessage() + e);
e.printStackTrace();
} catch (Exception e) {
System.out.println("Exception cause .. " + e.getMessage()
+ e);
}
for (WatchEvent event : watchKey.pollEvents()) {
WatchEvent.Kind kind = event.kind();
if (StandardWatchEventKinds.ENTRY_CREATE.equals(event
.kind())) {
String fileName = event.context().toString();
System.out.println("File Created:" + fileName);
String txtFileAbsPath = faxFolder.toString()
.concat("\\").concat(fileName);
System.out.println("##### Text file absolute Path .. "
+ txtFileAbsPath);
if (txtFileAbsPath.contains(".txt")) {
System.out
.println("************** calling processFile() method on file : "
+ txtFileAbsPath);
processFile(txtFileAbsPath);
}
}
}
valid = watchKey.reset();
} while (valid);
} catch (IOException e) {
System.out.println("IOException while polling Directory cause "
+ e.getMessage() + e);
e.printStackTrace();
}
}
}
and the error on Server as mentioned above ,
Dec 28, 2015 1:38:00 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'appDispatcher'
Is there anything you suspect on the above please ?
thanks In Advance .
from spring-integration-samples.
I made it as a static method as I need it running before the class gets Initialized,
???
How you can make it running before class gets Initialized, if it is @Scheduled
?
From other side it doesn't work until Spring Framework processes your class fully as bean.
See ScheduledAnnotationBeanPostProcessor.postProcessAfterInitialization()
:
Runnable runnable = new ScheduledMethodRunnable(bean, method);
So, we deal here with the bean exactly, not class. Therefore your static
stuff does not make sense for Spring.
From other side it looks like the problem is somewhere in a different place and doesn't relate to the @Scheduled
...
You should dump
your Tomcat's process and see where is the stuck for your threads.
from spring-integration-samples.
yeah , I got you .. sorry
below is the Exception where I am stuck ,
- locked <0x0000000700c244b8> (a java.lang.Class for com.activiti.extension.bean.CSVFileProcessor)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
"pool-3-thread-1" prio=10 tid=0x000000000119b800 nid=0x3ac4 waiting on condition [0x00007f9fd76c3000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000006fccd0120> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1085)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:807)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
"Thread-6" daemon prio=10 tid=0x0000000001e13000 nid=0x3ac3 in Object.wait() [0x00007f9fd77c4000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x0000000702e167e0>
(a java.lang.Object)
at org.activiti.engine.impl.asyncexecutor.AcquireAsyncJobsDueRunnable.run(AcquireAsyncJobsDueRunnable.java:86)
- locked <0x0000000702e167e0> (a java.lang.Object)
- locked <0x00000007030c9258> (a org.activiti.engine.impl.asyncexecutor.AcquireAsyncJobsDueRunnable)
at java.lang.Thread.run(Thread.java:722)
"Thread-5" daemon prio=10 tid=0x0000000001e17800 nid=0x3ac2 in Object.wait() [0x00007f9fd78c5000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x0000000702fba728>
(a java.lang.Object)
at org.activiti.engine.impl.asyncexecutor.AcquireTimerJobsRunnable.run(AcquireTimerJobsRunnable.java:88)
- locked <0x0000000702fba728> (a java.lang.Object)
- locked <0x00000007030c9280> (a org.activiti.engine.impl.asyncexecutor.AcquireTimerJobsRunnable)
this might be being caused as I kept synchronized for my @scheduled
method.
@Scheduled(fixedRate = 10000)
public static synchronized void pollDirectory()
from spring-integration-samples.
And? Does it help you somehow to overcome issue?
I see Activity is involved in the process.
So, more and more questions where is the problem with the Spring Integration?..
You have a dead lock with the fixedRate
, when the next task is initiated after the start of the previous one. But yes, having synchronized
there doesn't allow to go ahead and this new task is stuck. After the fixedRate = 10000
it initiates a new task again and so on.
Consider to use fixedDelay
instead.
from spring-integration-samples.
Note: please, read about the comments syntax here on the GitHub: https://guides.github.com/features/mastering-markdown/.
from spring-integration-samples.
Hi Artem,
yeah , after removing 'static' and 'synchronized' specifiers from the method
The Server is up and running .
we are developing this to run along with Activiti , hence it becoming a little difficult to solve the Issues .
thanks a lot for your inputs which helped me to solve the Issue.
from spring-integration-samples.
Glad to hear!
Let us know if we can close the issue or do that yourself.
Comeback to us anytime, but try to post the issue in the proper place.
from spring-integration-samples.
Hi Artem,
thanks a lot .. sure , I will make sure to post in proper place.
I am closing the Issue.
from spring-integration-samples.
I'll give it a try then,thanks a lot ,gus
from spring-integration-samples.
Related Issues (20)
- JSON or Pipe(|) based DSL for dynamic flow generation in Spring Integration HOT 1
- why @ConditionalOnBean annotation does't work well on the bean which annotated @@MessagingGateway ? HOT 1
- What is required to make DynamicTcpClientApplication also return data with the send interface? HOT 2
- Investigate Failing Test in tcp-client-server-multiplex
- SFTP delegation example HOT 8
- Only accepts one instance of multipart file not an array of multipart file HOT 7
- Add examples for using SI with Project Reactor HOT 4
- Project Structure - Reorganize in favor of JavaDSL and Reactive support HOT 12
- How to import and compile the project locally HOT 1
- Can add the sample code of mqttv5 in spring.integration.samples.basic.mqttv5? HOT 1
- How do I create multiple MQTTClients and generate messages using Spring-Integration-MQTT? HOT 1
- Why getClientInstance is used for inbound and getAsyncClientInstance is used for outbound to get synchronous and asynchronous clients. HOT 5
- Trying to find code examples on Spring Integration scatter gather HOT 3
- How to set up apply-sequence=true through xml configuration HOT 1
- Server-side logging seems to be broken HOT 2
- IMAP with OAuth 2 authentication HOT 8
- Payload Enricher with request-payload-expression="payload.username" HOT 10
- LoanBrokerSharkDetectorDemo.java:48: error: cannot find symbol HOT 1
- sftp - outbound transfer test doesn't work for embedded server HOT 6
- Sample projects to not compile with maven due to lack of <java.version/> property
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-integration-samples.