How to set Correlation ID in spring DSL - apache-camel

How to set the correlation id in Spring DSL? The below code doesn't reflect correlation ID in Active MQ
<setHeader headerName="correlationId">
<constant>IFS123</constant>
</setHeader>
tried with
<setHeader headerName="JMSCorrelationId">
<constant>IFS456</constant>
</setHeader>

The name is the standard JMS name which is JMSCorrelationID notice the upper case ID. You can find the name in the JMS spec: https://docs.oracle.com/javaee/7/api/javax/jms/Message.html

Related

Solr Result Ranking modifications to a particlar query

I am newbie to Solr and I am trying to build a simple search solution for my website. I am trying to build a feature which is similar to Swifttype's result ranking feature.
i.e., Lets say "ice" results in
Ice
Iceberg
Ice cream
......
so on....
If i want to rank "Ice cream" higher only for query "ice", but when i search for other search terms like "Iceland" default ranking should be maintained. how can i achieve that?
I am using solr v7.5
Thanks in advance...
The Query Elevation Component lets you configure the top results for a given query regardless of the normal Lucene scoring.
More importantly, you will need to configure elevate.xml file which looks like this:
<elevate>
<query text="ice">
<doc id="1" /> //where id=1 is your ice cream document
<doc id="2" />
<doc id="3" />
</query>
</elevate>
Later, during searches you only need to enable it by specifying http param enableElevation=true

how to index all metatags in nutch

I have installed Nutch 1.9 and configured it to successfully crawl with Solr 4.10.1. I am trying to set Nutch to index metadata as outlined here https://wiki.apache.org/nutch/IndexMetatags
How do I set it to index ALL of the metadata on a site? I set the value for metatags.names to * like this
<property>
<name>metatags.names</name>
<value>*</value>
<description>Names of the metatags to extract, separated by ','. Use '*' to extract all metatags. Prefixes the names with 'metatag.' in the parse-metadata. For instance to index description and keywords, you need to activate the plugin index-metadata and set the
value of the parameter 'index.parse.md' to 'metatag.description,metatag.keywords'.
</description>
</property>
but I am unsure of how to set the value for index.parse.md without listing individual metatag names. I tried this
<property>
<name>index.parse.md</name>
<value>meta*</value>
<description>Comma-separated list of keys to be taken from the parse metadata to generate fields. Can be used e.g. for 'description' or 'keywords' provided that these values are generated by a parser (see parse-metatags plugin)
</description>
</property>
but that doesn't display any metadata when running
bin/nutch indexchecker http://nutch.apache.org/
and I am sure there is metadata on that site because it returns Parse Metadata when running
bin/nutch parsechecker http://nutch.apache.org/
Any help would be greatly appreciated! Thanks
Plugin index-metadata doesn't work that way. You have to specify complete name there, e.g. "metatag.keywords".
Also "metatags.names" value "" is not really wildcard. You can't put something like "meta" there as well.

Apache Camel Enricher

Hi so I am learning Apache Camel and trying to create a very simple service that combines two XML files based on an ID and move the resulting file to a new location. There are multiple files in a direcotry so I need to filter it based on an ID.
Client XML:
<?xml version="1.0" encoding="UTF-8"?>
<client>
<id>2</id>
<firstName>Clark</firstName>
<lastName>Kent</lastName>
<netWorth>470</netWorth>
</client>
and Address XML:
<?xml version="1.0" encoding="UTF-8"?>
<address>
<id>3</id>
<clients>
<clientId>2</clientId>
</clients>
<city>New York</city>
</address>
So I would like to add the city element from the Address XML to the Client XML.
<?xml version="1.0" encoding="UTF-8"?>
<client>
<id>2</id>
<firstName>Clark</firstName>
<lastName>Kent</lastName>
<netWorth>470</netWorth>
<city>New York</city>
</client>
I've been reading about aggregators and enrichers, from what I understand an aggregator would combine all XML files in the directory(not really what I want) and an enricher would add a resource from another service but how do I filter out based on the id and add it to the XML structure and not just at the end.
Thanks, sorry this is probably really basic I just don't know it.
I dont know , if you have resolved the issue yet , however , the answer to you question is -
Aggregator has the method in Camel , where you can implement your logic , what to do with the old exchange and new exchange. In this case , you can get the ids of 2 exchanges and match it . Once matched , you can take the unmarshalled node(city) and add it to the parent xml .

Update query after the selected records from a Select Query

I have to select some rows from table, send the result to a queue and then the same records as 'Sent' in the DB.
This how I am trying to do this but not sure how to pass a column value to the where clause of the update query for the each record of the select query.
<route>
<from uri="timer://kickoff?period=10000"/>
<setBody>
<constant>select top 10 * from tableName</constant>
</setBody>
<to uri="jdbc:test"/>
<multicast>
<to uri="activemq:queue:TESTQUEUE"/>
<setBody>
<constant>update tableName set status='Sent' where primaryKey= ${primaryKey}</constant>
</setBody>
<to uri="jdbc:test"/>
</multicast>
</route>
Will this route will run for all 10 records?
If it is not possible with JDBC/SQL component then how to achieve it with Hibernate component?
When you run a query using Camel JDBC, you will get back an ArrayList of HashMaps. See the camel documentation here:
http://camel.apache.org/jdbc.html
"The result is returned in the OUT body as an ArrayList>. The List object contains the list of rows and the Map objects contain each row with the String key as the column name."
You will need to setup a spring bean to process this body. You can extract your primary key from the arraylist in the spring bean and set a header. From there you can use the splitter to process all the rows:
http://camel.apache.org/splitter.html

Why does Entity sometimes need a "url" parameter and sometimes not?

I am trying to setup a DataImportHandler and upon trying to do a full import I get this error:
SEVERE: Full Import failed:java.lang.RuntimeException: java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: SolrEntityProcessor: parameter 'url' is required Processing Document # 1
I see in the example data-config.xml that come with solr sometimes Entity has the url parameter and sometimes it doesn't. If it is required why do some of the examples not have it?
What URL is it looking for?
The documentation actually doesn't show "url" as a required parameter for SqlEntityProcessor
For SqlEntityProcessor the entity attributes are :
query (required) : The sql string using which to query the db
deltaQuery : Only used in delta-import
parentDeltaQuery : Only used in delta-import
deletedPkQuery : Only used in delta-import
deltaImportQuery : (Only used in delta-import) . If this is not present , DIH tries to construct the import query by(after identifying the delta) modifying the 'query' (this is error prone). There is a namespace ${dataimporter.delta.} which can be used in this query. e.g: select * from tbl where id=${dataimporter.delta.id} Solr1.4.
It depends on the specific EntityProcessor implementation you use. Every EntityProcessor has its own entity attributes. SQLEntityProcessor doesn't need an url parameter because it relies on the dataSource element to get the information needed to connect to the database, while for example the SolrEntityProcessor doesn't need the dataSource element but relies on the url attribute to get the url of the Solr instance from which import data.
There are different DataSource implementations as well, if you look at JdbcDataSource you'll see it requires the url parameter itself.

Resources