I don't write to solr, but I do query it (and writing should work equivalently).
My route for querying is just:
    <route id="SolrQuery">
      <from uri="direct:solrQuery" />
      <setHeader headerName="CamelHttpQuery">
        <simple>${body}</simple>
      </setHeader>
      <to uri="http://server:8983/solr/test/select/?disableStreamCache=true"; />
      <convertBodyTo type="java.lang.String" />
      <unmarshal ref="solrToMap"/>
    </route>

That route takes in the query string for solr as the body and then returns the 
data from solr as a map.

You might find it simpler to ignore java code for calling solr, and just talk 
http to it.

Jim

On Tue, Aug 09, 2011 at 09:01:18PM -0700, Tereza Nedelescu wrote:
> Hi,
> 
> I tried inserting data into Solr through Camel using two ways:
> 1 - from the *processor*, calling Java code that inserts data to Solr
> 2 - using the Solr component from this website:
> http://46.252.16.133/?q=espace/ispace/solrcomponent
> 
> In both cases, I ran into exceptions that prevented the program from
> inserting data into Solr. 
> *In Case 1* - simply by calling code executing
>                  solrServer = new
> CommonsHttpSolrServer("http://localhost:8983/solr";);
> it gave the following exception
> 
> SEVERE: Failed delivery for exchangeId: ID-myId. Exhausted after delivery
> attempt: 1 caught: org.apache.camel.CamelExecutionException: Exception
> occurred during execution on the exchange:
> Exchange[/home/tnedelescu/Logs_fresh/inDir/file.txt]
> org.apache.camel.CamelExecutionException: Exception occurred during
> execution on the exchange:
> Exchange[/home/tnedelescu/Logs_fresh/inDir/file.txt]
>       at
> org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1155)
>       at
> org.apache.camel.impl.DefaultExchange.setException(DefaultExchange.java:271)
>         .......................................
> Caused by: java.lang.IncompatibleClassChangeError: Implementing class
>       at java.lang.ClassLoader.defineClass1(Native Method)
>       at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
>       at 
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
>       at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
>         ...................
> 
> *In Case 2*, I got the following error:
> SEVERE: Failed delivery for exchangeId: ID-myId. Exhausted after delivery
> attempt: 1 caught: org.apache.camel.CamelExecutionException: Exception
> occurred during execution on the exchange: Exchange[null]
> org.apache.camel.CamelExecutionException: Exception occurred during
> execution on the exchange: Exchange[null]
>       at
> org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1155)
>       at
> org.apache.camel.impl.DefaultExchange.setException(DefaultExchange.java:271)
> 
> I tested that exchange.getOut().getBody() is not null when it exits
> "proces(exchange)".
> 
> If anybody inserted data to Solr, at the same time involving Camel, please,
> let me know how to do it. 
> 
> Thank you,
> Tereza
> 
> 
> 
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/How-can-I-insert-data-in-Solr-from-Camel-tp4684539p4684539.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to