I call the rabbitMQ client (and not the server) from my Java code running in the Glassfish V4.0 container (build 89) to connect to the rabbitmq server on another machine. According to the client document rabbitmq, we must provide an instance of ManagedThreadFactory to connect rabbitmq to create threads.
I tried using DefaultManagedThreadFactory using
ctx.lookup ("Java: comp / DefaultManagedThreadFactory")
Failed to complete
Search failed for "java: comp / DefaultManagedThreadFactory" in SerialContext ...
Trying @Resource (lookup = "concurrent / __ DefaultManagedThreadFactory") results in an NPE.
I am not very versed in java EE, and I use this container as an interface for my web services. It is clear that I need to do something more / different. However, I could not find much more than
https://blogs.oracle.com/arungupta/entry/create_managedexecutorservice_managedscheduledexecutorservice_managedthreadfactory_contextservice
http://javahowto.blogspot.in/2011/02/how-to-create-and-look-up-thread-pool.html
Can any Java EE expert tell me the right Voodoo spells to make this work?
Update-1
@Resource(name = "concurrent/__defaultManagedThreadFactory")
ManagedThreadFactory threadFactory;
// set on rabbitmq connection Factory
factory.setThreadFactory(threadFactory);
java.lang.NullPointerException
at java.util.concurrent.ThreadPoolExecutor.<init>(ThreadPoolExecutor.java:1312)
at java.util.concurrent.ThreadPoolExecutor.<init>(ThreadPoolExecutor.java:1233)
at java.util.concurrent.Executors.newFixedThreadPool(Executors.java:114)
at com.rabbitmq.client.impl.ConsumerWorkService.<init>(ConsumerWorkService.java:36)
Update-2
axel - in my case there is nothing special. What I'm looking at is just trying to use the rabbitmq java client inside GFV4. therefore to reproduce problems
- You need to start the rabbitmq server
- connect to the rabbitmq server using client code, which is part of the war deployed on GF
- API rabbitmq (https://www.rabbitmq.com/api-guide.html) @see Factory.
.
- rabbitmq Github
ManagedThreadFactory GF Admin, .
-3
Factory - JNDI. , - . (, java EE7 Github)
/Hk2/CDI/ ..? , ?