Openshift Component

Table of Contents

URI format
Options
Examples
See Also

Available as of Camel 2.14

The openshift component is a component for managing your OpenShift applications. 

Maven users will need to add the following dependency to their pom.xml for this component:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-openshift</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

URI format

openshift:clientId[?options]

You can append query options to the URI in the following format, ?option=value&option=value&…​

Options

The OpenShift component supports 4 options which are listed below.

{% raw %}

NameJava TypeDescription

username

String

The username to login to openshift server.

password

String

The password for login to openshift server.

domain

String

Domain name. If not specified then the default domain is used.

server

String

Url to the openshift server. If not specified then the default value from the local openshift configuration file /.openshift/express.conf is used. And if that fails as well then openshift.redhat.com is used.

{% endraw %}

The OpenShift component supports 27 endpoint options which are listed below:

{% raw %}

NameGroupDefaultJava TypeDescription

clientId

common

 

String

Required The client id

domain

common

 

String

Domain name. If not specified then the default domain is used.

password

common

 

String

Required The password for login to openshift server.

server

common

 

String

Url to the openshift server. If not specified then the default value from the local openshift configuration file /.openshift/express.conf is used. And if that fails as well then openshift.redhat.com is used.

username

common

 

String

Required The username to login to openshift server.

bridgeErrorHandler

consumer

false

boolean

Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored.

sendEmptyMessageWhenIdle

consumer

false

boolean

If the polling consumer did not poll any files you can enable this option to send an empty message (no body) instead.

exceptionHandler

consumer (advanced)

 

ExceptionHandler

To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored.

exchangePattern

consumer (advanced)

 

ExchangePattern

Sets the exchange pattern when the consumer creates an exchange.

pollStrategy

consumer (advanced)

 

PollingConsumerPollStrategy

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.

application

producer

 

String

The application name to start stop restart or get the state.

mode

producer

 

String

Whether to output the message body as a pojo or json. For pojo the message is a List type.

operation

producer

 

String

The operation to perform which can be: list start stop restart and state. The list operation returns information about all the applications in json format. The state operation returns the state such as: started stopped etc. The other operations does not return any value.

synchronous

advanced

false

boolean

Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).

backoffErrorThreshold

scheduler

 

int

The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in.

backoffIdleThreshold

scheduler

 

int

The number of subsequent idle polls that should happen before the backoffMultipler should kick-in.

backoffMultiplier

scheduler

 

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.

delay

scheduler

500

long

Milliseconds before the next poll. You can also specify time values using units such as 60s (60 seconds) 5m30s (5 minutes and 30 seconds) and 1h (1 hour).

greedy

scheduler

false

boolean

If greedy is enabled then the ScheduledPollConsumer will run immediately again if the previous run polled 1 or more messages.

initialDelay

scheduler

1000

long

Milliseconds before the first poll starts. You can also specify time values using units such as 60s (60 seconds) 5m30s (5 minutes and 30 seconds) and 1h (1 hour).

runLoggingLevel

scheduler

TRACE

LoggingLevel

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

scheduledExecutorService

scheduler

 

ScheduledExecutorService

Allows for configuring a custom/shared thread pool to use for the consumer. By default each consumer has its own single threaded thread pool.

scheduler

scheduler

none

ScheduledPollConsumerScheduler

To use a cron scheduler from either camel-spring or camel-quartz2 component

schedulerProperties

scheduler

 

Map

To configure additional properties when using a custom scheduler or any of the Quartz2 Spring based scheduler.

startScheduler

scheduler

true

boolean

Whether the scheduler should be auto started.

timeUnit

scheduler

MILLISECONDS

TimeUnit

Time unit for initialDelay and delay options.

useFixedDelay

scheduler

true

boolean

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

{% endraw %}

Examples

Listing all applications

// sending route
from("direct:apps")
    .to("openshift:myClient?username=foo&password=secret&operation=list");
    .to("log:apps");

In this case the information about all the applications is returned as pojo. If you want a json response, then set mode=json.

Stopping an application

// stopping the foobar application
from("direct:control")
    .to("openshift:myClient?username=foo&password=secret&operation=stop&application=foobar");
 

In the example above we stop the application named foobar.

 

Polling for gear state changes

The consumer is used for polling state changes in gears. Such as when a new gear is added/removed/ or its lifecycle is changed, eg started, or stopped etc.

// trigger when state changes on our gears
from("openshift:myClient?username=foo&password=secret&delay=30s")
    .log("Event ${header.CamelOpenShiftEventType} on application ${body.name} changed state to ${header.CamelOpenShiftEventNewState}");

 

When the consumer emits an Exchange then the body contains the com.openshift.client.IApplication as the message body. And the following headers is included.

HeaderMay be nullDescription

CamelOpenShiftEventType

No

The type of the event which can be one of: added, removed or changed.

CamelOpenShiftEventOldState

Yes

The old state, when the event type is changed.

CamelOpenShiftEventNewState

No

The new state, for any of the event types

See Also