Chapter 248. OpenShift Component (deprecated) Available as of Camel version 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> 248.1. URI format openshift:clientId[?options] You can append query options to the URI in the following format, ?option=value&option=value&... 248.2. Options The OpenShift component supports 5 options, which are listed below. Name Description Default Type username (security) The username to login to openshift server. String password (security) The password for login to openshift server. String domain (common) Domain name. If not specified then the default domain is used. String server (common) 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. String resolveProperty Placeholders (advanced) Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. true boolean The OpenShift endpoint is configured using URI syntax: with the following path and query parameters: 248.2.1. Path Parameters (1 parameters): Name Description Default Type clientId Required The client id String 248.2.2. Query Parameters (26 parameters): Name Description Default Type domain (common) Domain name. If not specified then the default domain is used. String password (common) Required The password for login to openshift server. String server (common) 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. String username (common) Required The username to login to openshift server. String bridgeErrorHandler (consumer) 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 or ERROR level and ignored. false boolean sendEmptyMessageWhenIdle (consumer) If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead. false boolean exceptionHandler (consumer) 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 exchangePattern (consumer) Sets the exchange pattern when the consumer creates an exchange. ExchangePattern pollStrategy (consumer) 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. PollingConsumerPoll Strategy application (producer) The application name to start, stop, restart, or get the state. String mode (producer) Whether to output the message body as a pojo or json. For pojo the message is a List type. String operation (producer) 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. String synchronous (advanced) Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). false boolean backoffErrorThreshold (scheduler) The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in. int backoffIdleThreshold (scheduler) The number of subsequent idle polls that should happen before the backoffMultipler should kick-in. int backoffMultiplier (scheduler) 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 actual attempt is happening again. When this option is in use then backoffIdleThreshold and/or backoffErrorThreshold must also be configured. int delay (scheduler) Milliseconds before the poll. You can also specify time values using units, such as 60s (60 seconds), 5m30s (5 minutes and 30 seconds), and 1h (1 hour). 500 long greedy (scheduler) If greedy is enabled, then the ScheduledPollConsumer will run immediately again, if the run polled 1 or more messages. false boolean initialDelay (scheduler) 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). 1000 long runLoggingLevel (scheduler) The consumer logs a start/complete log line when it polls. This option allows you to configure the logging level for that. TRACE LoggingLevel scheduledExecutorService (scheduler) Allows for configuring a custom/shared thread pool to use for the consumer. By default each consumer has its own single threaded thread pool. ScheduledExecutor Service scheduler (scheduler) To use a cron scheduler from either camel-spring or camel-quartz2 component none ScheduledPollConsumer Scheduler schedulerProperties (scheduler) To configure additional properties when using a custom scheduler or any of the Quartz2, Spring based scheduler. Map startScheduler (scheduler) Whether the scheduler should be auto started. true boolean timeUnit (scheduler) Time unit for initialDelay and delay options. MILLISECONDS TimeUnit useFixedDelay (scheduler) Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details. true boolean 248.3. Spring Boot Auto-Configuration The component supports 6 options, which are listed below. Name Description Default Type camel.component.openshift.domain Domain name. If not specified then the default domain is used. String camel.component.openshift.enabled Enable openshift component true Boolean camel.component.openshift.password The password for login to openshift server. String camel.component.openshift.resolve-property-placeholders Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. true Boolean camel.component.openshift.server 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. String camel.component.openshift.username The username to login to openshift server. String 248.4. Examples 248.4.1. 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. 248.4.2. 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 USD{header.CamelOpenShiftEventType} on application USD{body.name} changed state to USD{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. Header May be null Description 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 248.5. See Also Configuring Camel Component Endpoint Getting Started

Commands:
<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>
openshift:clientId[?options]
openshift:clientId
// sending route from("direct:apps") .to("openshift:myClient?username=foo&password=secret&operation=list"); .to("log:apps");
// stopping the foobar application from("direct:control") .to("openshift:myClient?username=foo&password=secret&operation=stop&application=foobar");
// trigger when state changes on our gears from("openshift:myClient?username=foo&password=secret&delay=30s") .log("Event USD{header.CamelOpenShiftEventType} on application USD{body.name} changed state to USD{header.CamelOpenShiftEventNewState}");