Thanks for the inputs, I have made a sample, just putting it below of any
body else reference

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xmlns:camel="http://camel.apache.org/schema/blueprint";
       xsi:schemaLocation="
       http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
       http://camel.apache.org/schema/blueprint
http://camel.apache.org/schema/blueprint/camel-blueprint.xsd";>

  <bean id="helloBean" class="manchanda.lalit.TestTimer.HelloBean">
      <property name="say" value="Hi from Camel"/>
      <property name="producer" ref="producer" />
      <property name="consumer" ref="consumer" />
  </bean>
  
  <bean id="timerExcepton" class="java.lang.RuntimeException" >
   <argument value="timer has expired"/>
</bean>
 

  <camelContext trace="true" id="blueprintContext"
xmlns="http://camel.apache.org/schema/blueprint";>
    <template id="producer"/>
    <consumerTemplate id="consumer"/>
    
    <onException>
    
    
    <exception>java.lang.Exception</exception>
    
    <handled>
      <constant>true</constant>
    </handled>
    <log message="Error occured ${body}" />
    <to uri="mock:error" />
  </onException>
    
    <route id="jettyToLog">
        <from uri="jetty:http://0.0.0.0:9012/myservice>
        <bean ref="helloBean" method="startTimer"/>
        <bean ref="helloBean" method="fetchFromHttp"/>
        <log message="The message contains ${body}"/>
        <to uri="mock:result"/>
    </route>
    
    <route id="timerExpiryQueue">
    <from uri="direct:timer-queue" />
    <to uri="mock:timer"/>
    </route>
    
</camelContext>

</blueprint>




public class HelloBean  {

private ProducerTemplate producer;
        private ConsumerTemplate consumer;

 public void startTimer(Exchange exchange){
        Timer timer;
        SessionCallback callback = new SessionCallback(exchange);
        timer = new Timer();
        timer.schedule(callback, 500);
    }
    
    protected class SessionCallback extends TimerTask {
                
                Exchange exchange;
                SessionCallback(Exchange exchange) {
                        this.exchange = exchange;
                }
                public void run() {
                        
                
                                
                        cancel();
                                        
                        exchange.setException(new RuntimeException("Session 
Timer Expired,
feSessionId "));
                        producer.send("direct:timer-queue", exchange);
                
        } // SessionCallback
    }
    
}



--
View this message in context: 
http://camel.465427.n5.nabble.com/Working-with-Exchange-from-outside-route-tp5733480p5733535.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to