Minio
| Deprecated: This minio is deprecated and may be removed in a future release. |
Since Camel 3.5
Both producer and consumer are supported
The Minio component supports storing and retrieving objects from/to Minio service.
Prerequisites
You must have valid credentials for authorized access to the buckets/folders. More information is available at Minio.
URI Format
minio://bucketName[?options]
The bucket will be created if it doesn’t already exist.
You can append query options to the URI in the following format: ?options=value&option2=value&…
For example, to read file hello.txt from the bucket helloBucket, use the following snippet:
-
Java
-
XML
-
YAML
from("minio://helloBucket?accessKey=yourAccessKey&secretKey=yourSecretKey&objectName=hello.txt")
.to("file:/var/downloaded"); <route>
<from uri="minio://helloBucket?accessKey=yourAccessKey&secretKey=yourSecretKey&objectName=hello.txt"/>
<to uri="file:/var/downloaded"/>
</route> - route:
from:
uri: minio://helloBucket
parameters:
accessKey: yourAccessKey
secretKey: yourSecretKey
objectName: hello.txt
steps:
- to:
uri: file:/var/downloaded Configuring Options
Camel components are configured on two separate levels:
-
component level
-
endpoint level
Configuring Component Options
At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.
For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.
Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.
You can configure components using:
-
the Component DSL.
-
in a configuration file (
application.properties,*.yamlfiles, etc). -
directly in the Java code.
Configuring Endpoint Options
You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.
Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.
A good practice when configuring options is to use Property Placeholders.
Property placeholders provide a few benefits:
-
They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.
-
They allow externalizing the configuration from the code.
-
They help the code to become more flexible and reusable.
The following two sections list all the options, firstly for the component followed by the endpoint.
Component Options
The Minio component supports the following options which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
Whether to create the bucket at startup if it does not exist (skipped when objectName is set), and, for a consumer with moveAfterRead, the destinationBucketName bucket. If false, a missing destination bucket fails the start of the consumer. | true | boolean | |
The configuration that the endpoints of this component start from. The options set on an endpoint replace its values. | MinioConfiguration | ||
The MinIO server, or other Amazon S3 compatible service, to connect to: a URL such as http://localhost:9000, or a host name or IP address, for which the client uses HTTPS on port 443. Required unless minioClient is set. | String | ||
Autowired To use a custom io.minio.MinioClient. When this option is set or autowired, the endpoint, proxyPort, secure, region, accessKey, secretKey and customHttpClient options are not used. | MinioClient | ||
Whether to enable object locking on the buckets that the component creates (see autoCreateBucket). It does not change an existing bucket. | false | boolean | |
The bucket policy, as JSON, that the endpoint sets on the bucket at startup. Not applied when objectName is set. | String | ||
The TCP port of the server. When set, it replaces the port of the endpoint option. An endpoint with the http:// or https:// scheme keeps its scheme; for a host name without a scheme, the secure option sets it. Not used when minioClient is set. | Integer | ||
The region of the server, for example us-east-1. The client signs its requests for this region, and the component creates buckets in it. If not set, the client asks the server for the region of the bucket. | String | ||
Whether the client uses HTTPS (true) or HTTP (false) when proxyPort is set and the endpoint option is a host name without a scheme. When the endpoint has the http:// or https:// scheme, or proxyPort is not set, this option is not used and the scheme of the endpoint applies. | false | boolean | |
Whether the consumer closes the stream that it read the content of the object from, when the exchange is done. Only used when includeBody is true. If false, the consumer does not close the stream. | true | boolean | |
Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean | |
Whether the consumer bypasses the governance mode retention of object locking when it deletes an object with deleteAfterRead or moveAfterRead. This needs the s3:BypassGovernanceRetention permission. | false | boolean | |
Whether the consumer deletes the object from the bucket after the exchange completes successfully. If false, the consumer gets the same objects again in later polls: use the Idempotent Consumer EIP to filter out duplicates, for example by the CamelMinioObjectName header. | true | boolean | |
The delimiter that the listing requests of the consumer use to group object names into folders. If not set, the listing uses /. Not used when recursive is true. | String | ||
The bucket that the consumer moves the consumed objects to, with moveAfterRead, which requires it. The producer reads the bucket of copyObject from the CamelMinioDestinationBucketName header instead. | String | ||
The object name that the consumer moves the consumed objects to, in destinationBucketName, with moveAfterRead. If not set, the name of the consumed object. With a fixed name, each moved object replaces the previous one. | String | ||
Whether the consumer reads the content of the object into the body, as a byte array. If false, the body is null and the headers carry the metadata of the object. | true | boolean | |
Whether the consumer also creates an exchange for the folder entries of the listing. By default, it skips them. | false | boolean | |
Whether the listing requests of the consumer ask for the user metadata of the objects (a MinIO extension of ListObjectsV2). The consumer does not set this metadata on the message. The listing fails if useVersion1 or includeVersions is also true. | false | boolean | |
Whether the consumer lists all versions of the objects. It still gets each listed object name once per poll, in the version that the versionId option selects, else the current version. | false | boolean | |
The number of bytes of the object, from offset, that the consumer gets. With moveAfterRead, the consumer copies only these bytes. The default 0 means up to the end of the object. | long | ||
The consumer gets an object only if its ETag matches this value (the If-Match condition). For an object that does not match, the request fails and the consumer reports an error. | String | ||
Not used: the component does not pass this value to the MinIO client. Configure the connection pool of the OkHttpClient of the customHttpClient option instead. | 60 | int | |
The maximum number of objects that the consumer lists and consumes in one poll, which is also the page size of its listing requests. Use 0 or a negative number for no limit. Not used when objectName is set. | 10 | int | |
The consumer gets an object only if it was modified after this time (the If-Modified-Since condition). For another object, the request fails and the consumer reports an error. | ZonedDateTime | ||
Whether the consumer copies the object to destinationBucketName after the exchange completes successfully, and then deletes it from the bucket, also when deleteAfterRead is false. | false | boolean | |
The consumer gets an object only if its ETag does not match this value (the If-None-Match condition). For an object that matches, the request fails and the consumer reports an error. | String | ||
The name of the one object that the consumer gets in each poll, instead of listing the bucket. When set, the endpoint does not check or create the bucket, and does not set the policy, at startup. | String | ||
The position of the first byte of the object that the consumer gets. With moveAfterRead, the consumer copies only the bytes from this position. The default 0 is the start of the object. | long | ||
The prefix of the names of the objects that the consumer lists. | String | ||
Whether the consumer lists all the objects below the prefix. If false, the listing stops at the delimiter and returns the folders as entries, which the consumer skips unless includeFolders is true. | false | boolean | |
The object name after which the consumer lists the bucket, at the start of each pass through the bucket. The listing returns only the names that sort after it. | String | ||
The consumer gets an object only if it was not modified after this time (the If-Unmodified-Since condition). For another object, the request fails and the consumer reports an error. | ZonedDateTime | ||
Whether the consumer lists the bucket with version 1 of the ListObjects API instead of ListObjectsV2. | false | boolean | |
The version of the objects that the consumer gets, deletes with deleteAfterRead and copies with moveAfterRead. If not set, the current version. | String | ||
Whether the producer deletes the file after it uploaded it, when the body is a java.io.File, for example the file of a file consumer. Other bodies are not affected. | false | boolean | |
The name of the object that the producer uploads, gets, deletes, copies (the source of copyObject) or creates a link for. The CamelMinioObjectName header replaces it. | String | ||
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean | |
The operation that the producer performs. If not set, the producer uploads the body as an object. The CamelMinioOperation header replaces it. Enum values:
| MinioOperations | ||
Whether the body is the builder of the request of the MinIO Java SDK, such as io.minio.GetObjectArgs.Builder for getObject, instead of the producer building the request from options and headers. deleteObjects works only with true, and listBuckets does not use it. | false | boolean | |
The storage class of the objects that the producer uploads, sent as the x-amz-storage-class header, for example STANDARD or REDUCED_REDUNDANCY. The CamelMinioStorageClass header replaces it. | String | ||
Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | boolean | |
To use a custom okhttp3.OkHttpClient for the requests to the server, for example to configure timeouts, a proxy or the connection pool. Not used when minioClient is set. | OkHttpClient | ||
Used for enabling or disabling all consumer based health checks from this component. | true | boolean | |
Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer checks globally by setting camel.health.producersEnabled=true. | true | boolean | |
The access key (user name) for the requests to the server. If accessKey or secretKey is not set, the client sends the requests without credentials. Not used when minioClient is set. | String | ||
The secret key (password) of the accessKey. If accessKey or secretKey is not set, the client sends the requests without credentials. Not used when minioClient is set. | String | ||
The server-side encryption, as an io.minio.ServerSideEncryption such as ServerSideEncryption.S3 or ServerSideEncryption.KMS, of the objects that the producer uploads or copies with copyObject, and that the consumer copies with moveAfterRead. The producer fails to start if serverSideEncryptionCustomerKey is also set. | ServerSideEncryption | ||
The key for server-side encryption with a customer-provided key (SSE-C), as an io.minio.ServerSideEncryption.CustomerKey. The consumer uses it to get the objects and to copy them with moveAfterRead; the producer to get, upload and copy objects. The producer fails to start if serverSideEncryption is also set. | CustomerKey |
Endpoint Options
The Minio endpoint is configured using URI syntax:
minio:bucketName
With the following path and query parameters:
Query Parameters
| Name | Description | Default | Type |
|---|---|---|---|
Whether to create the bucket at startup if it does not exist (skipped when objectName is set), and, for a consumer with moveAfterRead, the destinationBucketName bucket. If false, a missing destination bucket fails the start of the consumer. | true | boolean | |
The MinIO server, or other Amazon S3 compatible service, to connect to: a URL such as http://localhost:9000, or a host name or IP address, for which the client uses HTTPS on port 443. Required unless minioClient is set. | String | ||
Autowired To use a custom io.minio.MinioClient. When this option is set or autowired, the endpoint, proxyPort, secure, region, accessKey, secretKey and customHttpClient options are not used. | MinioClient | ||
Whether to enable object locking on the buckets that the component creates (see autoCreateBucket). It does not change an existing bucket. | false | boolean | |
The bucket policy, as JSON, that the endpoint sets on the bucket at startup. Not applied when objectName is set. | String | ||
The TCP port of the server. When set, it replaces the port of the endpoint option. An endpoint with the http:// or https:// scheme keeps its scheme; for a host name without a scheme, the secure option sets it. Not used when minioClient is set. | Integer | ||
The region of the server, for example us-east-1. The client signs its requests for this region, and the component creates buckets in it. If not set, the client asks the server for the region of the bucket. | String | ||
Whether the client uses HTTPS (true) or HTTP (false) when proxyPort is set and the endpoint option is a host name without a scheme. When the endpoint has the http:// or https:// scheme, or proxyPort is not set, this option is not used and the scheme of the endpoint applies. | false | boolean | |
Whether the consumer closes the stream that it read the content of the object from, when the exchange is done. Only used when includeBody is true. If false, the consumer does not close the stream. | true | boolean | |
Whether the consumer bypasses the governance mode retention of object locking when it deletes an object with deleteAfterRead or moveAfterRead. This needs the s3:BypassGovernanceRetention permission. | false | boolean | |
Whether the consumer deletes the object from the bucket after the exchange completes successfully. If false, the consumer gets the same objects again in later polls: use the Idempotent Consumer EIP to filter out duplicates, for example by the CamelMinioObjectName header. | true | boolean | |
The delimiter that the listing requests of the consumer use to group object names into folders. If not set, the listing uses /. Not used when recursive is true. | String | ||
The bucket that the consumer moves the consumed objects to, with moveAfterRead, which requires it. The producer reads the bucket of copyObject from the CamelMinioDestinationBucketName header instead. | String | ||
The object name that the consumer moves the consumed objects to, in destinationBucketName, with moveAfterRead. If not set, the name of the consumed object. With a fixed name, each moved object replaces the previous one. | String | ||
Whether the consumer reads the content of the object into the body, as a byte array. If false, the body is null and the headers carry the metadata of the object. | true | boolean | |
Whether the consumer also creates an exchange for the folder entries of the listing. By default, it skips them. | false | boolean | |
Whether the listing requests of the consumer ask for the user metadata of the objects (a MinIO extension of ListObjectsV2). The consumer does not set this metadata on the message. The listing fails if useVersion1 or includeVersions is also true. | false | boolean | |
Whether the consumer lists all versions of the objects. It still gets each listed object name once per poll, in the version that the versionId option selects, else the current version. | false | boolean | |
The number of bytes of the object, from offset, that the consumer gets. With moveAfterRead, the consumer copies only these bytes. The default 0 means up to the end of the object. | long | ||
The consumer gets an object only if its ETag matches this value (the If-Match condition). For an object that does not match, the request fails and the consumer reports an error. | String | ||
Not used: the component does not pass this value to the MinIO client. Configure the connection pool of the OkHttpClient of the customHttpClient option instead. | 60 | int | |
The maximum number of objects that the consumer lists and consumes in one poll, which is also the page size of its listing requests. Use 0 or a negative number for no limit. Not used when objectName is set. | 10 | int | |
The consumer gets an object only if it was modified after this time (the If-Modified-Since condition). For another object, the request fails and the consumer reports an error. | ZonedDateTime | ||
Whether the consumer copies the object to destinationBucketName after the exchange completes successfully, and then deletes it from the bucket, also when deleteAfterRead is false. | false | boolean | |
The consumer gets an object only if its ETag does not match this value (the If-None-Match condition). For an object that matches, the request fails and the consumer reports an error. | String | ||
The name of the one object that the consumer gets in each poll, instead of listing the bucket. When set, the endpoint does not check or create the bucket, and does not set the policy, at startup. | String | ||
The position of the first byte of the object that the consumer gets. With moveAfterRead, the consumer copies only the bytes from this position. The default 0 is the start of the object. | long | ||
The prefix of the names of the objects that the consumer lists. | String | ||
Whether the consumer lists all the objects below the prefix. If false, the listing stops at the delimiter and returns the folders as entries, which the consumer skips unless includeFolders is true. | false | boolean | |
If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead. | false | boolean | |
The object name after which the consumer lists the bucket, at the start of each pass through the bucket. The listing returns only the names that sort after it. | String | ||
The consumer gets an object only if it was not modified after this time (the If-Unmodified-Since condition). For another object, the request fails and the consumer reports an error. | ZonedDateTime | ||
Whether the consumer lists the bucket with version 1 of the ListObjects API instead of ListObjectsV2. | false | boolean | |
The version of the objects that the consumer gets, deletes with deleteAfterRead and copies with moveAfterRead. If not set, the current version. | String | ||
Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean | |
To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | ExceptionHandler | ||
Sets the exchange pattern when the consumer creates an exchange. Enum values:
| ExchangePattern | ||
A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the poll operation before an Exchange have been created and being routed in Camel. | PollingConsumerPollStrategy | ||
Whether the producer deletes the file after it uploaded it, when the body is a java.io.File, for example the file of a file consumer. Other bodies are not affected. | false | boolean | |
The name of the object that the producer uploads, gets, deletes, copies (the source of copyObject) or creates a link for. The CamelMinioObjectName header replaces it. | String | ||
The operation that the producer performs. If not set, the producer uploads the body as an object. The CamelMinioOperation header replaces it. Enum values:
| MinioOperations | ||
Whether the body is the builder of the request of the MinIO Java SDK, such as io.minio.GetObjectArgs.Builder for getObject, instead of the producer building the request from options and headers. deleteObjects works only with true, and listBuckets does not use it. | false | boolean | |
The storage class of the objects that the producer uploads, sent as the x-amz-storage-class header, for example STANDARD or REDUCED_REDUNDANCY. The CamelMinioStorageClass header replaces it. | String | ||
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean | |
To use a custom okhttp3.OkHttpClient for the requests to the server, for example to configure timeouts, a proxy or the connection pool. Not used when minioClient is set. | OkHttpClient | ||
The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in. | int | ||
The number of subsequent idle polls that should happen before the backoffMultipler should kick-in. | int | ||
To let the scheduled polling consumer backoff if there has been a number of subsequent idles/errors in a row. The multiplier is then the number of polls that will be skipped before the next actual attempt is happening again. When this option is in use then backoffIdleThreshold and/or backoffErrorThreshold must also be configured. | int | ||
Milliseconds before the next poll. | 500 | long | |
If greedy is enabled, then the ScheduledPollConsumer will run immediately again, if the previous run polled 1 or more messages. | false | boolean | |
How long a poll may run before the health check of the consumer reports DOWN. The health check is otherwise based on the polls that are done, so it stays UP while a poll hangs, for example on a read without timeout from a connection that went silent. A poll includes routing the messages it polled, so set this above the longest poll you expect. The poll is not interrupted. The value is in millis (not affected by timeUnit). The default 0 turns this off. | 0 | long | |
Milliseconds before the first poll starts. | 1000 | long | |
Specifies a maximum limit of number of fires. So if you set it to 1, the scheduler will only fire once. If you set it to 5, it will only fire five times. A value of zero or negative means fire forever. | 0 | long | |
The consumer logs a start/complete log line when it polls. This option allows you to configure the logging level for that. Enum values:
| TRACE | LoggingLevel | |
Allows for configuring a custom/shared thread pool to use for the consumer. By default each consumer has its own single threaded thread pool. | ScheduledExecutorService | ||
To use a cron scheduler from either camel-spring or camel-quartz component. Use value spring or quartz for built in scheduler. | none | Object | |
To configure additional properties when using a custom scheduler or any of the Quartz, Spring based scheduler. This is a multi-value option with prefix: scheduler. | Map | ||
Whether the scheduler should be auto started. | true | boolean | |
Time unit for initialDelay and delay options. Enum values:
| MILLISECONDS | TimeUnit | |
Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details. | true | boolean | |
The access key (user name) for the requests to the server. If accessKey or secretKey is not set, the client sends the requests without credentials. Not used when minioClient is set. | String | ||
The secret key (password) of the accessKey. If accessKey or secretKey is not set, the client sends the requests without credentials. Not used when minioClient is set. | String | ||
The server-side encryption, as an io.minio.ServerSideEncryption such as ServerSideEncryption.S3 or ServerSideEncryption.KMS, of the objects that the producer uploads or copies with copyObject, and that the consumer copies with moveAfterRead. The producer fails to start if serverSideEncryptionCustomerKey is also set. | ServerSideEncryption | ||
The key for server-side encryption with a customer-provided key (SSE-C), as an io.minio.ServerSideEncryption.CustomerKey. The consumer uses it to get the objects and to copy them with moveAfterRead; the producer to get, upload and copy objects. The producer fails to start if serverSideEncryption is also set. | CustomerKey |
Message Headers
The Minio component supports the following message header(s), which is/are listed below:
| Name | Description | Default | Type |
|---|---|---|---|
| Constant: | The name of the bucket of the consumed object. The consumer sets it. The producer does not read it: the CamelMinioOverrideBucketName header sets the bucket of the producer. | String | |
CamelMinioDestinationBucketName (producer) Constant: | The bucket that the producer copies the object to, for copyObject, which requires it. | String | |
CamelMinioContentControl (common) Constant: | The Cache-Control of the object. The consumer sets it from the consumed object. The producer stores it as user metadata (x-amz-meta-Cache-Control) of the object it uploads. | String | |
CamelMinioContentDisposition (common) Constant: | The Content-Disposition of the object. The consumer sets it from the consumed object. The producer stores it as user metadata (x-amz-meta-Content-Disposition) of the object it uploads. | String | |
CamelMinioContentEncoding (common) Constant: | The Content-Encoding of the object. The consumer sets it from the consumed object. The producer stores it as user metadata (x-amz-meta-Content-Encoding) of the object it uploads. | String | |
CamelMinioContentLength (common) Constant: | The size of the object in bytes. The consumer sets it for the consumed object. The producer uses it as the length of a body whose length it cannot tell without reading it. | Long | |
| Constant: | The Content-MD5 of the object that the producer uploads, the Base64 encoded MD5 digest of its content. The producer stores it as user metadata (x-amz-meta-Content-Md5) of the object. | String | |
CamelMinioContentType (common) Constant: | The Content-Type of the object. The consumer sets it from the consumed object. The producer stores it as user metadata (x-amz-meta-Content-Type) of the object it uploads. | String | |
| Constant: | The entity tag (ETag) of the object. The consumer sets it for the consumed object, and the producer for the object it uploaded. | String | |
| Constant: | The name of the object. The consumer sets it for the consumed object. The producer reads it as the object to upload, get, delete, copy or create a link for, and it replaces the keyName option. | String | |
CamelMinioDestinationObjectName (producer) Constant: | The name of the object that the producer copies to, for copyObject, which requires it. | String | |
CamelMinioLastModified (common) Constant: | The value of the Last-Modified HTTP header of the consumed object. The consumer sets it. | Date | |
CamelMinioStorageClass (producer) Constant: | The storage class of the object. The consumer sets it from the consumed object when the server returns one. The producer reads it as the storage class of the object it uploads, and it replaces the storageClass option. | String | |
| Constant: | The version ID of the object, when versioning is enabled on the bucket. The consumer sets it for the consumed object, and the producer for the object it uploaded or copied with copyObject. | String | |
CamelMinioCannedAcl (producer) Constant: | The canned ACL of the object that the producer uploads, sent as the x-amz-acl header, for example private or public-read. | String | |
CamelMinioOperation (producer) Constant: | The operation that the producer performs. It replaces the operation option. Enum values:
| MinioOperations | |
CamelMinioServerSideEncryption (common) Constant: | The server-side encryption algorithm of the consumed object, from the x-amz-server-side-encryption header, for example AES256. The consumer sets it. The producer does not read it: the serverSideEncryption option sets the encryption of uploads. | String | |
CamelMinioExpirationTime (common) Constant: | The value of the x-amz-expiration header of the consumed object: when a lifecycle rule of the bucket expires the object. The consumer sets it. | String | |
CamelMinioReplicationStatus (common) Constant: | The replication status of the consumed object, from the x-amz-replication-status header. The consumer sets it. | String | |
| Constant: | The position of the first byte that the producer gets, for getObjectRange, which requires it. | String | |
| Constant: | The number of bytes, from CamelMinioOffset, that the producer gets, for getObjectRange, which requires it. | String | |
CamelMinioPresignedURLExpirationTime (producer) Constant: | How long, in seconds, the URL of createDownloadLink and createUploadLink is valid: from 1 to 604800 (7 days). The default is 3600 (one hour). | int | |
CamelMinioOverrideBucketName (common) Constant: | The name of the bucket for the producer. It replaces the bucket of the endpoint. | String |
Message Body
The message body at each side of the Minio component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.
| Side | Body | Description |
|---|---|---|
Consumer |
| The content of the object as a byte array, one message per object, with its metadata in headers. No body with includeBody=false.
|
Producer input |
| The content to upload, when no operation is set: text, bytes, a stream or a file. A Map, a List or no body fails: marshal it first. The operations take their input from headers, or with pojoRequest=true from the builder of the request of the Minio SDK in the body, such as a GetObjectArgs.Builder; deleteObjects works only so. Not known when |
Producer output |
| Unchanged after an upload and a copyObject, with the ETag in a header. By the operation: the stream of the object for getObject and getObjectRange, a lazy Iterable of Result for listObjects, whose get() gives the Item, an Iterator of Bucket for listBuckets, true for the deletes, ok for deleteBucket and the URL as text for the links.
|
The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers, the sides and the tools that use them are described in Message Body Types.
You have to provide the minioClient in the Registry or your accessKey and secretKey to access the Minio. |
Usage
Batch Consumer
This component implements the Batch Consumer.
This allows you, for instance, to know how many messages exist in this batch and for instance, let the Aggregator aggregate this number of messages.
The batch properties are set before the content of each object is fetched. If an object is deleted (for example by another consumer) between the listing and the get of its content, it is skipped, so CamelBatchSize can be higher than the number of exchanges routed for the batch, and possibly no exchange has CamelBatchComplete set to true. |
Minio Producer operations
Camel-Minio component provides the following operation on the producer side:
-
copyObject -
deleteObject -
deleteObjects -
listBuckets -
deleteBucket -
listObjects -
getObject(this will return the content of the object as a stream) -
getObjectRange(this will return the range of the content as a stream). The former namegetPartialObjectstill works, but is deprecated. -
createDownloadLink(this will return a Presigned download Url) -
createUploadLink(this will return a Presigned upload url)
Advanced Minio configuration
If your Camel Application is running behind a firewall or if you need to have more control over the MinioClient instance configuration, you can create your own instance and refer to it in your Camel minio component configuration:
-
Java
-
XML
-
YAML
from("minio://MyBucket?minioClient=#client&delay=5000&maxMessagesPerPoll=5")
.to("mock:result"); <route>
<from uri="minio://MyBucket?minioClient=#client&delay=5000&maxMessagesPerPoll=5"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: minio://MyBucket
parameters:
minioClient: "#client"
delay: 5000
maxMessagesPerPoll: 5
steps:
- to:
uri: mock:result Minio Producer Operation examples
-
CopyObject: this operation copies an object from one bucket to a different one
-
Java
-
XML
-
YAML
from("direct:start")
.setHeader("CamelMinioDestinationBucketName").constant("camelDestinationBucket")
.setHeader("CamelMinioObjectName").constant("camelKey")
.setHeader("CamelMinioDestinationObjectName").constant("camelDestinationKey")
.to("minio://mycamelbucket?minioClient=#minioClient&operation=copyObject")
.to("mock:result"); <route>
<from uri="direct:start"/>
<setHeader name="CamelMinioDestinationBucketName">
<constant>camelDestinationBucket</constant>
</setHeader>
<setHeader name="CamelMinioObjectName">
<constant>camelKey</constant>
</setHeader>
<setHeader name="CamelMinioDestinationObjectName">
<constant>camelDestinationKey</constant>
</setHeader>
<to uri="minio://mycamelbucket?minioClient=#minioClient&operation=copyObject"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:start
steps:
- setHeader:
name: CamelMinioDestinationBucketName
constant: camelDestinationBucket
- setHeader:
name: CamelMinioObjectName
constant: camelKey
- setHeader:
name: CamelMinioDestinationObjectName
constant: camelDestinationKey
- to:
uri: minio://mycamelbucket
parameters:
minioClient: "#minioClient"
operation: copyObject
- to:
uri: mock:result This operation will copy the object with the name expressed in the header camelDestinationKey to the camelDestinationBucket bucket, from the bucket mycamelbucket.
-
DeleteObject: this operation deletes an object from a bucket
-
Java
-
XML
-
YAML
from("direct:start")
.setHeader("CamelMinioObjectName").constant("camelKey")
.to("minio://mycamelbucket?minioClient=#minioClient&operation=deleteObject")
.to("mock:result"); <route>
<from uri="direct:start"/>
<setHeader name="CamelMinioObjectName">
<constant>camelKey</constant>
</setHeader>
<to uri="minio://mycamelbucket?minioClient=#minioClient&operation=deleteObject"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:start
steps:
- setHeader:
name: CamelMinioObjectName
constant: camelKey
- to:
uri: minio://mycamelbucket
parameters:
minioClient: "#minioClient"
operation: deleteObject
- to:
uri: mock:result This operation will delete the object camelKey from the bucket mycamelbucket.
-
ListBuckets: this operation lists the buckets for this account in this region
-
Java
-
XML
-
YAML
from("direct:start")
.to("minio://mycamelbucket?minioClient=#minioClient&operation=listBuckets")
.to("mock:result"); <route>
<from uri="direct:start"/>
<to uri="minio://mycamelbucket?minioClient=#minioClient&operation=listBuckets"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:start
steps:
- to:
uri: minio://mycamelbucket
parameters:
minioClient: "#minioClient"
operation: listBuckets
- to:
uri: mock:result This operation will list the buckets for this account
-
DeleteBucket: this operation deletes the bucket specified as URI parameter or header
-
Java
-
XML
-
YAML
from("direct:start")
.to("minio://mycamelbucket?minioClient=#minioClient&operation=deleteBucket")
.to("mock:result"); <route>
<from uri="direct:start"/>
<to uri="minio://mycamelbucket?minioClient=#minioClient&operation=deleteBucket"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:start
steps:
- to:
uri: minio://mycamelbucket
parameters:
minioClient: "#minioClient"
operation: deleteBucket
- to:
uri: mock:result This operation will delete the bucket mycamelbucket
-
ListObjects: this operation list object in a specific bucket
-
Java
-
XML
-
YAML
from("direct:start")
.to("minio://mycamelbucket?minioClient=#minioClient&operation=listObjects")
.to("mock:result"); <route>
<from uri="direct:start"/>
<to uri="minio://mycamelbucket?minioClient=#minioClient&operation=listObjects"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:start
steps:
- to:
uri: minio://mycamelbucket
parameters:
minioClient: "#minioClient"
operation: listObjects
- to:
uri: mock:result This operation will list the objects in the mycamelbucket bucket
-
GetObject: this operation gets a single object in a specific bucket
-
Java
-
XML
-
YAML
from("direct:start")
.setHeader("CamelMinioObjectName").constant("camelKey")
.to("minio://mycamelbucket?minioClient=#minioClient&operation=getObject")
.to("mock:result"); <route>
<from uri="direct:start"/>
<setHeader name="CamelMinioObjectName">
<constant>camelKey</constant>
</setHeader>
<to uri="minio://mycamelbucket?minioClient=#minioClient&operation=getObject"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:start
steps:
- setHeader:
name: CamelMinioObjectName
constant: camelKey
- to:
uri: minio://mycamelbucket
parameters:
minioClient: "#minioClient"
operation: getObject
- to:
uri: mock:result This operation will return the content of the camelKey object in mycamelbucket bucket as a stream.
-
GetObjectRange: this operation gets a single object range in a specific bucket
-
Java
-
XML
-
YAML
from("direct:start")
.setHeader("CamelMinioObjectName").constant("camelKey")
.setHeader("CamelMinioOffset").constant("0")
.setHeader("CamelMinioLength").constant("9")
.to("minio://mycamelbucket?minioClient=#minioClient&operation=getObjectRange")
.to("mock:result"); <route>
<from uri="direct:start"/>
<setHeader name="CamelMinioObjectName">
<constant>camelKey</constant>
</setHeader>
<setHeader name="CamelMinioOffset">
<constant>0</constant>
</setHeader>
<setHeader name="CamelMinioLength">
<constant>9</constant>
</setHeader>
<to uri="minio://mycamelbucket?minioClient=#minioClient&operation=getObjectRange"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:start
steps:
- setHeader:
name: CamelMinioObjectName
constant: camelKey
- setHeader:
name: CamelMinioOffset
constant: "0"
- setHeader:
name: CamelMinioLength
constant: "9"
- to:
uri: minio://mycamelbucket
parameters:
minioClient: "#minioClient"
operation: getObjectRange
- to:
uri: mock:result This operation will return the bytes from 0 to 9 of the camelKey object in mycamelbucket bucket as a stream.
-
createDownloadLink: this operation will return a presigned url through which a file can be downloaded using GET method
-
Java
-
XML
-
YAML
from("direct:start")
.setHeader("CamelMinioObjectName").constant("camelKey")
.setHeader("CamelMinioPresignedURLExpirationTime").constant(3600)
.to("minio://mycamelbucket?minioClient=#minioClient&operation=createDownloadLink")
.to("mock:result"); <route>
<from uri="direct:start"/>
<setHeader name="CamelMinioObjectName">
<constant>camelKey</constant>
</setHeader>
<setHeader name="CamelMinioPresignedURLExpirationTime">
<constant resultType="java.lang.Integer">3600</constant>
</setHeader>
<to uri="minio://mycamelbucket?minioClient=#minioClient&operation=createDownloadLink"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:start
steps:
- setHeader:
name: CamelMinioObjectName
constant: camelKey
- setHeader:
name: CamelMinioPresignedURLExpirationTime
constant: 3600
- to:
uri: minio://mycamelbucket
parameters:
minioClient: "#minioClient"
operation: createDownloadLink
- to:
uri: mock:result -
createUploadLink: this operation will return a presigned url through which a file can be uploaded using PUT method
-
Java
-
XML
-
YAML
from("direct:start")
.setHeader("CamelMinioObjectName").constant("camelKey")
.setHeader("CamelMinioPresignedURLExpirationTime").constant(3600)
.to("minio://mycamelbucket?minioClient=#minioClient&operation=createUploadLink")
.to("mock:result"); <route>
<from uri="direct:start"/>
<setHeader name="CamelMinioObjectName">
<constant>camelKey</constant>
</setHeader>
<setHeader name="CamelMinioPresignedURLExpirationTime">
<constant resultType="java.lang.Integer">3600</constant>
</setHeader>
<to uri="minio://mycamelbucket?minioClient=#minioClient&operation=createUploadLink"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: direct:start
steps:
- setHeader:
name: CamelMinioObjectName
constant: camelKey
- setHeader:
name: CamelMinioPresignedURLExpirationTime
constant: 3600
- to:
uri: minio://mycamelbucket
parameters:
minioClient: "#minioClient"
operation: createUploadLink
- to:
uri: mock:result createDownLink and createUploadLink have a default expiry of 3600s which can be overridden by setting the header CamelMinioPresignedURLExpirationTime (value in seconds)
Bucket Auto-creation
With the option autoCreateBucket users are able to avoid the auto-creation of a Minio Bucket in case it doesn’t exist. The default for this option is true. If set to false, any operation on a not-existent bucket in Minio won’t be successful, and an error will be returned.
Automatic detection of a Minio client in registry
The component is capable of detecting the presence of a Minio bean into the registry. If it’s the only instance of that type, it will be used as the client, and you won’t have to define it as uri parameter, like the example above. This may be really useful for smarter configuration of the endpoint.
Moving stuff between a bucket and another bucket
Some users like to consume stuff from a bucket and move the content in a different one without using the copyObject feature of this component. If this is the case for you, remember to remove the bucketName header from the incoming exchange of the consumer. Otherwise, the file will always be overwritten on the same original bucket.
MoveAfterRead consumer option
In addition to deleteAfterRead, it has been added another option, moveAfterRead. With this option enabled, the consumed object will be moved to a target destinationBucketName instead of being only deleted. This will require specifying the destinationBucketName option. As example:
-
Java
-
XML
-
YAML
from("minio://mycamelbucket?minioClient=#minioClient&moveAfterRead=true&destinationBucketName=myothercamelbucket")
.to("mock:result"); <route>
<from uri="minio://mycamelbucket?minioClient=#minioClient&moveAfterRead=true&destinationBucketName=myothercamelbucket"/>
<to uri="mock:result"/>
</route> - route:
from:
uri: minio://mycamelbucket
parameters:
minioClient: "#minioClient"
moveAfterRead: true
destinationBucketName: myothercamelbucket
steps:
- to:
uri: mock:result In this case, the objects consumed will be moved to myothercamelbucket bucket and deleted from the original one (because of deleteAfterRead set to true as default).
The consumer deletes or moves the object it consumed, whatever the route does with the CamelMinioObjectName and CamelMinioBucketName headers. A route can set the object name header to write a copy of the object under another name.
Using a POJO as body
Sometimes build a Minio Request can be complex because of multiple options. We introduce the possibility to use a POJO as the body. In Minio, there are multiple operations you can submit, as an example for List brokers request, you can do something like:
from("direct:minio")
.setBody(ListObjectsArgs.builder()
.bucket(bucketName)
.recursive(getConfiguration().isRecursive()))
.to("minio://test?minioClient=#minioClient&operation=listObjects&pojoRequest=true"); In this way, you’ll pass the request directly without the need of passing headers and options specifically related to this operation.
Dependencies
Maven users will need to add the following dependency to their pom.xml.
pom.xml
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-minio</artifactId>
<version>${camel-version}</version>
</dependency> where ${camel-version} must be replaced by the actual version of Camel.