puniverse / quasar

Fibers, Channels and Actors for the JVM
http://docs.paralleluniverse.co/quasar/
Other
4.56k stars 575 forks source link

Problem integrating fiber wtih Apache Camel #328

Open sakshivijay opened 5 years ago

sakshivijay commented 5 years ago

I am trying to integrate quasar fiber with Apache Camel. The way I am trying to achieve this is by doing something like this-

Fiber fiberExchange = new Fiber(new SuspendableCallable() { public Exchange run() throws SuspendExecution, InterruptedException { return producerTemplate.send(clientURL, exchange); } }).start();

fiberExchange.get();

This internally uses HttpClient which was causing CPU hogging but nonetheless I was able to get responses correctly without error. To solve for CPU hogging, I tried to override HttpClient by FiberHttpClient provided by Comsat-

public class FiberHttpEndpoint extends HttpEndpoint { public FiberHttpEndpoint(final HttpEndpoint httpEndpoint , final HttpComponent httpComponent) throws URISyntaxException { super(httpEndpoint.getEndpointUri() , httpComponent , httpEndpoint.getHttpUri() , httpEndpoint.getClientBuilder() , httpEndpoint.getClientConnectionManager() , httpEndpoint.getHttpClientConfigurer()); }

@Override 
protected HttpClient createHttpClient() { 
        return FiberHttpClientBuilder.create(50). // use 2 io threads 
                setMaxConnPerRoute(super.getConnectionsPerRoute()). 
                setMaxConnTotal(super.getMaxTotalConnections()). 
                build(); 
} 

}

public class FiberHttpComponent extends HttpComponent { private static LoggerFacade LOGGER = LoggerFacadeManager.getLogger(HystrixHttpComponent.class); public FiberHttpComponent(){ super(); }

@Override 
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { 
    final HttpEndpoint defaultEndpoint = (HttpEndpoint) super.createEndpoint(uri, remaining, parameters); 
    return new FiberHttpEndpoint(defaultEndpoint, this); 
} 

}

And passing this Component while calling the endpoint. But after doing this change, I have started getting SuspendExecution Error due to uninstrumented methods in Fiber.java exec() method.

I have already enabled “-Dco.paralleluniverse.fibers.verifyInstrumentation=true” but it is now giving any uninstrumented method. VerifyInstrumentation was giving me warning earlier, but it got solved after marking those methods as suspendable. This is resulting in response not getting set correctly set in camel exchange.

Could you please point me to what am I missing here and how can I check which methods are uninstrumented resulting in this error.