312.5. 예제
다음은 간단한 INSERT, DELETE 및 COMMIT 예입니다.
from("direct:insert") .setHeader(SolrConstants.OPERATION, constant(SolrConstants.OPERATION_INSERT)) .setHeader(SolrConstants.FIELD + "id", body()) .to("solr://localhost:8983/solr"); from("direct:delete") .setHeader(SolrConstants.OPERATION, constant(SolrConstants.OPERATION_DELETE_BY_ID)) .to("solr://localhost:8983/solr"); from("direct:commit") .setHeader(SolrConstants.OPERATION, constant(SolrConstants.OPERATION_COMMIT)) .to("solr://localhost:8983/solr");
<route> <from uri="direct:insert"/> <setHeader headerName="SolrOperation"> <constant>INSERT</constant> </setHeader> <setHeader headerName="SolrField.id"> <simple>${body}</simple> </setHeader> <to uri="solr://localhost:8983/solr"/> </route> <route> <from uri="direct:delete"/> <setHeader headerName="SolrOperation"> <constant>DELETE_BY_ID</constant> </setHeader> <to uri="solr://localhost:8983/solr"/> </route> <route> <from uri="direct:commit"/> <setHeader headerName="SolrOperation"> <constant>COMMIT</constant> </setHeader> <to uri="solr://localhost:8983/solr"/> </route>
클라이언트는 삽입 또는 삭제 경로에 본문 메시지를 전달하고 커밋 경로를 호출하기만 하면 됩니다.
template.sendBody("direct:insert", "1234"); template.sendBody("direct:commit", null); template.sendBody("direct:delete", "1234"); template.sendBody("direct:commit", null);