On September 6, 2013 at 2:09:38 PM, Russell Hart (russel...@googlemail.com) wrote:
Does anyone have any experience of using Hystrix with WebSphere or any JEE container?? I'm wondering how the thread-pool strategy would work in this case as in my experience these containers usually don't like threads being created outside of their own thread pools.
--
You received this message because you are subscribed to the Google Groups "HystrixOSS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hystrixoss+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Hey Russell,
public class MyHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy {
/*
* @see com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy#wrapCallable(java.util.concurrent.Callable)
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Callable wrapCallable(Callable callable) {
return new MyHystrixContextCallable(callable);
}
/* Set custom ThreadPoolExecutor based on WebSphere Async Bean framework which is used to
* propagate a user's J2EE Subject onto the worker thread.
*
* See http://www.ibm.com/developerworks/websphere/techjournal/0606_johnson/0606_johnson.html
* and the classes in lc.util/base under the com.ibm.lconn.core.concurrent package.
*
*/
public ThreadPoolExecutor getThreadPool(final HystrixThreadPoolKey threadPoolKey, HystrixProperty<Integer> corePoolSize, HystrixProperty<Integer> maximumPoolSize,
HystrixProperty<Integer> keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) {
InitialContext ctx;
ThreadPoolExecutor tpe=null;
try {
ctx = new InitialContext();
WorkManager wm = (WorkManager)ctx.lookup("wm/default");
ThreadFactory tf = new WASThreadFactory(wm);
tpe = new ThreadPoolExecutor(corePoolSize.get(), maximumPoolSize.get(), keepAliveTime.get(), unit, workQueue, tf);
} catch (NamingException e) {
LOGGER.error("err.failed.to.set.threadpool", e);
}
return tpe;
}
}
HystrixPlugins.getInstance().registerConcurrencyStrategy(new MyHystrixConcurrencyStrategy());
JOIN_OR, myTimeout) after calling the startWork(...) method...