Camel Components

OpenStack Swift

Deprecated: This openstack-swift is deprecated and may be removed in a future release.

Since Camel 2.19

Only producer is supported

The Openstack Swift component allows messages to be sent to an OpenStack object storage services.

Dependencies

Maven users will need to add the following dependency to their pom.xml.

pom.xml
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-openstack</artifactId>
    <version>${camel-version}</version>
</dependency>

where ${camel-version} must be replaced by the actual version of Camel.

URI Format

openstack-swift://hosturl[?options]

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, *.yaml files, 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 OpenStack Swift component supports the following options which are listed below.

Name Description Default Type

lazyStartProducer (producer)

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

autowiredEnabled (advanced)

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

Endpoint Options

The OpenStack Swift endpoint is configured using URI syntax:

openstack-swift:host

With the following path and query parameters:

Path Parameters

Name Description Default Type

host (producer)

Required The URL of the OpenStack Identity service (Keystone) to authenticate with, for example http://controller:5000/v3.

String

Query Parameters

Name Description Default Type

apiVersion (producer)

The version of the OpenStack Identity API to authenticate with: V3 or V2.

Enum values:

  • V2

  • V3

V3

String

config (producer)

The openstack4j client configuration (org.openstack4j.core.transport.Config), for example to set connection and read timeouts, an SSLContext or a proxy. When not set, the openstack4j defaults are used.

Config

domain (producer)

The name of the domain the user belongs to, used to authenticate with Identity API V3 (not used with V2).

default

String

operation (producer)

The operation to perform: create, get, getAll, delete, getMetadata or createUpdateMetadata; containers also support update and deleteMetadata.

String

password (producer)

Required The password of the OpenStack user.

String

project (producer)

Required The ID of the project to scope the authentication to (the tenant ID with Identity API V2).

String

subsystem (producer)

Required The kind of Swift resource to manage: objects or containers.

Enum values:

  • objects

  • containers

String

username (producer)

Required The name of the OpenStack user to authenticate as.

String

lazyStartProducer (producer (advanced))

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

Message Headers

The OpenStack Swift component supports the following message header(s), which is/are listed below:

Name Description Default Type

CamelOpenstackSwiftContainerName (object container)

Constant: CONTAINER_NAME

The container name.

String

CamelOpenstackSwiftObjectName (object)

Constant: OBJECT_NAME

The object name.

String

CamelOpenstackSwiftContainerMetadata (container)

Constant: CONTAINER_METADATA_PREFIX

The metadata to set on the container when it is created or updated.

Map

CamelOpenstackSwiftVersionsLocation (container)

Constant: VERSIONS_LOCATION

The name of the container to keep the older versions of the objects in, which enables versioning.

String

CamelOpenstackSwiftContainerRead (container)

Constant: CONTAINER_READ

The read access control list (ACL) of the container.

String

CamelOpenstackSwiftContainerWrite (container)

Constant: CONTAINER_WRITE

The write access control list (ACL) of the container.

String

CamelOpenstackSwiftLimit (container)

Constant: LIMIT

The maximum number of containers to list.

Integer

CamelOpenstackSwiftMarker (container)

Constant: MARKER

List only the containers whose names are greater than this value.

String

CamelOpenstackSwiftEndMarker (container)

Constant: END_MARKER

List only the containers whose names are less than this value.

String

CamelOpenstackSwiftDelimiter (container)

Constant: DELIMITER

The delimiter character: names that share the part up to the delimiter are listed as one entry.

Character

CamelOpenstackSwiftPath (container object)

Constant: PATH

The pseudo folder path to list the names nested in.

String

CamelOpenstackOperation (producer)

Constant: OPERATION

The operation to perform.

String

CamelOpenstackId (producer)

Constant: ID

The ID of the resource to act on.

String

CamelOpenstackName (producer)

Constant: NAME

The name of the resource, such as the volume, image or server to create, or the key pair or container to act on.

String

Message Body

The message body at each side of the OpenStack Swift 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

Producer input

any

For create of an object the content: an InputStream, a File, a URL or a Payload of openstack4j, or else a body that converts to an InputStream such as text, bytes or the file of the file consumer. createUpdateMetadata and deleteMetadata take the metadata as a Map. The containers take a CreateUpdateContainerOptions or ContainerListOptions of openstack4j, or else headers.

Producer output

text, pojo, list, map, null or unchanged

For objects: the ETag as text after create, the SwiftObject of openstack4j for get (its download() gives the content), a List of them for getAll. For containers: a List of SwiftContainer for get and getAll; create and update keep the body. getMetadata gives a Map of the metadata; delete and the metadata updates keep the body.

  • With operation=getAll: list

  • With operation=getMetadata: map

  • With operation=delete: unchanged

  • With operation=createUpdateMetadata: unchanged

  • With operation=deleteMetadata: unchanged

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.

Usage

You can use the following settings for each subsystem:

Containers

Operations you can perform with the Container producer

Operation Description

create

Create a new container.

get

List the containers that match the list options.

getAll

Get all containers.

update

Update the container.

delete

Delete the container.

getMetadata

Get metadata.

createUpdateMetadata

Create/update metadata.

deleteMetadata

Delete metadata.

If you need more precise container settings, you can create a new object of the type org.openstack4j.model.storage.object.options.CreateUpdateContainerOptions (in case of create or update operation) or org.openstack4j.model.storage.object.options.ContainerListOptions for listing containers and send in the message body.

Objects

Operations you can perform with the Object producer

Operation Description

create

Create a new object.

get

Get the object.

getAll

Get all objects.

delete

Delete the object.

getMetadata

Get metadata.

createUpdateMetadata

Create/update metadata.

Example

The following route stores each file of the outbox folder as an object of the reports container. The body is the content of the object: an InputStream, a File, a URL or a Payload of openstack4j, or else a body that converts to an InputStream, such as text, bytes or the file of the file consumer. The endpoint is the address of the identity service (Keystone), and the credentials are property placeholders:

- route:
    from:
      uri: file:outbox
      steps:
        - setHeader:
            name: CamelOpenstackSwiftContainerName
            expression:
              constant:
                expression: "reports"
        - setHeader:
            name: CamelOpenstackSwiftObjectName
            expression:
              simple:
                expression: "${header.CamelFileName}"
        - to:
            uri: openstack-swift:http://controller:5000/v3
            parameters:
              username: "{{openstack.username}}"
              password: "{{openstack.password}}"
              project: "{{openstack.project}}"
              subsystem: objects
              operation: create
        - log:
            message: "Stored ${header.CamelFileName} with ETag ${body}"