How to change thread pool configuration in Apache CXF - apache-camel

I have created a service which is using camel and cxf. I am trying to increase the performance and utilization of CPU, for this I have configured the threadPoolProfile for Camel EIP's and multiple thread pools are getting created. How can I configure similarly for CXF thread pool.

If you are using Karaf container as explained in the discussion link you can configure the pool just by adding a *.cfg file.
Ex:
File to be added : $KARAF_HOME/etc/org.apache.cxf.http.jetty-8017.cfg
File content:
port=8017
threadingParameters.minThreads=10
threadingParameters.maxThreads=50
Even if Karaf is not in use, below spring configuration can be used to achieve the same :
<httpj:engine-factory bus="online-tests" >
<httpj:engine port="8017" >
<httpj:threadingParameters minThreads="10" maxThreads="50" />
</httpj:engine>
</httpj:engine-factory>

Related

Apache Camel not monitoring file changes

In continuation to the thread "How can Apache Camel be used to monitor file changes?"
I am using camel version 2.23.0, URL looks like
?noop=true&idempotentKey=${file:name}-${file:modified}
But the updated file is still not consumed by camel.
?noop=true&idempotentKey=$simple{file:name}-$simple{file:modified}

What Queue or queues is a camel route listening on

How can I determine what, if any, ActiveMQ queue a camel route is a consumer of? The route is running as a bundle within Karaf.
You have to define it yourself. Every Camel route starts with a from statement. For ActiveMQ this would look somehow like this
from("activemq:queue:myAwesomeQueue")...
This route would create an ActiveMQ consumer that consumes every message arriving on the myAwesomeQueue.
The connection to the broker is "hidden" behind the activemq:. This is a Camel component (the ActiveMQ component) that needs to be configured to connect to the broker.
EDIT: Add operational perspective
Hawtio is a webconsole that uses Jolokia to get data. Jolokia makes JMX information available through a REST API.
If JMX is enabled, you can get loads of information about the CamelContext and/or ActiveMQ. For example the endpoint of an ActiveMQ consumer as in your case.
Unfortunately I can't upload a screenshot because the image domain of SO is blocked, but Google gives you lots of them.

Apache camel Quartz endpoints : rescheduling at runtime

Is it possible to change cron expression of camel quartzendpoint at runtime using jmx or so ?
You can update the route itself (including configuration of the quartz endpoint). As an example you can see how Camel plugin of Hawt.io (http://hawt.io/plugins/camel/) does it
No, but you could experiment with CamelContext and see if you can add new routes at runtime.

activemq - create new broker in servicemix/fuseesb

I'm using fuseesb as my esb and i wanted to create new message broken in activemq, so i'm doing:
in karaf: activemq:create-broker --name=myBroker
then i see:
Creating file: #|green .../myBroker-broker.xml|
Default ActiveMQ Broker (myBroker) configuration file created at: .../myBroker-broker.xml
Please review the configuration and modify to suite your needs.
i see that the file was created, but in karaf i see then:
karaf#root> Exception in thread "SpringOsgiExtenderThread-26" java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:171)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:368)
at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
at java.lang.Thread.run(Thread.java:679)
And i don't know what it is...
Could you help me?
I had the same exception and fixed it by changing the configured ports in my newly-generated broker xml file so they didn't clash with the default broker, which is configured in etc/activemq-broker.xml

How do you debug CXF endpoint publishing?

Given the "cxf-osgi" example from fuse source's apache-servicemix-4.4.1-fuse-00-08, built with maven 3.0.3, when deploying it to apache karaf 2.2.4 and CXF 2.4.3 the web service is never published and never visible to the CXF servlet (http://localhost:8181/cxf/). There are no errors in the karaf log. How would one go about debugging such behavior?
It's worth turning up the log level(s) - you can do this permanently in the etc/org.ops4j.pax.logging.cfg or in the console with log:set TRACE org.apache.cxf - IIRC this will show some useful information.
Also check that it's actually published on localhost/127.0.0.1 - it may well be being published on another interface, the IP of the local network but not localhost. Try using 0.0.0.0 as the the address, that way it will bind to all available interfaces.
As you're using maven, you can download the CXF source (easily in Eclipse) and connect a remote debugger to the Karaf instance, with some strategically placed breakpoints you should be able to get a handle on what's going on.
Try changing to Equinox instead of the default of Felix. There is a bug in 2.4.3 in that it doesn't work well with Felix. Alternatively, CXF 2.4.4 is now available that should also fix it.
Take a look at this issue I filed this week: https://issues.apache.org/jira/browse/CXF-4058
What I found is that if my beans.xml is loaded before the cxf bundle jar, then the endpoints are registered with CXF but not with the OSGi http service. So everything looks good from the logs but the endpoints are never accessible. This is a race condition.
I did two workarounds: 1) in the short term, just move my own jars later in the boot order (I use Karaf features) so Spring and CXF are fully loaded before my beans.xml is read and 2) abandon Spring and roll my own binding code based loosely on this approach: http://eclipsesource.com/blogs/2012/01/23/an-osgi-jax-rs-connector-part-1-publishing-rest-services/
I just implemented solution #2 yesterday and I'm already extremely happy with it. It's solved all of my classloader issues (before I had to manually add a lot of Import-Package lines because BND doesn't see beans.xml references) and fixed my boot race condition.

Resources