You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bo...@apache.org on 2012/01/18 02:26:08 UTC
svn commit: r1232710 - in /camel/trunk/components:
camel-amqp/src/test/java/org/apache/camel/component/amqp/
camel-cxf/src/test/java/org/apache/camel/component/cxf/
camel-solr/src/main/java/org/apache/camel/component/solr/
camel-solr/src/test/java/org/...
Author: boday
Date: Wed Jan 18 01:26:08 2012
New Revision: 1232710
URL: http://svn.apache.org/viewvc?rev=1232710&view=rev
Log:
CAMEL-4880, CAMEL-4881 added SolrInputDocument and streaming support
Modified:
camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java
camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrComponent.java
camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrConstants.java
camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrEndpoint.java
camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrProducer.java
camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/InitSolrEndpointTest.java
camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java
camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrUpdateTest.java
camel/trunk/components/camel-solr/src/test/resources/SolrSpringTest-context.xml
camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java
Modified: camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java?rev=1232710&r1=1232709&r2=1232710&view=diff
==============================================================================
--- camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java (original)
+++ camel/trunk/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java Wed Jan 18 01:26:08 2012
@@ -33,7 +33,7 @@ import static org.apache.camel.component
/**
* @version
*/
-@Ignore("AMQP testing is a bit unstable")
+//@Ignore("AMQP testing is a bit unstable")
public class AMQPRouteTest extends CamelTestSupport {
protected MockEndpoint resultEndpoint;
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java?rev=1232710&r1=1232709&r2=1232710&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java Wed Jan 18 01:26:08 2012
@@ -58,7 +58,7 @@ public class CxfEndpointTest extends Ass
endpoint.getServiceClass().getCanonicalName(),
"org.apache.camel.component.cxf.HelloService");
}
-
+
@Test
public void testSettingClientBus() throws Exception {
CXFBusImpl bus = (CXFBusImpl) BusFactory.newInstance().createBus();
Modified: camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrComponent.java?rev=1232710&r1=1232709&r2=1232710&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrComponent.java (original)
+++ camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrComponent.java Wed Jan 18 01:26:08 2012
@@ -26,7 +26,7 @@ import org.apache.camel.impl.DefaultComp
public class SolrComponent extends DefaultComponent {
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
- Endpoint endpoint = new SolrEndpoint(uri, this, remaining);
+ Endpoint endpoint = new SolrEndpoint(uri, this, remaining, parameters);
setProperties(endpoint, parameters);
return endpoint;
}
Modified: camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrConstants.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrConstants.java?rev=1232710&r1=1232709&r2=1232710&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrConstants.java (original)
+++ camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrConstants.java Wed Jan 18 01:26:08 2012
@@ -25,10 +25,16 @@ public final class SolrConstants {
public static final String OPERATION_ROLLBACK = "ROLLBACK";
public static final String OPERATION_OPTIMIZE = "OPTIMIZE";
public static final String OPERATION_INSERT = "INSERT";
+ public static final String OPERATION_INSERT_STREAMING = "INSERT_STREAMING";
public static final String OPERATION_ADD_BEAN = "ADD_BEAN";
public static final String OPERATION_DELETE_BY_ID = "DELETE_BY_ID";
public static final String OPERATION_DELETE_BY_QUERY = "DELETE_BY_QUERY";
+ public static final String PARAM_STREAMING_QUEUE_SIZE = "streamingQueueSize";
+ public static final String PARAM_STREAMING_THREAD_COUNT = "streamingThreadCount";
+ public static final int DEFUALT_STREAMING_QUEUE_SIZE = 10;
+ public static final int DEFAULT_STREAMING_THREAD_COUNT = 2;
+
private SolrConstants() {
throw new AssertionError();
}
Modified: camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrEndpoint.java?rev=1232710&r1=1232709&r2=1232710&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrEndpoint.java (original)
+++ camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrEndpoint.java Wed Jan 18 01:26:08 2012
@@ -16,11 +16,13 @@
*/
package org.apache.camel.component.solr;
+import java.util.Map;
import org.apache.camel.Consumer;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
import org.apache.camel.impl.DefaultEndpoint;
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
+import org.apache.solr.client.solrj.impl.StreamingUpdateSolrServer;
/**
* Represents a Solr endpoint.
@@ -28,22 +30,25 @@ import org.apache.solr.client.solrj.impl
public class SolrEndpoint extends DefaultEndpoint {
private CommonsHttpSolrServer solrServer;
+ private CommonsHttpSolrServer streamingSolrServer;
private String requestHandler;
+ private int streamingThreadCount;
+ private int streamingQueueSize;
- public SolrEndpoint() {
- }
-
- public SolrEndpoint(String uri, SolrComponent component) {
- super(uri, component);
- }
+ public SolrEndpoint(String endpointUri, SolrComponent component, String address, Map<String, Object> parameters) throws Exception {
+ super(endpointUri, component);
- public SolrEndpoint(String endpointUri) {
- super(endpointUri);
+ solrServer = new CommonsHttpSolrServer("http://" + address);
+ streamingQueueSize = getIntFromString((String) parameters.get(SolrConstants.PARAM_STREAMING_QUEUE_SIZE), SolrConstants.DEFUALT_STREAMING_QUEUE_SIZE);
+ streamingThreadCount = getIntFromString((String) parameters.get(SolrConstants.PARAM_STREAMING_THREAD_COUNT), SolrConstants.DEFAULT_STREAMING_THREAD_COUNT);
+ streamingSolrServer = new StreamingUpdateSolrServer("http://" + address, streamingQueueSize, streamingThreadCount);
}
- public SolrEndpoint(String endpointUri, SolrComponent component, String address) throws Exception {
- super(endpointUri, component);
- solrServer = new CommonsHttpSolrServer("http://" + address);
+ public static int getIntFromString(String value, int defaultValue) {
+ if (value != null && value.length() > 0) {
+ return Integer.parseInt(value);
+ }
+ return defaultValue;
}
@Override
@@ -65,32 +70,47 @@ public class SolrEndpoint extends Defaul
return solrServer;
}
+ public CommonsHttpSolrServer getStreamingSolrServer() {
+ return streamingSolrServer;
+ }
+
+ public void setStreamingSolrServer(CommonsHttpSolrServer streamingSolrServer) {
+ this.streamingSolrServer = streamingSolrServer;
+ }
+
public void setMaxRetries(int maxRetries) {
solrServer.setMaxRetries(maxRetries);
+ streamingSolrServer.setMaxRetries(maxRetries);
}
public void setSoTimeout(int soTimeout) {
solrServer.setSoTimeout(soTimeout);
+ streamingSolrServer.setSoTimeout(soTimeout);
}
public void setConnectionTimeout(int connectionTimeout) {
solrServer.setConnectionTimeout(connectionTimeout);
+ streamingSolrServer.setConnectionTimeout(connectionTimeout);
}
public void setDefaultMaxConnectionsPerHost(int defaultMaxConnectionsPerHost) {
solrServer.setDefaultMaxConnectionsPerHost(defaultMaxConnectionsPerHost);
+ streamingSolrServer.setDefaultMaxConnectionsPerHost(defaultMaxConnectionsPerHost);
}
public void setMaxTotalConnections(int maxTotalConnections) {
solrServer.setMaxTotalConnections(maxTotalConnections);
+ streamingSolrServer.setMaxTotalConnections(maxTotalConnections);
}
public void setFollowRedirects(boolean followRedirects) {
solrServer.setFollowRedirects(followRedirects);
+ streamingSolrServer.setFollowRedirects(followRedirects);
}
public void setAllowCompression(boolean allowCompression) {
solrServer.setAllowCompression(allowCompression);
+ streamingSolrServer.setAllowCompression(allowCompression);
}
public void setRequestHandler(String requestHandler) {
@@ -100,4 +120,20 @@ public class SolrEndpoint extends Defaul
public String getRequestHandler() {
return requestHandler;
}
+
+ public int getStreamingThreadCount() {
+ return streamingThreadCount;
+ }
+
+ public void setStreamingThreadCount(int streamingThreadCount) {
+ this.streamingThreadCount = streamingThreadCount;
+ }
+
+ public int getStreamingQueueSize() {
+ return streamingQueueSize;
+ }
+
+ public void setStreamingQueueSize(int streamingQueueSize) {
+ this.streamingQueueSize = streamingQueueSize;
+ }
}
Modified: camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrProducer.java?rev=1232710&r1=1232709&r2=1232710&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrProducer.java (original)
+++ camel/trunk/components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrProducer.java Wed Jan 18 01:26:08 2012
@@ -17,12 +17,19 @@
package org.apache.camel.component.solr;
import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import org.apache.camel.Exchange;
import org.apache.camel.impl.DefaultProducer;
+import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.common.SolrDocument;
+import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,10 +40,12 @@ import org.slf4j.LoggerFactory;
public class SolrProducer extends DefaultProducer {
private static final transient Logger LOG = LoggerFactory.getLogger(SolrProducer.class);
private SolrServer solrServer;
+ private SolrServer streamingSolrServer;
public SolrProducer(SolrEndpoint endpoint) {
super(endpoint);
solrServer = endpoint.getSolrServer();
+ streamingSolrServer = endpoint.getStreamingSolrServer();
}
@Override
@@ -49,7 +58,9 @@ public class SolrProducer extends Defaul
}
if (operation.equalsIgnoreCase(SolrConstants.OPERATION_INSERT)) {
- insert(exchange);
+ insert(exchange, false);
+ } else if (operation.equalsIgnoreCase(SolrConstants.OPERATION_INSERT_STREAMING)) {
+ insert(exchange, true);
} else if (operation.equalsIgnoreCase(SolrConstants.OPERATION_DELETE_BY_ID)) {
solrServer.deleteById(exchange.getIn().getBody(String.class));
} else if (operation.equalsIgnoreCase(SolrConstants.OPERATION_DELETE_BY_QUERY)) {
@@ -67,7 +78,7 @@ public class SolrProducer extends Defaul
}
}
- private void insert(Exchange exchange) throws Exception {
+ private void insert(Exchange exchange, boolean isStreaming) throws Exception {
Object body = exchange.getIn().getBody();
@@ -82,19 +93,34 @@ public class SolrProducer extends Defaul
}
}
- updateRequest.process(solrServer);
+ if (isStreaming) {
+ updateRequest.process(streamingSolrServer);
+ } else {
+ updateRequest.process(solrServer);
+ }
+
} else {
- SolrInputDocument doc = new SolrInputDocument();
- for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) {
- if (entry.getKey().startsWith(SolrConstants.FIELD)) {
- String fieldName = entry.getKey().substring(SolrConstants.FIELD.length());
- doc.setField(fieldName, entry.getValue());
+
+ UpdateRequest updateRequest = new UpdateRequest(getRequestHandler());
+
+ if (body instanceof SolrInputDocument) {
+ updateRequest.add((SolrInputDocument) body);
+ } else {
+ SolrInputDocument doc = new SolrInputDocument();
+ for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) {
+ if (entry.getKey().startsWith(SolrConstants.FIELD)) {
+ String fieldName = entry.getKey().substring(SolrConstants.FIELD.length());
+ doc.setField(fieldName, entry.getValue());
+ }
}
+ updateRequest.add(doc);
}
- UpdateRequest updateRequest = new UpdateRequest(getRequestHandler());
- updateRequest.add(doc);
- updateRequest.process(solrServer);
+ if (isStreaming) {
+ updateRequest.process(streamingSolrServer);
+ } else {
+ updateRequest.process(solrServer);
+ }
}
}
Modified: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/InitSolrEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/InitSolrEndpointTest.java?rev=1232710&r1=1232709&r2=1232710&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/InitSolrEndpointTest.java (original)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/InitSolrEndpointTest.java Wed Jan 18 01:26:08 2012
@@ -27,16 +27,27 @@ public class InitSolrEndpointTest extend
@Test
public void endpointCreatedCorrectlyWithAllOptions() throws Exception {
SolrEndpoint solrEndpoint = context.getEndpoint(solrUrl + getFullOptions(), SolrEndpoint.class);
+ assertEquals("queue size incorrect", 5, solrEndpoint.getStreamingQueueSize());
+ assertEquals("thread count incorrect", 1, solrEndpoint.getStreamingThreadCount());
assertNotNull(solrEndpoint);
}
+ @Test
+ public void streamingEndpointCreatedCorrectly() throws Exception {
+ SolrEndpoint solrEndpoint = context.getEndpoint(solrUrl, SolrEndpoint.class);
+ assertNotNull(solrEndpoint);
+ assertEquals("queue size incorrect", SolrConstants.DEFUALT_STREAMING_QUEUE_SIZE, solrEndpoint.getStreamingQueueSize());
+ assertEquals("thread count incorrect", SolrConstants.DEFAULT_STREAMING_THREAD_COUNT, solrEndpoint.getStreamingThreadCount());
+ }
+
@Test(expected = ResolveEndpointFailedException.class)
public void wrongURLFormatFailsEndpointCreation() throws Exception {
context.getEndpoint("solr://localhost:-99/solr");
}
private String getFullOptions() {
- return "?maxRetries=1&soTimeout=100&connectionTimeout=100"
+ return "?streamingQueueSize=5&streamingThreadCount=1"
+ + "&maxRetries=1&soTimeout=100&connectionTimeout=100"
+ "&defaultMaxConnectionsPerHost=100&maxTotalConnections=100"
+ "&followRedirects=false&allowCompression=true"
+ "&requestHandler=/update";
Modified: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java?rev=1232710&r1=1232709&r2=1232710&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java (original)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java Wed Jan 18 01:26:08 2012
@@ -48,9 +48,15 @@ public class SolrSpringTest extends Abst
@Produce(uri = "direct:xml-start")
protected ProducerTemplate xmlRoute;
+ @Produce(uri = "direct:xml-start-streaming")
+ protected ProducerTemplate xmlRouteStreaming;
+
@Produce(uri = "direct:pdf-start")
protected ProducerTemplate pdfRoute;
+ @Produce(uri = "direct:pdf-start-streaming")
+ protected ProducerTemplate pdfRouteStreaming;
+
@DirtiesContext
@Test
public void endToEndIndexXMLDocuments() throws Exception {
@@ -70,6 +76,26 @@ public class SolrSpringTest extends Abst
assertEquals(Arrays.asList("Web", "Technology", "Computers"), doc.getFieldValue("cat"));
}
+
+ @DirtiesContext
+ @Test
+ public void endToEndIndexXMLDocumentsStreaming() throws Exception {
+ xmlRouteStreaming.sendBody(new File("src/test/resources/data/books.xml"));
+
+ // Check things were indexed.
+ QueryResponse response = executeSolrQuery("*:*");
+
+ assertEquals(0, response.getStatus());
+ assertEquals(4, response.getResults().getNumFound());
+
+ // Check fields were indexed correctly.
+ response = executeSolrQuery("title:Learning XML");
+
+ SolrDocument doc = response.getResults().get(0);
+ assertEquals("Learning XML", doc.getFieldValue("id"));
+ assertEquals(Arrays.asList("Web", "Technology", "Computers"), doc.getFieldValue("cat"));
+ }
+
@DirtiesContext
@Test
public void endToEndIndexPDFDocument() throws Exception {
@@ -86,6 +112,22 @@ public class SolrSpringTest extends Abst
assertEquals(Arrays.asList("application/pdf"), doc.getFieldValue("content_type"));
}
+ @DirtiesContext
+ @Test
+ public void endToEndIndexPDFDocumentStreaming() throws Exception {
+ pdfRouteStreaming.sendBody(new File("src/test/resources/data/tutorial.pdf"));
+
+ QueryResponse response = executeSolrQuery("*:*");
+
+ assertEquals(0, response.getStatus());
+ assertEquals(1, response.getResults().getNumFound());
+
+ SolrDocument doc = response.getResults().get(0);
+ assertEquals("Solr", doc.getFieldValue("subject"));
+ assertEquals("tutorial.pdf", doc.getFieldValue("id"));
+ assertEquals(Arrays.asList("application/pdf"), doc.getFieldValue("content_type"));
+ }
+
@BeforeClass
public static void beforeClass() throws Exception {
// Set appropriate paths for Solr to use.
Modified: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrUpdateTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrUpdateTest.java?rev=1232710&r1=1232709&r2=1232710&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrUpdateTest.java (original)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrUpdateTest.java Wed Jan 18 01:26:08 2012
@@ -23,6 +23,7 @@ import org.apache.camel.Exchange;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrInputDocument;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -39,6 +40,37 @@ public class SolrUpdateTest extends Solr
}
@Test
+ public void testInsertSolrInputDocument() throws Exception {
+
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", "MA147LL/A", 1.0f);
+ template.sendBodyAndHeader("direct:start", doc, SolrConstants.OPERATION, SolrConstants.OPERATION_INSERT);
+
+ solrCommit();
+
+ QueryResponse response = executeSolrQuery("id:MA147LL/A");
+ assertEquals(0, response.getStatus());
+ assertEquals(1, response.getResults().getNumFound());
+ }
+
+ @Test
+ public void testInsertStreaming() throws Exception {
+
+ Exchange exchange = createExchangeWithBody(null);
+ exchange.getIn().setHeader(SolrConstants.OPERATION, SolrConstants.OPERATION_INSERT_STREAMING);
+ exchange.getIn().setHeader("SolrField.id", "MA147LL/A");
+ template.send("direct:start", exchange);
+
+ Thread.sleep(500);
+
+ solrCommit();
+
+ QueryResponse response = executeSolrQuery("id:MA147LL/A");
+ assertEquals(0, response.getStatus());
+ assertEquals(1, response.getResults().getNumFound());
+ }
+
+ @Test
public void indexSingleDocumentOnlyWithId() throws Exception {
Exchange exchange = createExchangeWithBody(null);
exchange.getIn().setHeader(SolrConstants.OPERATION, SolrConstants.OPERATION_INSERT);
Modified: camel/trunk/components/camel-solr/src/test/resources/SolrSpringTest-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/resources/SolrSpringTest-context.xml?rev=1232710&r1=1232709&r2=1232710&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/test/resources/SolrSpringTest-context.xml (original)
+++ camel/trunk/components/camel-solr/src/test/resources/SolrSpringTest-context.xml Wed Jan 18 01:26:08 2012
@@ -35,6 +35,35 @@
<to uri="solr://localhost:{{SolrServer.Port}}/solr"/>
</route>
+ <route id="XMLRoute-Streaming">
+ <from uri="direct:xml-start-streaming" />
+ <split>
+ <xpath>/bookstore/book</xpath>
+ <convertBodyTo type="java.lang.String"/>
+ <setHeader headerName="SolrOperation">
+ <constant>INSERT_STREAMING</constant>
+ </setHeader>
+ <setHeader headerName="SolrField.id">
+ <xpath resultType="java.lang.String">//title/text()</xpath>
+ </setHeader>
+ <setHeader headerName="SolrField.title">
+ <xpath resultType="java.lang.String">//title/text()</xpath>
+ </setHeader>
+ <setHeader headerName="SolrField.cat">
+ <groovy>
+ def book = new XmlParser().parseText(request.body)
+ book.cat.collect{ it.text() } as String[]
+ </groovy>
+ </setHeader>
+ <to uri="solr://localhost:{{SolrServer.Port}}/solr"/>
+ </split>
+ <delay><constant>500</constant></delay>
+ <setHeader headerName="SolrOperation">
+ <constant>COMMIT</constant>
+ </setHeader>
+ <to uri="solr://localhost:{{SolrServer.Port}}/solr"/>
+ </route>
+
<route id="PDFRoute">
<from uri="direct:pdf-start" />
<setHeader headerName="SolrOperation">
@@ -49,6 +78,23 @@
</setHeader>
<to uri="solr://localhost:{{SolrServer.Port}}/solr"/>
</route>
+
+ <route id="PDFRoute-Streaming">
+ <from uri="direct:pdf-start-streaming" />
+ <setHeader headerName="SolrOperation">
+ <constant>INSERT_STREAMING</constant>
+ </setHeader>
+ <setHeader headerName="SolrParam.literal.id">
+ <simple>${body.name}</simple>
+ </setHeader>
+ <to uri="solr://localhost:{{SolrServer.Port}}/solr?requestHandler=/update/extract" />
+ <delay><constant>500</constant></delay>
+ <setHeader headerName="SolrOperation">
+ <constant>COMMIT</constant>
+ </setHeader>
+ <to uri="solr://localhost:{{SolrServer.Port}}/solr"/>
+ </route>
+
</camelContext>
</beans>
Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java?rev=1232710&r1=1232709&r2=1232710&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java (original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java Wed Jan 18 01:26:08 2012
@@ -157,6 +157,17 @@ public class CamelBeanPostProcessor impl
* @return true to process it
*/
protected boolean canPostProcessBean(Object bean, String beanName) {
+
+ //Let us check if we can load this class...
+ ClassLoader classLoader = getCamelContext().getClassResolver().getClass().getClassLoader();
+
+ try {
+ Class aClass = classLoader.loadClass("org.apache.camel.core.xml.CamelJMXAgentDefinition");
+ //Keep going.
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+
// the JMXAgent is a bit strange and causes Spring issues if we let it being
// post processed by this one. It does not need it anyway so we are good to go.
// We should also avoid to process the null object bean (in Spring 2.5.x)