You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by vipup <vA...@googlEMail.Com> on 2011/06/16 17:55:31 UTC

choose the 1st from two(many) Search-responses

I am total newbie in Camel, but hope here I am right ...
.. The Camel looks pretty powerfull for my needs, but i don't found any
sample, than make something similar. I want perform parallely two or more
request into some search engines and get back the only dirst request. Just
like the example below have to send back the the winner from 2 searches,
where win the first finished search:
like
Input: "Camel Apache"
Process:: 
  1) http://www.google.de/search?q=Camel+Apache
  2) http://www.bing.com/search?q=Camel+Apache
Output:::
  resp1!=null? {1} : {2}

Assumes the response have the similar format (xhtml for ex.) and need not to
be converted at all. Just for start the pure RAW will be ok.  In another
words the looser's answer will be ignored/broken. 

I just found the sample for Camel+Tomcat, but...
...really it is not so easy to make a fist step! Which EIP is it? Please
help! It should be really simple.


 

        
            
            
            
                
                    
                    search
                    
                     
                
                
                    
                    
                        Add a search to uri, eg ?search=camel
                    
                
            
        
    
 
 



--
View this message in context: http://camel.465427.n5.nabble.com/choose-the-1st-from-two-many-Search-responses-tp4495659p4495659.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: choose the 1st from two(many) Search-responses

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Take a look at, see the async client API section
http://camel.apache.org/async

Its also covered in chapter 10 in the Camel book in more details.



On Tue, Jun 21, 2011 at 3:14 PM, vipup <vA...@googlemail.com> wrote:
> Hi Claus,
> thank you for answer. As for me it should be _VERY_ easy to make it.
> Somethink like 2-lines but...
>
> ...i try to finish it already 3 (!) days. Samlples with Camel, Spring,
> Xml-Scheme, MQ, e.t.c even works sometimes. But any my modification gives me
> almost the same  - any_kind_of_errors :( I "LOVE" spring-dynamic-weaving. So
> many hops via so different levels of abstraction don't give me full
> imagination how it should work. Only runtime is able to detect what is
> really wrong.
>
> Could you please kill me with your draft DSL without Spring, if it is
> possible? It should be maximal 3 lines of code, am I right? Just
> Implementation this on pure java is not much complex...
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/choose-the-1st-from-two-many-Search-responses-tp4495659p4510536.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: choose the 1st from two(many) Search-responses

Posted by vipup <vA...@googlEMail.Com>.
Hi Claus,
thank you for answer. As for me it should be _VERY_ easy to make it.
Somethink like 2-lines but...

...i try to finish it already 3 (!) days. Samlples with Camel, Spring,
Xml-Scheme, MQ, e.t.c even works sometimes. But any my modification gives me
almost the same  - any_kind_of_errors :( I "LOVE" spring-dynamic-weaving. So
many hops via so different levels of abstraction don't give me full
imagination how it should work. Only runtime is able to detect what is
really wrong.

Could you please kill me with your draft DSL without Spring, if it is
possible? It should be maximal 3 lines of code, am I right? Just
Implementation this on pure java is not much complex...

--
View this message in context: http://camel.465427.n5.nabble.com/choose-the-1st-from-two-many-Search-responses-tp4495659p4510536.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: choose the 1st from two(many) Search-responses

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jun 16, 2011 at 6:53 PM, boday <be...@initekconsulting.com> wrote:
> I think you are looking for the  http://camel.apache.org/scatter-gather.html
> scatter-gather  pattern.  If you use the proper
> http://camel.apache.org/aggregator2.html aggregation strategy
> (completionSize=1, etc), this should work for you...
>
>

You can also just from a java bean send 2x async requests to an
endpoint and grab the first that completes.


> vipup wrote:
>>
>> <pre>
>> I am total newbie in Camel, but hope here I am right ...
>> .. The Camel looks pretty powerfull for my needs, but i don't found any
>> sample, than make something similar. I want perform parallely two or more
>> request into some search engines and get back the only dirst request. Just
>> like the example below have to send back the the winner from 2 searches,
>> where win the first finished search:
>> like
>> Input: "Camel Apache"
>> Process::
>>   1) http://www.google.de/search?q=Camel+Apache
>>   2) http://www.bing.com/search?q=Camel+Apache
>> Output:::
>>   resp1!=null? {1} : {2}
>>
>> Assumes the response have the similar format (xhtml for ex.) and need not
>> to be converted at all. Just for start the pure RAW will be ok.  In
>> another words the looser's answer will be ignored/broken.
>>
>> I just found the sample for Camel+Tomcat, but...
>> ...really it is not so easy to make a fist step! Which EIP is it? Please
>> help! It should be really simple.
>>
>>
>>
>> <camelContext xmlns="http://camel.apache.org/schema/spring">
>>         <route>
>>
>>             <from uri="servlet:///search"/>
>>             <choice>
>>                 <when>
>>
>>                     <header>search</header>
>>
>>
>>                 </when>
>>                 <otherwise>
>>
>>                     <transform>
>>                         <constant>Add a search to uri, eg
>> ?search=camel</constant>
>>                     </transform>
>>                 </otherwise>
>>             </choice>
>>         </route>
>>     </camelContext>
>>
>>
>> </pre>
>>
>
>
> -----
> Ben O'Day
> IT Consultant -http://consulting-notes.com
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/choose-the-1st-from-two-many-Search-responses-tp4495659p4495883.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: choose the 1st from two(many) Search-responses

Posted by boday <be...@initekconsulting.com>.
I think you are looking for the  http://camel.apache.org/scatter-gather.html
scatter-gather  pattern.  If you use the proper 
http://camel.apache.org/aggregator2.html aggregation strategy 
(completionSize=1, etc), this should work for you...


vipup wrote:
> 
> <pre>
> I am total newbie in Camel, but hope here I am right ...
> .. The Camel looks pretty powerfull for my needs, but i don't found any
> sample, than make something similar. I want perform parallely two or more
> request into some search engines and get back the only dirst request. Just
> like the example below have to send back the the winner from 2 searches,
> where win the first finished search:
> like
> Input: "Camel Apache"
> Process:: 
>   1) http://www.google.de/search?q=Camel+Apache
>   2) http://www.bing.com/search?q=Camel+Apache
> Output:::
>   resp1!=null? {1} : {2}
> 
> Assumes the response have the similar format (xhtml for ex.) and need not
> to be converted at all. Just for start the pure RAW will be ok.  In
> another words the looser's answer will be ignored/broken. 
> 
> I just found the sample for Camel+Tomcat, but...
> ...really it is not so easy to make a fist step! Which EIP is it? Please
> help! It should be really simple.
> 
> 
>  
> <camelContext xmlns="http://camel.apache.org/schema/spring">
>         <route>
>             
>             <from uri="servlet:///search"/>
>             <choice>
>                 <when>
>                     
>                     <header>search</header>
>                     
>                      
>                 </when>
>                 <otherwise>
>                     
>                     <transform>
>                         <constant>Add a search to uri, eg
> ?search=camel</constant>
>                     </transform>
>                 </otherwise>
>             </choice>
>         </route>
>     </camelContext>
>  
>  
> </pre>
> 


-----
Ben O'Day
IT Consultant -http://consulting-notes.com

--
View this message in context: http://camel.465427.n5.nabble.com/choose-the-1st-from-two-many-Search-responses-tp4495659p4495883.html
Sent from the Camel - Users mailing list archive at Nabble.com.