Problem integrating fiber with Camel

36 views
Skip to first unread message

Sakshi Vijay

unread,
Jun 9, 2019, 2:12:53 PM6/9/19
to quasar-pulsar-user
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<Exchange> fiberExchange = new Fiber<Exchange>(new SuspendableCallable<Exchange>() {
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.
Reply all
Reply to author
Forward
0 new messages