Hi all, I have written a route to do the following: - expose a restful service - invoke a http server - catch errors; put the associated messages on an error queue - catch connection exceptions and unknown business errors; put the associated request messages on a retry queue - every 24 hours, poll the retry queue; invoke the http server again increment a retry counter and when a retry limit is reached... move the associated messages on the error queue
Can someone please review my route (below), and tell me if I have missed any useful solutions, or if this is the optimal approach? Also, is there any handy way to implement an exponential backoff in my http client? Thanks, Paul <camelContext xmlns="http://camel.apache.org/schema/spring" id="SPGClient"> <endpoint id="frontend" uri="restlet:http://localhost:8080/myclient/{param}"/> <endpoint id="httpServer" uri="http://localhost:8080/myserver"/> <endpoint id="workQueue" uri="direct:INTERNAL_QUEUE"/> <endpoint id="errorQueue" uri="activemq:ERROR_QUEUE?exchangePattern=InOnly"/> <endpoint id="retryQueue" uri="activemq:RETRY_QUEUE?exchangePattern=InOnly"/> <endpoint id="retryTimer" uri="quartz://myTimer/0/0/12/*/*/$"/> <route id="frontendRoute"> <from ref="frontend"/> <!-- inject param into message body --> <process ref="paramProcessor"/> <!-- prepare to invoke http server --> <setHeader headerName="CamelHttpMethod"> <constant>POST</constant> </setHeader> <setHeader headerName="Content-Type"> <constant>text/xml</constant> </setHeader> <removeHeader headerName="CamelHttpUri"/> <to ref="workQueue"/> </route> <route id="backendRoute"> <from ref="workQueue"/> <doTry> <!-- invoke the http server --> <to ref="httpServer"/> <doCatch> <!-- if the server is not running --> <exception>java.net.ConnectException</exception> <!-- put the message on the retry queue --> <to ref="retryQueue"/> </doCatch> </doTry> <!-- process the http server's response --> <choice> <when> <xpath>in:header('result') = 'SUCCESS'</xpath> <setHeader headerName="Exchange.HTTP_RESPONSE_CODE"> <constant>200</constant> </setHeader> </when> <when> <xpath>in:header('result') = 'ERROR'</xpath> <to ref="errorQueue"/> </when> <otherwise> <to ref="retryQueue"/> </otherwise> </choice> </route> <route id="retryRoute"> <!-- every day at noon --> <from ref="retryTimer"/> <!-- read from the retry queue --> <pollEnrich ref="retryQueue"/> <!-- check a retry counter --> <choice> <when> <xpath>in:header('retries') > 3</xpath> <to ref="errorQueue"/> <stop/> </when> <otherwise> <!-- invoke "backendRoute" again --> <setExchangePattern pattern="InOnly"/> <to ref="workQueue"/> </otherwise> </choice> <!-- increment the retry counter --> <process ref="incrementRetryCounterProcessor"/> </route> </camelContext> STRICTLY PRIVATE, CONFIDENTIAL AND PRIVILEGED COMMUNICATION. This message (including attachments) may contain information that is privileged, confidential or protected from disclosure. They are intended solely for the use of the intended recipient. If you are not the intended recipient, you are hereby notified that dissemination, disclosure, copying, distribution, printing, transmission or use of this message or any information contained in it is strictly prohibited. If you have received this message from NewBay Software in error, please immediately notify the sender by reply email and delete this message from your computer. The content of this e-mail, and any files transmitted with it, may have been changed or altered without the consent of the author. Although we have taken steps to ensure that this email and attachments are free from any virus, we advise that in keeping with good computing practice the recipient should ensure they are actually virus free.