...
Code Block |
---|
title | AggregatorExample.java |
---|
|
...
from(...)
.aggregate()
.correlationExpression(header(id))
.aggregationStrategy(myStrategy)
.completionTimeout(10000)
.messageStore(myStore)
...
|
Claim check
THe claim check pattern temporarily reduces the data volume of the message by storing content in a message store in exchange for a claim check token. The content is retrieved later on before it's needed again.
Code Block |
---|
title | Setting default message store for route | | Claim Check EIP store |
---|
|
// Optionally: override default store from context
// (ohr:) IMHO I don't think that this configuration level is really necessary
defaultMessageStore(myStore);
|
Code Block |
---|
title | Claim Check EIP store |
---|
|
// 1) Store body.
// 2) Set body to null.
// 3) Set Exchange.CLAIM_CHECK header to unique claim id.
from(...)
.claimCheck() // store body in default store
// .claimCheck(header('bigHeader'), customStore) : store header in custom store
.to(...);
|
Code Block |
---|
title | Claim Check EIP read |
---|
|
// 1) Lookup for the Exchange.CLAIM_CHECK header value.
// 2) Read the message.
// 3) Set body to the value fetched from the store.
from(...)
// .setHeader(Exchange.CLAIM_CHECK, const("id")) : header should still contain the claim id
.claim() // read body from default store
// .transform(claim()) : more generically as expression
// .setHeader('bigHeader', claim(customStore)) : retrieve from custom store back into original header
.to(...);
|
Open issues:
- exception handling if there's no data available for a specific token
- clean up of stale content that was never claimed back
- maybe return some kind of DataHandler instead of a token (cf. CXF MTOM attachments) and retrieve content transparently?