Apache Camel - 10 - File组件(1)

Apache Camel File Component(文件组件)

官网File组件链接:

http://camel.apache.org/file2.html

 

Apache Camel相关代码已经上传GitHub,需要的自取:GitHub - Apache Camel 完整Demo

如果觉得还行,麻烦点个Star

 

The File component provides access to file systems, allowing files to be processed by any other Camel Components or messages from other components to be saved to disk.

File组件提供对文件系统的访问,允许任何其他Camel组件处理文件或将其他组件的消息保存到磁盘。

 

URI Format(URI格式)

file:directoryName[?options]     or     file://directoryName[?options]

Where directoryName represents the underlying file directory. You can append query options to the URI in the following format,?option=value&option=value&...

其中directoryName代表基础文件目录。您可以使用以下格式将查询选项附加到URI?option=value&option=value&...

支持绝对路径、相对路径:

file:E:/Eclipse Code Work Space/camel/temp

file:/temp

file:../temp

file:./temp

 

Only directories(只有目录)

Camel supports only endpoints configured with a starting directory. So the directoryName must be a directory. 

If you want to consume a single file only, you can use the fileName option e.g., by setting fileName=thefilename.

Also, the starting directory must not contain dynamic expressions with ${} placeholders. 

Again use the fileName option to specify the dynamic part of the filename.

Avoid reading files currently being written by another application

Camel只支持配置有起始目录的端点。 所以directoryName必须是一个目录。

如果只想使用单个文件,则可以使用fileName选项,例如通过设置fileName=thefilename。

此外,起始目录不得包含具有$ {}占位符的动态表达式。

再次使用fileName选项来指定文件名的动态部分。

避免读取当前正在被其他应用程序写入的文件

Beware the JDK File IO API is a bit limited in detecting whether another application is currently writing/copying a file.

And the implementation can be different depending on OS platform as well.

This could lead to that Camel thinks the file is not locked by another process and start consuming it.

Therefore you have to do you own investigation what suites your environment. To help with this Camel provides different readLock options and doneFileName option that you can use.

See also the section Consuming files from folders where others drop files directly.

请注意,JDK文件IO API在检测另一个应用程序当前正在写入/复制文件时有点受限。

而且实现可以根据OS平台而有所不同。

这可能导致Camel认为该文件没有被另一个进程锁定,并开始使用它。

所以你必须自己调查你的环境。 为了帮助这个Camel提供了可以使用的不同的readLock选项和doneFileName选项。

另请参阅从其他位置直接放置文件的文件夹中获取文件。

 

URI Options(URI选项)

Common(通用选项)

Name

Default Value

Description

autoCreate

自动创建

true

Automatically create missing directories in the file's path name. For the file consumer, that means creating the starting directory. For the file producer, it means the directory the files should be written to.

 

在文件的路径名中自动创建缺少的目录。 对于文件使用者来说,这意味着要创建起始目录。 对于文件生产者来说,这意味着文件应该被写入的目录。

 

(针对消费者而言,实际测试时发现,不加该参数,camel也会自动创建目录)

bufferSize

缓冲区大小

128kb

Write buffer sized in bytes.

写缓冲区大小以字节为单位

fileName

文件名

null

Use Expression such as File Language to dynamically set the filename. For consumers, it's used as a filename filter. For producers, it's used to evaluate the filename to write. If an expression is set, it take precedence over the CamelFileName header. (Note: The header itself can also be an Expression). The expression options support both String and Expression types. If the expression is a String type, it is always evaluated using the File Language. If the expression is an Expression type, the specified Expression type is used - this allows you, for instance, to use OGNL expressions.

 

使用“文件语言”等表达式来动态设置文件名。 对于消费者来说,它被用作文件名过滤器。 对于生产者来说,它用于评估要写入的文件名。 如果设置了表达式,则优先于CamelFileName标头。 (注:头本身也可以是一个表达式)。 表达式选项同时支持String和Expression类型。 如果表达式是字符串类型,则始终使用文件语言进行评估。 如果表达式是表达式类型,则使用指定的表达式类型 - 例如,您可以使用OGNL表达式。

 

For the consumer, you can use it to filter filenames, so you can for instance consume today's file using the File Language syntax: mydata-${date:now:yyyyMMdd}.txt. From Camel 2.11 onward the producers support the CamelOverruleFileName header which takes precedence over any existing CamelFileName header; the CamelOverruleFileName is a header that is used only once, and makes it easier as this avoids to temporary store CamelFileName and have to restore it afterwards.

 

对于消费者,您可以使用它来过滤文件名,因此您可以使用“文件语言”语法使用今天的文件:mydata - $ {date:now:yyyyMMdd}.txt。 从Camel 2.11开始,生产者支持CamelOverruleFileName头,它优先于任何现有的CamelFileName头; CamelOverruleFileName是一个只能使用一次的头文件,因此可以避免临时存储CamelFileName并且必须在之后恢复。

flatten

false

Flatten is used to flatten the file name path to strip any leading paths, so it's just the file name. This allows you to consume recursively into sub-directories, but when you eg write the files to another directory they will be written in a single directory. Setting this to true on the producer enforces that any file name received in CamelFileName header will be stripped for any leading paths.

 

拼合用于拼合文件名路径去除任何前导路径,所以它只是文件名。 这允许您递归地使用子目录,但是当您将文件写入另一个目录时,它们将被写入一个目录中。 在生产者上将其设置为true将强制执行:在CamelFileName头中接收到的任何文件名将被剥离用于任何前导路径。

charset

字符集

null

Camel 2.9.3: this option is used to specify the encoding of the file. You can use this on the consumer, to specify the encodings of the files, which allow Camel to know the charset it should load the file content in case the file content is being accessed. Likewise when writing a file, you can use this option to specify which charset to write the file as well. See further below for a examples and more important details.

 

Camel2.9.3:这个选项用来指定文件的编码。 你可以在消费者上使用它来指定文件的编码,这使得骆驼知道应该加载文件内容的字符集,以防文件内容被访问。 同样,当写入一个文件时,你可以使用这个选项来指定写入文件的字符集。 请参阅下面的示例和更重要的细节。

copyAndDeleteOnRenameFail

true

Camel 2.9: whether to fallback and do a copy and delete file, in case the file could not be renamed directly. This option is not available for the FTP component.

 

Camel2.9:是否备份和复制并删除文件,以防文件无法直接重命名。 该选项不适用于FTP组件。

renameUsingCopy

false

Camel 2.13.1: Perform rename operations using a copy and delete strategy. This is primarily used in environments where the regular rename operation is unreliable e.g., across different file systems or networks. This option takes precedence over the copyAndDeleteOnRenameFail parameter that will automatically fall back to the copy and delete strategy, but only after additional delays.

 

Camel 2.13.1:使用复制和删除策略执行重命名操作。 这主要用于常规重命名操作不可靠的环境,例如跨越不同的文件系统或网络。 此选项优先于copyAndDeleteOnRenameFail参数,该参数将自动回退到复制和删除策略,但仅在其他延迟之后。

Consumer(消费者)

 

Name

Default Value

Description

initialDelay

初始延迟

1000

Milliseconds before polling the file/directory starts.

轮询文件/目录之前的毫秒数开始。

delay

延迟

500

Milliseconds before the next poll of the file/directory.

下一轮轮询文件/目录之前的毫秒数。

useFixedDelay

使用固定延迟

 

Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details.

In Camel 2.7.x or older the default value is false.

From Camel 2.8 onward the default value is true.

 

控制是否使用固定延迟或固定费率。 有关详细信息,请参阅JDK中的ScheduledExecutorService。

在Camel 2.7.x或更旧版本中,默认值为false。

从Camel2.8开始,默认值为true。

runLoggingLevel

运行日志级别

TRACE

Camel 2.8: The consumer logs a start/complete log line when it polls. This option allows you to configure the logging level for that.

Camel2.8:消费者轮询时记录一个开始/完整的日志行。 该选项允许您为此配置日志记录级别。

recursive

递归

false

If a directory, will look for files in all the sub-directories as well.

如果一个目录,也会在所有子目录中查找文件。

delete

false

如果为true,则文件在成功处理后将被删除。

noop

空操作

false

If true, the file is not moved or deleted in any way. This option is good for readonly data, or for ETL type requirements. If noop=true, Camel will set idempotent=true as well, to avoid consuming the same files over and over again.

如果为true,则不会以任何方式移动或删除文件。 此选项适用于只读数据或ETL类型要求。 如果noop = true,Camel也会设置idempotent = true,以避免重复使用同一个文件。

preMove

null

Expression (such as File Language) used to dynamically set the filename when moving it before processing. For example to move in-progress files into the order directory set this value to order.

表达式(如文件语言)用于在处理之前移动文件名时动态设置文件名。 例如,要将正在进行的文件移动到订单目录中,请将此值设置为订购。

move

.camel

Expression (such as File Language) used to dynamically set the filename when moving it after processing. To move files into a .done subdirectory just enter .done.

表达式(如文件语言)用于在处理后移动文件名时动态设置文件名。 要将文件移动到.done子目录,只需输入.done。

moveFailed

移动失败

null

Expression (such as File Language) used to dynamically set a different target directory when moving files in case of processing (configured via move defined above) failed.

For example, to move files into a .error subdirectory use: .error.

Note: When moving the files to the “fail” location Camel will handle the error and will not pick up the file again.

 

在处理的情况下移动文件(通过以上定义的移动配置)时,用于动态设置不同目标目录的表达(如文件语言)失败。

例如,要将文件移动到.error子目录中,请使用:.error。

注意:将文件移动到“失败”位置时Camel将处理该错误,并不会再次拾取文件。

include

null

Is used to include files, if filename matches the regex pattern (matching is case in-sensitive from Camel 2.17 onward).

用于包含文件,如果文件名匹配正则表达式模式(匹配是从Camel2.17以后的情况下不敏感)。

exclude

排除

null

Is used to exclude files, if filename matches the regex pattern (matching is case in-sensitive from Camel 2.17 onward).

用于排除文件,如果文件名匹配正则表达式模式(匹配是大小写不敏感从Camel2.17以上)。

antInclude

null

Camel 2.10: Ant style filter inclusion, for example antInclude=*/.txt. Multiple inclusions may be specified in comma-delimited format. See below for more details about ant path filters.

Camel2.10:包含Ant风格的过滤器,例如antInclude = * / .txt。 可以用逗号分隔的格式指定多个包含。 请参阅下面的Ant路径过滤器的更多细节。

antExclude

null

Camel 2.10: Ant style filter exclusion. If both antInclude and antExclude are used, antExclude takes precedence over antInclude. Multiple exclusions may be specified in comma-delimited format. See below for more details about ant path filters.

Camel2.10:ant风格过滤器排除。 如果使用antInclude和antExclude,则antExclude优先于antInclude。 多个排除可能以逗号分隔的格式指定。 请参阅下面的ant路径过滤器的更多细节。

antFilterCaseSensitive

蚂蚁过滤器大小写敏感

true

Camel 2.11: Ant style filter which is case sensitive or not.

Camel2.11:ant风格的过滤器是否区分大小写。

Producer(生产者)

 

Name

Default Value

Description

fileExist

文件存在

Override

What to do if a file already exists with the same name. The following values can be specified:

如果文件已经存在,并且名称相同,该怎么办。 可以指定下列值:

 

Override replaces the existing file.

覆盖取代现有的文件。

 

Append adds content to the existing file.

追加将内容添加到现有的文件。

 

Fail throws a GenericFileOperationException indicating that there is already an existing file.

失败抛出一个GenericFileOperationException,表示已经有一个现有的文件。

 

Ignore silently ignores the problem and does not override the existing file, but assumes everything is okay.

忽略默认忽略的问题,并不覆盖现有的文件,但假设一切都没问题。

 

Move (Camel 2.10.1 onward) requires that the option moveExisting be configured as well. The eagerDeleteTargetFile can be used to control what to do if moving the file, and there already exists a file, otherwise causing the move operation to fail. The Move option will move any existing files, before writing the target file.

移动(Camel2.10.1向前)要求也配置moveExisting选项。 eagerDeleteTargetFile可用于控制如何移动文件,并且已经存在文件,否则会导致移动操作失败。 在写入目标文件之前,移动选项将移动任何现有的文件。

 

 

TryRename (Camel 2.11.1 onward) is only applicable if tempFileName option is in use. This allows to try renaming the file from the temporary name to the actual name, without doing any exists check. This check may be faster on some file systems and especially FTP servers.

TryRename(Camel2.11.1以上)只适用于tempFileName选项正在使用。 这允许尝试将文件从临时名称重命名为实际名称,而不进行任何存在检查。 在某些文件系统,特别是FTP服务器上,这种检查可能会更快。

 

tempPrefix

临时前缀

null

This option is used to write the file using a temporary name and then, after the write is complete, rename it to the real name. Can be used to identify files being written to and also avoid consumers (not using exclusive read locks) reading in progress files. Is often used by FTP when uploading big files.

 

此选项用于使用临时名称写入文件,然后在写入完成后将其重命名为实名。 可以用来识别正在写入的文件,也可以避免消费者(不使用独占读锁)读取正在进行的文件。 上传大文件时经常使用FTP。

tempFileName

临时文件名

null

Camel 2.1: The same as tempPrefix option but offering a more fine grained control on the naming of the temporary filename as it uses the File Language.

 

Camel 2.1:与tempPrefix选项相同,但是在使用文件语言时,对临时文件名的命名提供更精细的控制。

moveExisting

null

Camel 2.10.1: Expression (such as File Language) used to compute file name to use when fileExist=Move is configured. To move files into a backup subdirectory just enter backup.

Camel2.10.1:表达式(如文件语言)用于计算fileExist = Move时使用的文件名称。 要将文件移入备份子目录,只需输入备份。

 

This option only supports the following File Language tokens:

该选项仅支持以下文件语言令牌:

 

file:name

file:name.ext

file:name.noext

file:onlyname

file:onlyname.noext

file:ext

file:parent

 

Note: the file:parent token is not supported by the FTP component which can only move files to a directory relative to the current directory.

注意:只能将文件移动到相对于当前目录的目录的FTP组件不支持file:parent标记。

keepLastModified

false

Camel 2.2: Will keep the last modified timestamp from the source file (if any). Will use the Exchange.FILE_LAST_MODIFIED header to located the timestamp. This header can contain either a java.util.Date or long with the timestamp. If the timestamp exists and the option is enabled it will set this timestamp on the written file.

Camel2.2:将保留源文件的最后修改时间戳(如果有的话)。 将使用Exchange.FILE_LAST_MODIFIED标头来定位时间戳。 这个头文件可以包含一个java.util.Date或者带有时间戳的long。 如果时间戳存在并且选项已启用,则会在写入的文件上设置此时间戳。

 

Note: This option only applies to the file producer. It cannot be used with any of the FTP producers.

注意:该选项仅适用于文件制作者。 它不能与任何FTP生产者一起使用。

eagerDeleteTargetFile

true

Camel 2.3: Whether or not to eagerly delete any existing target file. This option only applies when you use fileExists=Override and the tempFileName option as well. You can use this to disable (set it to false) deleting the target file before the temp file is written. For example you may write big files and want the target file to exist while the temp file is being written. This ensures that the target file is only deleted at the very last moment, just before the temp file is being renamed to the target filename.

 

From Camel 2.10.1 onward this option is also used to control whether to delete any existing files when fileExist=Move is enabled, and an existing file exists. If this option copyAndDeleteOnRenameFail is false, then an exception will be thrown if an existing file existed. When true the existing file is deleted before the move operation.

 

Camel2.3:是否急切地删除任何现有的目标文件。 此选项仅适用于使用fileExists = Override和tempFileName选项。 您可以使用它来禁用(将其设置为false)在写入临时文件之前删除目标文件。 例如,您可能会写入大文件,并希望在写入临时文件时存在目标文件。 这确保了目标文件只在临时文件被重命名为目标文件名之前的最后时刻才被删除。

 

从Camel 2.10.1开始,此选项也用于控制在启用fileExist = Move时是否删除任何现有文件,并存在现有文件。 如果此选项copyAndDeleteOnRenameFail为false,则在存在现有文件时将抛出异常。 如果为true,则在移动操作之前删除现有文件。

doneFileName

完成文件名称

null

Camel 2.6: If provided, then Camel will write a second file (called done file) when the original file has been written. The done file will be empty. This option configures what file name to use. You can either specify a fixed name, or you can use dynamic placeholders. The done file will always be written in the same folder as the original file. See writing done file section for examples.

 

Camel2.6:如果提供,那么当原始文件被写入时,Camel将编写第二个文件(称为完成文件)。 完成的文件将是空的。 该选项配置要使用的文件名。 您可以指定一个固定的名称,也可以使用动态占位符。 完成的文件将始终写入与原始文件相同的文件夹中。 请参阅编写完成的文件部分的示例。

allowNullBody

false

Camel 2.10.1: Used to specify if a null body is allowed during file writing. If set to true then an empty file will be created, when set to false, and attempting to send a null body to the file component, a GenericFileWriteException the a message 'Cannot write null body to file' will be thrown.

 

If fileExist=Override the file will be truncated. If fileExist=append the file will remain unchanged.

 

Camel2.10.1:用于指定文件写入时是否允许空体。 如果设置为true,那么将会创建一个空文件,当设置为false时,并尝试向文件组件发送一个空体时,GenericFileWriteException将抛出一条消息'Can not write null body to file'。

 

如果fileExist = Override,文件将被截断。 如果fileExist =追加文件将保持不变。

forceWrites

true

Camel 2.10.5/2.11: Whether to force syncing writes to the file system. You can turn this off if you do not want this level of guarantee, for example if writing to logs / audit logs etc; this would yield better performance.

 

Camel2.10.5 / 2.11:是否强制同步写入文件系统。 如果你不想要这个级别的保证,例如写入日志/审计日志等,你可以关掉它。 这会产生更好的性能。

chmod

null

Camel 2.15.0: Specify the file permissions which is sent by the producer, the chmod value must be between 000 and 777; If there is a leading digit like in 0755 we will ignore it.

 

Camel2.15.0:指定生产者发送的文件权限,chmod值必须在000到777之间; 如果有像0755这样的前导数字,我们将忽略它。

chmodDirectory

null

Camel 2.17.0: Specify the directory permissions used when the producer creates missing directories, the chmod value must be between 000 and 777; If there is a leading digit like in 0755 we will ignore it.

 

Camel2.17.0:指定生产者创建缺少目录时使用的目录权限,chmod值必须在000到777之间; 如果有像0755这样的前导数字,我们将忽略它。

Default behavior for file producer(文件生产者的默认行为)

By default it will override any existing file, if one exist with the same name.

默认情况下,它将覆盖任何现有的文件,如果存在相同的名称。

Move and Delete operations(移动和删除操作)

Any move or delete operations is executed after (post command) the routing has completed; so during processing of the Exchange the file is still located in the inbox folder.

任何移动或删除操作在路由完成后(后命令)执行; 所以在处理Exchange时,文件仍位于收件箱文件夹中。

Lets illustrate this with an example:

让我们举个例子来说明一下:

java from("file://inbox?move=.done") .to("bean:handleOrder");

When a file is dropped in the inbox folder, the file consumer notices this and creates a new FileExchange that is routed to the handleOrder bean. The bean then processes the File object. At this point in time the file is still located in the inbox folder. After the bean completes, and thus the route is completed, the file consumer will perform the move operation and move the file to the .done sub-folder.

将文件放入收件箱文件夹时,文件使用者注意到这一点,并创建一个路由到handleOrder bean的新FileExchange。 然后bean处理File对象。 此时该文件仍位于收件箱文件夹中。 在bean完成后,路由完成后,文件使用者将执行移动操作并将文件移动到.done子文件夹。

The move and the preMove options are considered as a directory name though if you use an expression such as File Language, or Simple then the result of the expression evaluation is the file name to be used e.g., if you set

move和preMove选项被认为是一个目录名,尽管如果你使用表达式如File Language或者Simple,那么表达式求值的结果就是要使用的文件名,例如,如果你设置了

move=../backup/copy-of-${file:name}

then that's using the File Language which we use return the file name to be used), which can be either relative or absolute. If relative, the directory is created as a sub-folder from within the folder where the file was consumed.

那么就是使用我们使用的文件语言返回文件名来使用),它可以是相对的也可以是绝对的。 如果是相对的,该目录将作为文件所在文件夹内的子文件夹创建。

By default, Camel will move consumed files to the .camel sub-folder relative to the directory where the file was consumed.

默认情况下,Camel会将使用的文件移动到相对于文件所在目录的.camel子文件夹中。

If you want to delete the file after processing, the route should be:

如果要在处理后删除文件,路线应该是:

java from("file://inobox?delete=true") .to("bean:handleOrder");

We have introduced a pre move operation to move files before they are processed. This allows you to mark which files have been scanned as they are moved to this sub folder before being processed.

我们已经介绍了一个预处理操作,在处理文件之前移动文件。 这允许您标记哪些文件在被处理之前被移动到这个子文件夹已被扫描。

java from("file://inbox?preMove=inprogress") .to("bean:handleOrder");

You can combine the pre move and the regular move:

你可以结合前移和常规移动:

java from("file://inbox?preMove=inprogress&move=.done") .to("bean:handleOrder");

So in this situation, the file is in the inprogress folder when being processed and after it's processed, it's moved to the .done folder.

所以在这种情况下,文件在进行处理时处于进行中的文件夹中,处理完之后,文件被移动到.done文件夹中。

Fine Grained Control Using The move and preMove Options

使用move和preMove选项进行细粒度控制

The move and preMove options are Expression-based, so we have the full power of the File Language to do advanced configuration of the directory and name pattern.

Camel will, in fact, internally convert the directory name you enter into a File Language expression. So when we enter move=.done Camel will convert this into: ${file:parent}/.done/${file:onlyname}. This is only done if Camel detects that you have not provided a ${} in the option value yourself. So when you enter a ${} Camel will not convert it and thus you have the full power.

move和preMove选项是基于表达式的,所以我们具有文件语言的全部功能来进行目录和名称模式的高级配置。

事实上,Camel内部将你输入的目录名转换成文件语言表达式。 所以当我们输入move = .done时,Camel会将其转换为

${file:parent}/.done/${file:onlyname}. 

这只有在Camel检测到自己没有在选项值中提供$ {}时才会执行。 所以,当你输入一个$ {}Camel不会转换它,因此你有全部的权力

So if we want to move the file into a backup folder with today's date as the pattern, we can do:

所以如果我们想把文件移动到当前日期的备份文件夹中,我们可以这样做:

move=backup/${date:now:yyyyMMdd}/${file:name}

 

About moveFailed(关于移动失败)

The moveFailed option allows you to move files that could not be processed successfully to another location such as a error folder of your choice. For example to move the files in an error folder with a timestamp you can use moveFailed=/error/${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.${file:ext}.

moveFailed选项允许您将不能成功处理的文件移动到另一个位置,例如您选择的错误文件夹。 例如,要使用时间戳移动错误文件夹中的文件,可以使

moveFailed=/error/${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.${file:ext}.

 

Using Expressions for Filenames(使用表达式的文件名)

In this sample we want to move consumed files to a backup folder using today's date as a sub-folder name:

在本示例中,我们要将使用当前日期的使用文件移动到备份文件夹作为子文件夹名称

java from("file://inbox?move=backup/${date:now:yyyyMMdd}/${file:name}") .to("...");

Avoiding reading the same file more than once (idempotent consumer)

避免多次阅读同一个文件(幂等消费者)(谷歌翻译是幂等,感觉应该是多线程吧...)

Camel supports Idempotent Consumer directly within the component so it will skip already processed files. This feature can be enabled by setting the idempotent=true option.

Camel直接在组件内支持Idempotent Consumer,所以它会跳过已处理的文件。 该功能可以通过设置idempotent = true选项来启用

java from("file://inbox?idempotent=true") .to("...");

Camel uses the absolute file name as the idempotent key, to detect duplicate files. From Camel 2.11 onward you can customize this key by using an expression in the idempotentKey option. For example to use both the name and the file size as the key

Camel使用绝对文件名作为幂等键,检测重复文件。 从Camel2.11开始,您可以使用idempotentKey选项中的表达式来自定义此键。 例如使用名称和文件大小作为关键字

xml 
<route>
	<from uri="file://inbox?idempotent=true&amp;idempotentKey=${file:name}-${file:size}"/> 
	<to uri="bean:processInbox"/>
</route>

By default Camel uses a in memory based store for keeping track of consumed files, it uses a least recently used cache holding up to 1000 entries. You can plugin your own implementation of this store by using the idempotentRepository option using the # sign in the value to indicate it's a referring to a bean in the Registry with the specified id.

默认情况下,Camel使用基于内存的存储来跟踪消耗的文件,它使用最近最少使用的高速缓存,最多可容纳1000个条目。 您可以通过使用idempotentRepository选项使用值中的#号来插入您自己的此存储实现,以指示它是否使用指定的ID引用注册表中的bean。

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Apache Camel和JBang是两个不同的工具,但可以配合使用。Apache Camel是一个源的集成框架,用于构建面向企业的集成应用程序,而JBang是一个基于Java的脚本引擎。 如果你想在使用Apache Camel时结合JBang进行脚本编写和执行,可以按照以下步骤操作: 1. 首先,确保你已经安装了Java和Apache Camel。你可以从官方网站下载和安装最新版本的Apache Camel。 2. 接下来,你需要安装JBang。JBang可以通过其官方网站或GitHub仓库进行下载和安装。 3. 安装完成后,你可以创建一个新的JBang脚本文件,用于编写和执行Apache Camel的集成路由。你可以使用任何文本编辑器打开该文件,并在其中编写你的Camel路由逻辑。 4. 在脚本文件的开头,添加`#!/usr/bin/env jbang`这一行,以告诉系统使用JBang来执行该脚本。 5. 在脚本文件中,导入所需的Apache Camel类和其他必要的依赖项。你可以使用JBang的内置依赖管理功能来自动下载和管理这些依赖项。 6. 编写你的Apache Camel路由逻辑。你可以使用Camel的Java DSL或XML DSL来定义和配置路由。在脚本中,你可以使用Java代码来编写这些路由逻辑。 7. 最后,保存脚本文件,并在命令行中执行它。你可以使用`jbang <脚本文件名>`命令来运行该脚本。 通过这种方式,你可以使用JBang来编写和执行Apache Camel的集成路由,从而实现各种企业集成场景的需求。注意,这只是一种使用JBang和Apache Camel的方法,你还可以根据自己的需求进行灵活调整和扩展。希望对你有所帮助!如果你有更多问题,可以继续提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值