Which Enterprise Integration pattern is used in camel

I am facing an issue in finding out which pattern processed the message lastly. Like whether the intercept happened after an aggregate,split or process.After which pattern my intercept processor worked. Is there any way to find out this?

You can get some details from CamelMessageHistory exchange property which is a list of DefaultMessageHistory objects. These contain routeId and some details about the endpoint node like its id. If you're using interceptFrom camel stores the intercepted endpoint uri to CamelInterceptedEndpoint header.

Intercept and print history

intercept()
    .process(new Processor(){

        @Override
        public void process(Exchange exchange) throws Exception {
        
            String output = "History:\n";
            List historyList = (List)exchange.getProperty(Exchange.MESSAGE_HISTORY);
            
            for (int i = 0; i < historyList.size(); i++) {
                
                DefaultMessageHistory messageHistory = (DefaultMessageHistory)historyList.get(i);

                output += "\t[" + (i + 1) + "]" 
                    + messageHistory.getRouteId() +":" 
                    + messageHistory.getNode().getShortName()
                    + "\n";
            }
            System.out.println(output);
        }
    });

This however wont help you much as the information is fairly limited and many patterns like split that create a new exchange with their own new history. However for these you could look if headers like CamelSplitIndex have been set and if it has then determine from that that split has occurred.

if there is any other way to full fill my need to store the details of routing in DB

You could keep things simple and track the state of the exchange using events instead. Just write a processor or component that you can use to write/store what happened and when during the routing. You can use breadcrumbId as unique id for exchange as this persists even after something like split.

The processor or custom component could then simply stream these events to some file or store them to a local database like sqlite for further processing. Avoid sending them straight to external database or service to minimize impact on actual routes.

This kind of diagram is what I need to create from the routes. Thanks in Advance.

Have you looked in to Hawtio? It does a lot of this already. I am running Hawtio with Apache Karaf and it provides me with Route diagrams and fairly detailed profiling data for routes, endpoints and whatnot. Its also open source so you can modify it or use it as reference for your own application.

If you prefer to do something similar yourself you can look in to using JMX to manage and monitor camel application. For my understanding Hawtio uses it under the hood to get more information about applications running inside JVM.