Are Apache Camel Mbeans extendable? - java

I would like to add few more attributes to the existent JMX Apache Camel route attributes. Is there a way of doing this either using Spring or Java code?

And to answer your question. No the routes mbean are not extensible.
Though if you build custom components you can annotate your component with JMX annotations to have JMX operations and attributes enlisted out of the box. But this is only for components, and not the standard route, camelcontext, mbeans etc.
See details at: http://camel.apache.org/camel-jmx.html

Related

How can I find out what is registering a Spring bean?

I have an application with a complex mix of #Imports and #ComponentScans.
There is a class marked as #Component that I expected not to be added to the application context, but it is, and I want to climb back the scan chain to find out why is that bean registered.
Is there any easy way I can do that e.g. by using Spring Tools 4 Eclipse's plug-in features or maybe programmatically? Googling keywords led to no result.
Enable the actuator and look at the beans endpoint (/actuator/beans).
The resource property tells you, where this bean might have been included.

Apache Camel Restlet Producer Connector

I would like to use the new Connector strategy within Apache Camel 2.19.x to use the Restlet Producer to connect to a JasperServer instance on a scheduled basis to download certain reports.
Basically what I would like to do is convert the following:-
from("timer://runOnce?repeatCount=1&delay=5000")
.setHeader(RestletConstants.RESTLET_LOGIN).simple("jasperadmin") .setHeader(RestletConstants.RESTLET_PASSWORD).simple("jasperadmin")
.to("restlet:http://localhost:8181/jasperserver/rest_v2/reports/reports/interactive/MapReport.pdf?restletMethods=get").to("file:C:/tmp/camel")
to
from("jasper-server").to("file:C:/tmp/camel")
The problem is that the RestletComponent sets up the RestletConsumer by default and I am not sure how to set it into Producer mode using an component option or whether I should use the SchedulerComponent as my base and then somehow integrate the Restlet functionality into the component. Would it be better to use the HttpComponent as the base component instead?
I haven't really used RestletComponet, but I managed a similar route to yours using http4 Component like:
from("timer://").to("direct:http-endpoint");
to("direct:http-endpoint").to("restlet://...")
I believe this is what is described in Restlet Component docs

How to update camel properties externally?

Im developping non OSGI app and i need to update the values ​​of some properties used in camel routes (loaded BridgePropertyPlaceHolder).
So I thought:
To use Hawtio, the cool mangement console, in order update camel using JMX
Create a JMX MBean that will update the properties ..
I successfully create the MBean operations and call them using JMX, but I can't figure out how to update the camel routes that depends on these properties.
Is there a way to update the camel context externally?
Update:
Exemple of use case:when a remote server doesn't return response, we keep sending messages until we reach the max of unsuccessful attempt(messages without ack).
in camel we create a router pattern based on property loaded from file system.
This property can change occasionally, and we want to do this without restarting server, but the problem is that camel parse routes when starting context and i can't find no mean to update routes accordingly.
I am grateful for any proposal that could help:)
If you use Camel error handling to retry (redeliver) then you can use the retryWhile to keep retrying until you return false. This allows you to use java code etc, and that allows you to read the updated configuration option.
See more details at
http://camel.apache.org/exception-clause.html
And if you have a copy of Camel in Action book, see page 152
For what properties you want them to be dynamic.you can move those prop to some db and fetch them whenever you are reading.I think a redesign is required for your camel route.
Changing from endpoint parameters such as URLs etc., following procedure has to be used according to dynamic change endpoint camel:
stop the route
remove the route
change the endpoint
add the route
start the route
If the to endpoint has to be configurable, you may use the recipient list component. Here you may read properties from a database and/or from the filesystem using the appropriate Camel component.

java config for SpringBeanAutowiringInterceptor in an MDB

I am trying to expose an MDB interface for an existing jaxws service. The jaxws implementation is wired using Spring's java configuration and I would like to reuse that for the MDB as well, injecting a delegate into the MDB that will be called from onMessage().
I am trying to use the SpringBeanAutowiringInterceptor as per the documentation.
http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/ejb.html#ejb-implementation-ejb3
But the documentation referes only to the XML configuration. There is a mention of an option to override the getBeanFactory() but no details are given.
Is there a way to use Spring's java configuration (#Configuration) with the SpringBeanAutowiringInterceptor?
Thanks.
Ended up packaging the the MDB inside the WAR along with the web service as documented at http://pic.dhe.ibm.com/infocenter/wasinfo/v8r5/index.jsp?topic=/com.ibm.websphere.base.doc/ae/cejb_ejbinwar.html.

Camel Log Component

I'm looking for a logging solution that is based on SLF4J so I can bind to any underlying implementation I want at runtime (for right now I'm thinking log4j). Since I am planning to have my backend routed via Apache Camel, I figured Camel must have some solution for logging.
It does - here.
But from that page description I can't tell if camel-log is for pushing internal (Camel) messages (errors, exceptions, infos, etc.) to SLF4J, or for me to use as a SLF4J "wrapper", or both.
Hence my question: is camel-log for enabling Camel messaging (so I can see what Camel is doing under the hood) or is it a component that pushes my application's messages onto a route? Or both?!?
Thanks in advance!
Camel log component (http://camel.apache.org/log.html) is for logging exchanges. In latest versions of Camel it uses SFL4J so you could choose underlying logging implementation in usual SFL4J way.
You could enable 'trace' on Camel context to 'see what Camel is doing under the roof'.
For your own logging you could just use SLF4J inside your code as usual.

Categories