lopushen opened a new pull request, #292: URL: https://github.com/apache/camel-karaf/pull/292
Fixes#291 **Motivation** During testing using an OSGI blueprint, it turned out that the camel-google-pubsub is missing bundles to successfully execute the route. **Modifications:** Add the missing bundles with appropriate SPI provide/consume statements To run google pubsub emulator: `docker run --rm -p 8085:8085 google/cloud-sdk:emulators /bin/bash -c "gcloud beta emulators pubsub start --project=test-project --host-port='0.0.0.0:8085'"` After launching the container we need to create a topic `curl --location --request PUT 'http://localhost:8085/v1/projects/test-project/topics/test-topic'` And we need to create a subscription ``` curl --location --request PUT 'http://localhost:8085/v1/projects/test-project/subscriptions/test-subscription' \ --header 'Content-Type: application/json' \ --data '{ "topic": "projects/test-project/topics/test-topic" }' ``` Install repo, blueprint and pubsub features on karaf: ``` repo-add mvn:org.apache.camel.karaf/apache-camel/4.5.0-SNAPSHOT/xml/features feature:install camel-blueprint camel-google-pubsub ``` Copy a file with the following xml to the deploy folder: ``` <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" xsi:schemaLocation=" http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd"> <bean id="google-pubsub" class="org.apache.camel.component.google.pubsub.GooglePubsubComponent"> <property name="endpoint" value="localhost:8085"/> <property name="authenticate" value="false"/> </bean> <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/blueprint"> <route id="pubsubSendRoute"> <from uri="timer:pubsubTimer?period=5000"/> <setBody> <constant>Hello, Google Pub/Sub!</constant> </setBody> <to uri="google-pubsub:test-project:test-topic"/> <log message="Sent message to Google Pub/Sub ${body}"/> </route> <route id="pubsubReceiveRoute"> <from uri="google-pubsub:test-project:test-subscription"/> <choice> <when> <simple>${body} != "Hello, Google Pub/Sub!"</simple> <log message="KO - not expected ${body}"/> <throwException exceptionType="java.lang.Exception" message="An unexpected body returned"/> </when> <otherwise> <log message="OK - Received message from Google Pub/Sub ${body}"/> </otherwise> </choice> </route> </camelContext> </blueprint> ``` After all the successful steps the following output should be visible: ``` 10:34:45.114 INFO [Camel (camel-1) thread #2 - timer://pubsubTimer] Sent message to Google Pub/Sub Hello, Google Pub/Sub! 10:34:45.141 INFO [Gax-209] OK - Received message from Google Pub/Sub Hello, Google Pub/Sub! 10:34:50.135 INFO [Camel (camel-1) thread #2 - timer://pubsubTimer] Sent message to Google Pub/Sub Hello, Google Pub/Sub! 10:34:50.147 INFO [Gax-204] OK - Received message from Google Pub/Sub Hello, Google Pub/Sub! 10:34:55.128 INFO [Camel (camel-1) thread #2 - timer://pubsubTimer] Sent message to Google Pub/Sub Hello, Google Pub/Sub! 10:34:55.135 INFO [Gax-210] OK - Received message from Google Pub/Sub Hello, Google Pub/Sub! 10:35:00.135 INFO [Camel (camel-1) thread #2 - timer://pubsubTimer] Sent message to Google Pub/Sub Hello, Google Pub/Sub! 10:35:00.137 INFO [Gax-207] OK - Received message from Google Pub/Sub Hello, Google Pub/Sub! 10:35:05.135 INFO [Camel (camel-1) thread #2 - timer://pubsubTimer] Sent message to Google Pub/Sub Hello, Google Pub/Sub! 10:35:05.158 INFO [Gax-205] OK - Received message from Google Pub/Sub Hello, Google Pub/Sub! ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
