Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.此内容没有您所选择的语言版本。
8.4. Claim Check
Claim Check 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
The claim check pattern, shown in Figure 8.4, “Claim Check Pattern”, allows you to replace message content with a claim check (a unique key), which can be used to retrieve the message content at a later time. The message content is stored temporarily in a persistent store like a database or file system. This pattern is very useful when message content is very large (thus it would be expensive to send around) and not all components require all information.
It can also be useful in situations where you cannot trust the information with an outside party; in this case, you can use the Claim Check to hide the sensitive portions of data.
Figure 8.4. Claim Check Pattern
Java DSL example 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
The following example shows how to replace a message body with a claim check and restore the body at a later step.
from("direct:start").to("bean:checkLuggage", "mock:testCheckpoint", "bean:dataEnricher", "mock:result");
from("direct:start").to("bean:checkLuggage", "mock:testCheckpoint", "bean:dataEnricher", "mock:result");
The next step in the pipeline is the
mock:testCheckpoint
endpoint, which checks that the message body has been removed, the claim check added, and so on.
XML DSL example 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
The preceding example can also be written in XML, as follows:
checkLuggage bean 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
The message is first sent to the
checkLuggage
bean which is implemented as follows:
This bean stores the message body into the data store, using the
custId
as the claim check. In this example, we are using a HashMap
to store the message body; in a real application you would use a database or the file system. The claim check is added as a message header for later use and, finally, we remove the body from the message and pass it down the pipeline.
testCheckpoint endpoint 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
The example route is just a Pipeline. In a real application, you would substitute some other steps for the
mock:testCheckpoint
endpoint.
dataEnricher bean 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
To add the message body back into the message, we use the
dataEnricher
bean, which is implemented as follows:
This bean queries the data store, using the claim check as the key, and then adds the recovered data back into the message body. The bean then deletes the message data from the data store and removes the
claimCheck
header from the message.