I wish to develop a generic java bean that will be included in all my camel routes (for personalized logging purposes). The route will call my java function in a processor and pass it the exchange object (and other stuff if needed).
How can I detect the type of the first endpoint that the route listens to ? it can be from ftp, http, jms etc ... and the relevant informations I would like to log are in different headers according to the endpoint protocol, for instance "CamelFileName" for ftp.
I have a workaround testing if the "CamelFilename" header exists then I know the endpoint listens to ftp server, or I could parse the endpointURI, but is there a more reliable/seeded function to get this?
You can get the from route on the Exchange, using the getFromEndpoint
and getFromRouteId
.
See the Exchange javadoc: http://static.javadoc.io/org.apache.camel/camel-core/2.18.2/org/apache/camel/Exchange.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.