-
1. Threading inside JBoss
vijaysachin Mar 3, 2011 2:09 AM (in response to thehunt)I am new to Jboss. Please tell me how to configure thread pool. I fedup by searching google from long time please me.
I found a link http://community.jboss.org/wiki/ConfigBasicThreadPool in this link they had not specfied which file I have to put those XML code.
And also give some sample code how can I implement Thread Pool
-
2. Threading inside JBoss
alesj Mar 3, 2011 5:27 AM (in response to vijaysachin)Please tell me how to configure thread pool. I fedup by searching google from long time please me.
* http://lmgtfy.com/?q=jboss+thread+pool ... top item ;-)
-
3. Threading inside JBoss
vijaysachin Mar 3, 2011 5:55 AM (in response to alesj)Seen all the links man but cannot get proper Information. Please post some same example
-
4. Threading inside JBoss
alesj Mar 3, 2011 6:02 AM (in response to vijaysachin)Please post some same example
What kind of example?
The wiki goes into details explaining all sorts of config options.
And the actual code is here: https://github.com/dmlloyd/jboss-threads
While you can search the JBossAS config files for actual usage.
-
5. Threading inside JBoss
jaikiran Mar 3, 2011 8:05 AM (in response to vijaysachin)Actually, you even got a detailed reply in this post here http://www.coderanch.com/t/528949/JBoss/configure-Thread-pool-JBOSS
-
6. Threading inside JBoss
vijaysachin Mar 3, 2011 9:12 AM (in response to jaikiran)Actually, you even got a detailed reply in this post here http://www.coderanch.com/t/528949/JBoss/configure-Thread-pool-JBOSS
But the above link shows how to creates MDB pool.
But I need to know how can we creat normal Thread pool in jboss
While googling I got to see this one link http://community.jboss.org/wiki/ConfigBasicThreadPool
But below they had not specified which xml file I need to change. And also I need to know how can I use this Java code
Configuration of a BasicThreadPool
The basic thread pool provides a simple thread pooling service
Example Configuration
<mbean code="org.jboss.util.threadpool.BasicThreadPool" name="jboss.jca:service=WorkManagerThreadPool">
<!-- The name that appears in thread names -->
<attribute name="Name">WorkManager</attribute>
<!-- The maximum amount of work in the queue -->
<attribute name="MaximumQueueSize">1024</attribute>
<!-- The maximum number of active threads -->
<attribute name="MaximumPoolSize">100</attribute>
<!-- How long to keep threads alive after their last work (default one minute) -->
<attribute name="KeepAliveTime">60000</attribute>
</mbean> -
7. Threading inside JBoss
jaikiran Mar 3, 2011 9:13 AM (in response to vijaysachin)vijaysachin sachin wrote:
Actually, you even got a detailed reply in this post here http://www.coderanch.com/t/528949/JBoss/configure-Thread-pool-JBOSS
But the above link shows how to creates MDB pool.
But I need to know how can we creat normal Thread pool in jboss
And how and where do you plan to use that thread pool?
-
8. Threading inside JBoss
vijaysachin Mar 3, 2011 9:19 AM (in response to jaikiran)And how and where do you plan to use that thread pool?
My requirement is something different MDB pool can solve my requirement.
But I need to know like Connection pool, MDB pool how can I create Thread Pool in jboss.
Which xml files need to be changed?
-
9. Threading inside JBoss
peterj Mar 3, 2011 10:32 AM (in response to vijaysachin)I still do not understand why my answer does not solve your problem. You stated that when your MDB grabs a message off of the queue that it might take a long time for it to process the message and you do not want the other messages in the queue being ignored during that time. I told you that there are actually 15 (by default) MDB instances processing messages out of the queue and even showed you how you could increase that limit.
If you pull a message off a queue and decide you need to fork a thread to process the message, then you are not thinking correctly. The whole purpose of a messaging system is so that you can process things asynchronously.
Or was message processing by and MDB not your real requirement? If you get some other request, let's say from a web service, and that request will take a long time to process, then I suggest that you create another messaging queue and place the request on that queue and have an MDB do the processing. That is the whole purpose of messaging. Don't fight the Java EE architecture, and don't limit yourself to requirements that you don't really need. Instead, make use of the Java EE architecture.
-
10. Threading inside JBoss
mhvenkat Mar 26, 2011 6:48 PM (in response to peterj)Hi Peter,
I have same frustration as Vijay. I would like to use JBoss threads programmatically in non-MDB cases. In a Web App, when I want to integrate with an external service, I would like to fork a thread to invoke the external http service.
Rather than using JDK concurrent util package, if I want to JBoss
org.jboss.util.threadpool.BasicThreadPool for my custom logic how will I do it programmatically?
Sure I can add an entry in the conf\jboss-service.xml or jbossweb.sar\META-INF\jboss-beans.xml to define a custom worker thread pool
Now I in order to use this custom worker thread pool, I think we need to develop JMX MBean Proxy to invoke it.
Can someone provide a code snippet to develop JBoss MBean and its Proxy that can invoked programmatically in an jboss web app ?
Thanks
--Mahesh
-
11. Threading inside JBoss
mhvenkat Mar 26, 2011 7:44 PM (in response to mhvenkat)I think I finally have the answer on how to feed a runnable task to the BasicthreadPool. Look at
http://community.jboss.org/message/230378
This post describes the configuration and code snippet which I have elaborated below ...
Use JBossWorkManager.
Implement a javax.resource.spi.work.Work; which extends Runnable interface and implement the run() method.
Mywork implements Work {
void run() {
// your main logic
}
}
Get an instance of JBossWorkManager using the following code:
WorkManager customWorkManager = null; // JBossWorkManager extends WorkManager
Work mywork = new MyWork();
try {
MBeanServer server = MBeanServerLocator.locateJBoss();
customWorkManager = (WorkManager) server.getAttribute(new ObjectName(
"custom.jca:service=CustomWorkManager"), "Instance");customWorkManager.getInstance().doWork(mywork);
} catch (MalformedObjectNameException e) {
// TODO
} catch (Exception e) {
// TODO
}Let me know if this works for you.
Thanks
--Mahesh
-
12. Re: Threading inside JBoss
spyhunter99 Mar 11, 2012 4:21 PM (in response to mhvenkat)From the class that actual performs the work, how do you access context variables or objects that are necessary to do the work?
I was expecting something like,
customWorkManager.getInstance().doWork(mywork); //this does the enqueue
then the work manager does the dequeue and handles the threading
void run() {
// your main logic
Object j = //some code is needed to get stuff from the queue?
}
-
13. Re: Threading inside JBoss
spyhunter99 Mar 11, 2012 4:31 PM (in response to spyhunter99)Ahh never mind, I understand the way it works now. thanks for the post
-
14. Re: Threading inside JBoss
spyhunter99 Mar 11, 2012 5:59 PM (in response to spyhunter99)I'm using Jboss 6.1 and I keep getting instancenotfound exception on server.getAttribute. Should the thread pool be visible in the jmx console?
In addition, the api seems to be different in jboss 6.1.
customWorkManager.getInstance().doWork(mywork);
doesn't exist
customWorkManager.doWork(mywork);
does