i am trying to understand the karaf thread model.
from what i can understand in OSGI in case the bundle starts threads it is also responsible for closing them.
is this the case in karaf as well?
are there any other solutions for managing threads in karaf?
Taken from the extra comment.
No the OSGi framework will not manage your threads.
If you spawn threads from your bundle, you are supposed to take care of it.
For example in the stop Method of your Activator you can stop the thread pool you used.
Threads in OSGi work like in plain Java. So for example you can use Executors.
Related
I am using an bpmn process which is already running using thread and also using spring ftp where the Task scheduler thread is running but I found the application is cannot switch from the threads. Is there any way to invoke the task-scheduler process without any interrupt and I am using InboundchannelAdapter to copy files from FTP. Please suggest any feasible way to resolve the issue.
I don't see any issues in your question. And to be honest it fully isn't clear.
Please, be more specific and sharing some code/config/logs/stack-trace sometime is really useful. More info, more chance to get quick and proper answer.
I guess your problem that you download files from FTP and in the same thread run a BPM process which might block eventually waiting for some actor action.
Fro this purpose you should shift Spring Integration flow on the <poller> to different thread and don't steal task-scheduler resources. They are really so expensive for the whole system. Consider to use enough big ThreadPoolTaskExecutor for the task-executor reference on the <poller>. Also there is an ExecutorChannel for you with similar thread shifting capabilities.
I'm trying to execute subprocesses from within my application server (Glassfish 3.1.2)
Therefore I discovered the Apache Commons Exec library. The problem is that this library creates threads which should not be done on an application server because the server is not aware of these threads.
What could be a solution to this problem?
Would it be possible to create a message component written in Java SE who consumes messages containing information about pending jobs and register it with the application server?
The application server would then not have to deal with runtime exceptions and threads but just consume messages which contain the result or an exception.
Do you have any better ideas?
You could either use:
MDB (as pointed by duffymo),
Servlets 3.0 asynchronous processing,
Asynchronous EJB invocation.
Effectively, it should give you similar functionality as plain subprocesses.
Using Java SE component which communicates with Java EE just to overcome using threads on your own sounds a bit like an overkill. Just read about mentioned solutions and try if any of them fits your needs.
Message driven beans were designed for asynchronous processing. It could be a solution to your problem. You can create a separate listener thread pool sized to handle the traffic.
Is there a command in OSGi to get information about the thread pool? E.g. minimum number of threads, current number of threads ... etc.
An OSGi framework does not know anything about thread pools. A framework implementation has some threads for asynchronous task like event dispatching but otherwise does not create threads/thread pools for the bundles. Any threads/thread pools created by bundles are unknown to the framework.
I know how to make thread safe in non distributed environment , but I want to know how to make Servlet thread safe in distributed environment ? Because one Servlet instance will be created per JVM by Servlet container and how to make them thread safe?
Thanks in Advance
Rajesh
Servlets that are running on different JVM instances do not have to worry about being thread safe since they don't share any resources.
The normal practices for making any code thread safe apply to servlets in the same JVM. For example, don't modify shared resources without making them synchronized and make use of java.util.concurrent classes, use thread local storage, etc.
Any code is said to be Not Thread Safe if there will be concurrency issues when that piece of code is executed by different threads.
In Distributed Environment, there is no way two threads from different JVM can access the servlet instance.
are there any performance limitations using IBM's asynchbeans?
my apps jvm core dumps are showing numerous occurences of orphaned threads. Im currently using native jdk unmanaged threads. Is it worth changing over to managed threads?
In my perspective asynchbeans are a workaround to create threads inside Websphere J2EE server. So far so good, websphere lets you create pool of "worker" threads, controlling this way the maximum number of threads, typical J2EE scalability concern.
I had some problems using asynchbeans inside websphere on "unmanaged" threads (hacked callbacks from JMS Listener via the "outlawed" setMessageListener). I was "asking for it" not using MDBs in the first place, but I have requisites that do not feet MDB way.