...
Krati
...
Component
...
Available
...
as
...
of
...
Camel
...
2.9
...
This
...
component
...
allows
...
the
...
use
...
krati
...
datastores
...
and
...
datasets
...
inside
...
Camel.
...
Krati
...
is
...
a
...
simple
...
persistent
...
data
...
store
...
with
...
very
...
low
...
latency
...
and
...
high
...
throughput.
...
It
...
is
...
designed
...
for
...
easy
...
integration
...
with
...
read-write-intensive
...
applications
...
with
...
little
...
effort
...
in
...
tuning
...
configuration,
...
performance
...
and
...
JVM
...
garbage
...
collection.
...
Camel
...
provides
...
a
...
producer
...
and
...
consumer
...
for
...
krati
...
datastore_(key/value
...
engine)_.
...
It
...
also
...
provides
...
an
...
idempotent
...
repository
...
for
...
filtering
...
out
...
duplicate
...
messages.
...
Maven
...
users
...
will
...
need
...
to
...
add
...
the
...
following
...
dependency
...
to
...
their
...
pom.xml
...
for
...
this
...
component:
Code Block | ||||
---|---|---|---|---|
| ||||
{code:xml} <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-krati</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency> {code} h3. URI format {code} |
URI format
Code Block |
---|
krati:[the path of the datastore][?options]
{code}
The *path of the datastore* is the relative path of the folder that krati will use for its datastore.
You can append query options to the URI in the following format, {{ |
The path of the datastore is the relative path of the folder that krati will use for its datastore.
You can append query options to the URI in the following format, ?option=value&option=value&...
Krati URI Options
Div | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||
|
You can have as many of these options as you like.
Code Block |
---|
MurmurHashFunctiom | {div} You can have as many of these options as you like. {code} krati:/tmp/krati?operation=CamelKratiGet&initialCapacity=10000&keySerializer=#myCustomSerializer {code} |
For
...
producer
...
endpoint
...
you
...
can
...
override
...
all
...
of
...
the
...
above
...
URI
...
options
...
by
...
passing
...
the
...
appropriate
...
headers
...
to
...
the
...
message.
...
Message
...
Headers
...
for
...
datastore
Div | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
|
Usage Samples
Example 1: Putting to the datastore.
This example will show you how you can store any message inside a datastore.
Code Block |
---|
=confluenceTableSmall} || Header || Description || | {{CamelKratiOperation}} | The operation to be performed on the datastore. The valid options are - CamelKratiAdd - CamelKratiGet - CamelKratiDelete - CamelKratiDeleteAll | | {{CamelKratiKey}} | The key. | | {{CamelKratiValue}} | The value. | {div} h3. Usage Samples h4. Example 1: Putting to the datastore. This example will show you how you can store any message inside a datastore. {code} from("direct:put").to("krati:target/test/producertest"); {code} |
In
...
the
...
above
...
example
...
you
...
can
...
override
...
any
...
of
...
the
...
URI
...
parameters
...
with
...
headers
...
on
...
the
...
message.
...
Here
...
is
...
how
...
the
...
above
...
example
...
would
...
look
...
like
...
using
...
xml
...
to
...
define
...
our
...
route.
Code Block | ||||
---|---|---|---|---|
| ||||
{code:xml} <route> <from uri="direct:put"/> <to uri="krati:target/test/producerspringtest"/> </route> {code} h4. Example |
Example 2:
...
Getting/Reading
...
from
...
a
...
datastore
...
This
...
example
...
will
...
show
...
you
...
how
...
you
...
can
...
read
...
the
...
contnet
...
of
...
a
...
datastore.
Code Block |
---|
} from("direct:get") .setHeader(KratiConstants.KRATI_OPERATION, constant(KratiConstants.KRATI_OPERATION_GET)) .to("krati:target/test/producertest"); {code} |
In
...
the
...
above
...
example
...
you
...
can
...
override
...
any
...
of
...
the
...
URI
...
parameters
...
with
...
headers
...
on
...
the
...
message.
...
Here
...
is
...
how
...
the
...
above
...
example
...
would
...
look
...
like
...
using
...
xml
...
to
...
define
...
our
...
route.
Code Block | ||||
---|---|---|---|---|
| ||||
{code:xml} <route> <from uri="direct:get"/> <to uri="krati:target/test/producerspringtest?operation=CamelKratiGet"/> </route> {code} h4. Example |
Example 3:
...
Consuming
...
from
...
a
...
datastore
...
This
...
example
...
will
...
consume
...
all
...
items
...
that
...
are
...
under
...
the
...
specified
...
datastore.
Code Block |
---|
} from("krati:target/test/consumertest") .to("direct:next"); {code} |
You
...
can
...
achieve
...
the
...
same
...
goal
...
by
...
using
...
xml,
...
as
...
you
...
can
...
see
...
below.
Code Block | ||||
---|---|---|---|---|
| ||||
{code:xml} <route> <from uri="krati:target/test/consumerspringtest"/> <to uri="mock:results"/> </route> {code} h3. Idempotent Repository As already mentioned this |
Idempotent Repository
As already mentioned this component also offers and idemptonet repository which can be used for filtering out duplicate messages.
Code Block |
---|
component also offers and idemptonet repository which can be used for filtering out duplicate messages. {code} from("direct://in").idempotentConsumer(header("messageId"), new KratiIdempotentRepositroy("/tmp/idempotent").to("log://out"); {code} h4. See also [Krati Websitre|http://sna-projects.com/krati/] |