connecting couchbase with camel - apache-camel

I am trying to connect to couchbase through with following customroute configuration in java
from("cxfrs://bean://rsServer")
.choice()
.when(header("operationName").isEqualTo("getCity"))
.setHeader(CouchbaseConstants.HEADER_ID,constant("#"))
.to("couchbase:http://"couchbase-ip"/Hotels?operation='GET'")
.end()
.marshal().json(JsonLibrary.Jackson);
I want to give path param for my rest service to be provided as document id for retrieval from couchbase. Problem is Output returned is Arraylist of whatever is my path param.

Related

Authentication with apache solr

Github Link
Missing username and password properties from the solr connector configuration to authenticate with the solr.
Is that possible to authenticate with solr via connector config?
How to pass username n password within the connector config?
Looks like solr.username and solr.password aren't actually used in the connector. The SolrClient is created with a default HttpSolrClient without any credentials in this source file in Github. But MatsLindh's point about embedding username and password in the URL is a good one and I'd have expected it to work.
There's a relevant thread here:
Solr6.3.0 SolrJ API for Basic Authentication
I haven't vetted the last answer in the thread, which doesn't really address the original topic in that post, but it is a concise example of creating a SolrClient with authentication. The SolrClient needs to wrap an underlying HttpClient that provides the basic auth, and the Kafka Solr sink connector isn't doing that.

Apache Camel - How to set a private key in a dynamic sftp endpoint

Using Java DSL, I have a route in which I poll a file in an SFTP server using the file name set in the message headers
from("direct:download")
.pollEnrich()
.simple("sftp://my.host:22/folder/?username=foo&fileName=${header.CamelFileName}")
.to("file://state/downloaded");
The sftp endpoint needs to have set a private key. Usually something like this suffices:
endpoint("sftp://my.host:22/folder/?username=foo&fileName=my_file_explicitly_written_here", SftpEndpoint.class).getConfiguration().setPrivateKey(getSshPrivateKey());
However, I see no way to "mix" dynamic fields in the URI (${header.CamelFileName}) in the pollEnrich().simple()) with endpoint configuration.
Any suggestion on this?
You can reference privateKey as bean from registry.
.pollEnrich()
.simple("sftp://my.host:22/folder/?username=foo&privateKey=#myKeyInRegistry&fileName=${header.CamelFileName}")
Binding bean to registry depends on platform and Camel version you are using.

Retrieve schema info from HttpSolrServer and CloudSolrServer with SolrJ

HttpSolrServer/CloudSolrServer support the /schema request handler but that isn't supported on the EmbeddedSolrServer and I would like a way to access the same information using SolrJ (and without HTTP requests).
When using EmbeddedSolrServer, the instance is created by passing a CoreContainer to the constructor. Later, the CoreContainer can be queried for all (well, just the one in the case of an embedded server) SolrCores with the getCores() method. From any given SolrCore I can obtain its schema using getSchema().
I now want to do the same thing but with an HttpSolrServer server and a CloudSolrServer. They, however, don't seem to have a way to ask for the list of loaded SolrCores or CoreContainers or anything. I know about the CoreAdmin but that only retrieves the status of each core, with no way to get Java instances of SolrCore.
Is it possible to obtain a list of SolrCores from a HttpSolrServer/CloudSolrServer using SolrJ, and how is it done?
Since Solr 5.3 SolrJ has API for Schema Access - see SchemaRequest.
For example, to retrieve collection schema one can use (in Solr 7) :
CloudSolrClient client = ...;
SchemaRequest request = new SchemaRequest();
SchemaResponse response = request.process(client, "collectionName");
SchemaRepresentation schema = response.getSchemaRepresentation();

How to inject query parameters using camel REST DSL?

Actually I am playing with apache-camel 2.15.2, the REST DSL available since Camel 2.14 is not complicated. However I can't find in the official documentation how to retrieve a query parameter, basically I would like to target my REST service in this way:
http://myServer/myService/myMethod?myQueryParam=myValue
Is that possible, or is there any workaround ?
Thanks in advance.
Camel uses the REST/HTTP component of choice (restlet, jetty, servlet, netty-http, spark-rest, etc) which maps query parameters as Camel message headers.
So yes you can with the rest-dsl exposes a REST service where clients can call it with query parameters, which is then mapped to Camel message headers during routing.

Using Apache Camel ProducerTemplate to send JSON message to ActiveMQ

I have a camel route setup like the following to send a java object to an activemq queue.
from("direct:clientRequest")
.marshal().json(JsonLibrary.Jackson)
.to("activemq:queue:command");
I want to do the following:
Map the "clientRequest" uri to some Java method
Use ProducerTemplate's "sendBody" method to send a JSON form of a Java object to the activemq queue.
Is this possible?
I am asking this question after a lot of homework. Please suggest a way to do this.
You can use pojo producing in Apache Camel. See this page for more details
http://camel.apache.org/pojo-producing.html
And there is an example that shows more about using pojo producing/consuming in Camel
http://camel.apache.org/pojo-messaging-example.html

Resources