--- apiVersion: v1 kind: List items: - apiVersion: v1 kind: ConfigMap metadata: labels: funktion.fabric8.io/kind: Connector provider: fabric8 project: connector-apns version: 1.1.20 group: io.fabric8.funktion.connector name: apns data: deployment.yml: | --- apiVersion: extensions/v1beta1 kind: Deployment metadata: labels: funktion.fabric8.io/kind: Subscription connector: apns spec: replicas: 1 template: metadata: labels: funktion.fabric8.io/kind: Subscription connector: apns spec: containers: - image: fabric8/connector-apns:1.1.20 name: connector schema.yml: | --- component: kind: component scheme: apns syntax: apns:name title: APNS description: For sending notifications to Apple iOS devices. label: eventbus,mobile deprecated: false async: false javaType: org.apache.camel.component.apns.ApnsComponent groupId: org.apache.camel artifactId: camel-apns version: 2.18.1 componentProperties: apnsService: kind: property type: object javaType: com.notnoop.apns.ApnsService deprecated: false secret: false description: To use a custom link ApnsService properties: name: kind: path group: common type: string javaType: java.lang.String deprecated: false secret: false description: Name of the endpoint tokens: kind: parameter group: common type: string javaType: java.lang.String deprecated: false secret: false description: Configure this property in case you want to statically declare tokens related to devices you want to notify. Tokens are separated by comma. bridgeErrorHandler: kind: parameter group: consumer label: consumer type: boolean javaType: boolean optionalPrefix: consumer. deprecated: false secret: false defaultValue: false description: 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: kind: parameter group: consumer label: consumer type: boolean javaType: boolean optionalPrefix: consumer. deprecated: false secret: false defaultValue: false description: If the polling consumer did not poll any files you can enable this option to send an empty message (no body) instead. exceptionHandler: kind: parameter group: consumer (advanced) label: consumer,advanced type: object javaType: org.apache.camel.spi.ExceptionHandler optionalPrefix: consumer. deprecated: false secret: false description: 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: kind: parameter group: consumer (advanced) label: consumer,advanced type: string javaType: org.apache.camel.ExchangePattern enum: - InOnly - RobustInOnly - InOut - InOptionalOut - OutOnly - RobustOutOnly - OutIn - OutOptionalIn deprecated: false secret: false description: Sets the exchange pattern when the consumer creates an exchange. pollStrategy: kind: parameter group: consumer (advanced) label: consumer,advanced type: object javaType: org.apache.camel.spi.PollingConsumerPollStrategy optionalPrefix: consumer. deprecated: false secret: false description: 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. synchronous: kind: parameter group: advanced label: advanced type: boolean javaType: boolean deprecated: false secret: false defaultValue: false description: Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). backoffErrorThreshold: kind: parameter group: scheduler label: consumer,scheduler type: integer javaType: int optionalPrefix: consumer. deprecated: false secret: false description: The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in. backoffIdleThreshold: kind: parameter group: scheduler label: consumer,scheduler type: integer javaType: int optionalPrefix: consumer. deprecated: false secret: false description: The number of subsequent idle polls that should happen before the backoffMultipler should kick-in. backoffMultiplier: kind: parameter group: scheduler label: consumer,scheduler type: integer javaType: int optionalPrefix: consumer. deprecated: false secret: false description: 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: kind: parameter group: scheduler label: consumer,scheduler type: integer javaType: long optionalPrefix: consumer. deprecated: false secret: false defaultValue: "500" description: 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: kind: parameter group: scheduler label: consumer,scheduler type: boolean javaType: boolean optionalPrefix: consumer. deprecated: false secret: false defaultValue: false description: If greedy is enabled then the ScheduledPollConsumer will run immediately again if the previous run polled 1 or more messages. initialDelay: kind: parameter group: scheduler label: consumer,scheduler type: integer javaType: long optionalPrefix: consumer. deprecated: false secret: false defaultValue: "1000" description: 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: kind: parameter group: scheduler label: consumer,scheduler type: string javaType: org.apache.camel.LoggingLevel enum: - TRACE - DEBUG - INFO - WARN - ERROR - OFF optionalPrefix: consumer. deprecated: false secret: false defaultValue: TRACE description: The consumer logs a start/complete log line when it polls. This option allows you to configure the logging level for that. scheduledExecutorService: kind: parameter group: scheduler label: consumer,scheduler type: object javaType: java.util.concurrent.ScheduledExecutorService optionalPrefix: consumer. deprecated: false secret: false description: 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: kind: parameter group: scheduler label: consumer,scheduler type: string javaType: org.apache.camel.spi.ScheduledPollConsumerScheduler enum: - none - spring - quartz2 optionalPrefix: consumer. deprecated: false secret: false defaultValue: none description: To use a cron scheduler from either camel-spring or camel-quartz2 component schedulerProperties: kind: parameter group: scheduler label: consumer,scheduler type: object javaType: java.util.Map prefix: scheduler. multiValue: true deprecated: false secret: false description: To configure additional properties when using a custom scheduler or any of the Quartz2 Spring based scheduler. startScheduler: kind: parameter group: scheduler label: consumer,scheduler type: boolean javaType: boolean optionalPrefix: consumer. deprecated: false secret: false defaultValue: true description: Whether the scheduler should be auto started. timeUnit: kind: parameter group: scheduler label: consumer,scheduler type: string javaType: java.util.concurrent.TimeUnit enum: - NANOSECONDS - MICROSECONDS - MILLISECONDS - SECONDS - MINUTES - HOURS - DAYS optionalPrefix: consumer. deprecated: false secret: false defaultValue: MILLISECONDS description: Time unit for initialDelay and delay options. useFixedDelay: kind: parameter group: scheduler label: consumer,scheduler type: boolean javaType: boolean optionalPrefix: consumer. deprecated: false secret: false defaultValue: true description: Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details. documentation.adoc: |+ [[APNS-ApnsComponent]] Apns Component ~~~~~~~~~~~~~~ *Available as of Camel 2.8* The *apns* component is used for sending notifications to iOS devices. The apns components use https://github.com/notnoop/java-apns[javapns] library. + The component supports sending notifications to Apple Push Notification Servers (APNS) and consuming feedback from the servers. The consumer is configured with 3600 seconds for polling by default because it is a best practice to consume feedback stream from Apple Push Notification Servers only from time to time. For example: every 1 hour to avoid flooding the servers. The feedback stream gives informations about inactive devices. You only need to get this informations every some hours if your mobile application is not a heavily used one. Maven users will need to add the following dependency to their `pom.xml` for this component: [source,xml] ------------------------------------------------------------ org.apache.camel camel-apns x.x.x ------------------------------------------------------------ [[APNS-URIformat]] URI format ^^^^^^^^^^ To send notifications: [source,java] --------------------- apns:notify[?options] --------------------- To consume feedback: [source,java] ----------------------- apns:consumer[?options] ----------------------- [[APNS-Options]] Options ^^^^^^^ // component options: START The APNS component supports 1 options which are listed below. {% raw %} [width="100%",cols="2,1m,7",options="header"] |======================================================================= | Name | Java Type | Description | apnsService | ApnsService | To use a custom link ApnsService |======================================================================= {% endraw %} // component options: END // endpoint options: START The APNS component supports 21 endpoint options which are listed below: {% raw %} [width="100%",cols="2,1,1m,1m,5",options="header"] |======================================================================= | Name | Group | Default | Java Type | Description | name | common | | String | Name of the endpoint | tokens | common | | String | Configure this property in case you want to statically declare tokens related to devices you want to notify. Tokens are separated by comma. | 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. | 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 %} // endpoint options: END You can append query options to the URI in the following format, `?option=value&option=value&...` [[APNS-Component]] Component +++++++++ The `ApnsComponent` must be configured with a `com.notnoop.apns.ApnsService`. The service can be created and configured using the `org.apache.camel.component.apns.factory.ApnsServiceFactory`. See further below for an example. And as well in the https://svn.apache.org/repos/asf/camel/trunk/components/camel-apns/[test source code]. [[APNS-Exchangedataformat]] Exchange data format ^^^^^^^^^^^^^^^^^^^^ When Camel will fetch feedback data corresponding to inactive devices, it will retrieve a List of InactiveDevice objects. Each InactiveDevice object of the retrieved list will be setted as the In body, and then processed by the consumer endpoint. [[APNS-MessageHeaders]] Message Headers ^^^^^^^^^^^^^^^ Camel Apns uses these headers. [width="100%",cols="10%,10%,80%",options="header",] |======================================================================= |Property |Default |Description |`CamelApnsTokens` | |Empty by default. |`CamelApnsMessageType` |`STRING, PAYLOAD, APNS_NOTIFICATION`?? |In case you choose PAYLOAD for the message type, then the message will be considered as a APNS payload and sent as is. In case you choose STRING, message will be converted as a APNS payload. From *Camel 2.16* onwards APNS_NOTIFICATION is used for sending message body as com.notnoop.apns.ApnsNotification types. |======================================================================= [[APNS-ApnsServiceFactorybuildercallback]] ApnsServiceFactory builder callback ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ApnsServiceFactory` comes with the empty callback method that could be used to configure (or even replace) the default `ApnsServiceBuilder` instance. The signature of the method could look as follows: [source,java] ---------------------------------------------------------------------------------------- protected ApnsServiceBuilder configureServiceBuilder(ApnsServiceBuilder serviceBuilder); ---------------------------------------------------------------------------------------- And could be used like as follows: [source,java] ------------------------------------------------------------------------------------------- ApnsServiceFactory proxiedApnsServiceFactory = new ApnsServiceFactory(){ ?? @Override protected ApnsServiceBuilder configureServiceBuilder(ApnsServiceBuilder serviceBuilder) { return serviceBuilder.withSocksProxy("my.proxy.com", 6666); } }; ------------------------------------------------------------------------------------------- [[APNS-Samples]] Samples ^^^^^^^ [[APNS-CamelXmlroute]] Camel Xml route +++++++++++++++ [source,xml] -------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------- [[APNS-CamelJavaroute]] Camel Java route ++++++++++++++++ [[APNS-Createcamelcontextanddeclareapnscomponentprogrammatically]] Create camel context and declare apns component programmatically [source,java] ---------------------------------------------------------------------------------- protected CamelContext createCamelContext() throws Exception { CamelContext camelContext = super.createCamelContext(); ApnsServiceFactory apnsServiceFactory = new ApnsServiceFactory(); apnsServiceFactory.setCertificatePath("classpath:/certificate.p12"); apnsServiceFactory.setCertificatePassword("MyCertPassword"); ApnsService apnsService = apnsServiceFactory.getApnsService(camelContext); ApnsComponent apnsComponent = new ApnsComponent(apnsService); camelContext.addComponent("apns", apnsComponent); return camelContext; } ---------------------------------------------------------------------------------- [[APNS-ApnsProducer-iOStargetdevicedynamicallyconfiguredviaheader:"CamelApnsTokens"]] ApnsProducer - iOS target device dynamically configured via header: `"CamelApnsTokens"` [source,java] --------------------------------------------------------------------------------------- protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() throws Exception { from("direct:test") .setHeader(ApnsConstants.HEADER_TOKENS, constant(IOS_DEVICE_TOKEN)) .to("apns:notify"); } } } --------------------------------------------------------------------------------------- [[APNS-ApnsProducer-iOStargetdevicestaticallyconfiguredviauri]] ApnsProducer - iOS target device statically configured via uri [source,java] ------------------------------------------------------------------ protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() throws Exception { from("direct:test"). to("apns:notify?tokens=" + IOS_DEVICE_TOKEN); } }; } ------------------------------------------------------------------ [[APNS-ApnsConsumer]] ApnsConsumer [source,java] -------------------------------------------------------------------------- from("apns:consumer?initialDelay=10&delay=3600&timeUnit=SECONDS") .to("log:com.apache.camel.component.apns?showAll=true&multiline=true") .to("mock:result"); -------------------------------------------------------------------------- [[APNS-SeeAlso]] See Also ^^^^^^^^ * http://camel.apache.org/component.html[Component] * http://camel.apache.org/endpoint.html[Endpoint] * http://blog.xebia.fr/2010/09/30/creer-un-composant-apache-camel-de-connexion-a-lapns-1-sur-3/[Blog about using APNS (in french)]