Camel-restdsl and fabric8 http-gateway - apache-camel

I got a camel-restdsl route (among others) running on JBoss Fuse 6.2, I'd like to know if it is possible to have it gateway'ed by the fabri8 http-gateway. I know that is would work for CXF rest services implemented there but don't see any documentation about REST services implemented with RestDSL.
The route relies on on the restlet component (though I may have it changed to jetty or whatever other it may work).
Any pointers will be much appreciated!

Related

using reactive-streams with Apache Camel Saga

I would like to know if it is possible to use reactive streams in Apache Camel. I know reactive-streams is a component from Apache but I couldn't get it to work the way they explain in the documentation. I would like to know if there is any possible solutions available in github that could help me understand apache camel along with reactive-streams except the one's from apache.
I could possibly use Producer Template with reactor-core but the route logic that sits in RouteBuilder configure method would still be blocking I/O. Any helps would be appreciated?

JCachePolicy in Camel 2

I want to implement some content-caching on my Camel 2.23.2 routes. While researching I came across Camel's JCache component which, according to the documentation, should have a JCachePolicy that would:
"The JCachePolicy is an interceptor around a route that caches the "result of the route" - the message body - after the route is completed. If next time the route is called with a "similar" Exchange, the cached value is used on the Exchange instead of executing the route."
Which is basically exactly what I'm looking for. However, as it turns out this policy is only available in Camel 3.x and higher.
So my question is, how might I recreate this functionality in Camel 2.23.2?
The solution was quite simple. In the Camel 3.x branch the policy package is available and in it are only two files. The actual policy and the processor.
As it turns out, pending more testing, these files work very well with little adjustment.
On the policy you need to change the method definition for the "wrap" and "beforeWrap" methods. These require the routeContext, not the Route. But moving from the RouteContext to the route is simple enough.
On the processor, the main change is using the correct package for "DelegateAsyncProcessor" it extends.
With those changes everything seemingly works as documented. I used the ehcache spring boot starter in my pom without any further change to have it work with ehcache as it's cachemanager.
One other remark, when you want to use this, the model you want to cache needs to be serializable.

What is the CamelContext in apache?

I searched in web but did not find any explanation that what is the exactly CamelContext? where and how to use ?
I gone through below links also but not satisfied with explanation.
https://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/CamelContext.html
https://dzone.com/articles/apache-camel-tutorial-eip
There are many comparision for CamelContext with others, but what I am looking for is the what is it? I want some conceptual explanation.
Please help me to understand this.
It's roughly an instance of a Camel environment, or at least it's a reference to it. Most apps would only have one CamelContext, but you can have several if needed. Looking at the referenced document, it shows how the context has a lifecycle.
In most cases, the context will start and stop along with the application.
After seeing the videos in YouTube, I knew about the Apache camel framework,
and from that I got the answer that camelcontext is nothing but context of the 'apache camel framework' framework.
As many framework have context like Spring have an applicationcontext, Ninja have a context, same the 'Apache camel framework' have a context and that is called 'camelcontext'.
So, it is the run-time system of Apache Camel (framework) and it connects its different concepts such as routes, components or endpoints.
Reference :
Basic Apache Camel Tutorial

Can I use Camel and WMQ without JMS?

I am currently learning Camel, and have a specific project in mind that requires a Websphere MQ back-end, but I can't use JMS components, since I need a lot of non-jms headers, like MQIIH.
I found the camel-wmq project.
Is it the recommended solution ? Is it any good ?
You don't need to use jms. WMQ has a client API. Just download the wmq client jars and put them in your project and use them together with your Camel routes. You will probably put the wmq client code in a processor class or something similar. Off course best to test to put a message on a queue manually via RFHUTIL or something similar as a client so you are sure the environment setup is correct.
The suggested way of working with WMQ has always been through the JMS component since it enables you to painlessly switch to other providers if the need arises.
However, if you need to use some WMQ-specific function then my suggestion would be to extend the camel-wmq library - it contains only a subset of features supported by WMQ and does not support MQIIH headers that you need. Adding functionality to a component would probably involve more work than the solution Souciance Eqdam Rashti suggested but it would be a cleaner solution and more in line with Camel's philosophy. Also, you'd be giving back to the community and thus help make Camel a better tool for everyone :)
I would also suggest you go through the IBM MQ discussions on the Camel's official user group mailing list and see if you can salvage anything.

Configuring logging for ActiveMQ 5.5 on Tomcat 6 with web app using SLF4j and logback

I would like my web app to log using SLF4j and logback. However, I am using ActiveMQ - which then requires that some if its jars go in /usr/share/tomcat6/lib (this is because the queues are defined outside of the web app so the classes to support them must be at container level).
ActiveMQ 5.5+ requires SLF4j-api so that jar has to go in to. Because SLF4j is now starting it needs to have a logging library added or it will simply nop. Thus, logback-core and logback-classic go in too.
After quite some frustration I got this working well enough that I can tidy it up shortly. I needed to configure logback to use a JNDI lookup to get the context. Then it can lookup logback-kenobi.xml in my web app and have a separate configuration there.
However, I'm wondering if this is the best way to do this. For one, the context handling appears not to support the groovy format. I did have a logback.groovy in my web app that logged to console when I was developing locally (which means that Eclipse WTP works nicely) but logs to file and to Splunk Storm when everywhere else. I'm going to want to do something similar with this setup but I'm not sure if I should do that by overwriting the logback-kenobi.xml or some other method.
Note that I don't, currently, need Tomcat itself to log with slf4j although I am planning to do that. Nor do I really need ActiveMQ to log with slf4j but I did need it to stop spewing debug messages every 30s as it was doing. I am aware of tomcat-slf4j-logbak but I don't believe it is directly useful as it is ActiveMQ requiring logging which is the issue.
However, I'm wondering if this is the best way to do this.
Best is an opinion, working is a fact.

Resources