Skip to content

Problem integrating fiber wtih Apache Camel #328

@sakshivijay

Description

@sakshivijay

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions