Este conteúdo não está disponível no idioma selecionado.
Chapter 3. Examples
The quickstart examples listed in the following table can be cloned or downloaded from the Camel Quarkus Examples Git repository.
Number of Examples: 2
Example | Description |
---|---|
Shows how to consume CSV files, marshal & unmarshal the data and send it onwards via FTP | |
Kafka example | Shows how to produce and consume messages in a Kafka topic, using Strimzi Operator |
3.1. Getting started with the file consumer quickstart example Copiar o linkLink copiado para a área de transferência!
You can download or clone the quickstarts from the Camel Quarkus Examples Git repository. The example is in the file-bindy-ftp
directory.
Extract the contents of the zip file or clone the repository to a local folder, for example a new folder named quickstarts
.
You can run this example in development mode on your local machine from the command line. Using development mode, you can iterate quickly on integrations in development and get fast feedback on your code. Please refer to the Development mode section of the Camel Quarkus User guide for more details.
If you need to configure container resource limits or enable the Quarkus Kubernetes client to trust self signed certificates, you can find these configuration options in the src/main/resources/application.properties
file.
Prerequisites
-
You have
cluster admin
access to the OpenShift cluster. -
You have access to an SFTP server and you have set the server properties (which are prefixed by
ftp
) in the application properties configuration file:src/main/resources/application.properties
.
Procedure
Use Maven to build the example application in development mode:
cd quickstarts/file-bindy-ftp mvn clean compile quarkus:dev
$ cd quickstarts/file-bindy-ftp $ mvn clean compile quarkus:dev
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The application triggers the timer component every 10 seconds, generates some random “books” data and creates a CSV file in a temporary directory with 100 entries. The following message is displayed in the console:
[route1] (Camel (camel-1) thread #3 - timer://generateBooks) Generating randomized books CSV data
[route1] (Camel (camel-1) thread #3 - timer://generateBooks) Generating randomized books CSV data
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Next, the CSV file is read by a file consumer and Bindy is used to marshal the individual data rows into Book objects:
[route2] (Camel (camel-1) thread #1 - file:///tmp/books) Reading books CSV data from 89A0EE24CB03A69-0000000000000000
[route2] (Camel (camel-1) thread #1 - file:///tmp/books) Reading books CSV data from 89A0EE24CB03A69-0000000000000000
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Next the collection of Book objects is split into individual items and is aggregated based on the genre property:
[route3] (Camel (camel-1) thread #0 - AggregateTimeoutChecker) Processed 34 books for genre 'Action' [route3] (Camel (camel-1) thread #0 - AggregateTimeoutChecker) Processed 31 books for genre 'Crime' [route3] (Camel (camel-1) thread #0 - AggregateTimeoutChecker) Processed 35 books for genre 'Horror'
[route3] (Camel (camel-1) thread #0 - AggregateTimeoutChecker) Processed 34 books for genre 'Action' [route3] (Camel (camel-1) thread #0 - AggregateTimeoutChecker) Processed 31 books for genre 'Crime' [route3] (Camel (camel-1) thread #0 - AggregateTimeoutChecker) Processed 35 books for genre 'Horror'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Finally, the aggregated book collections are unmarshalled back to CSV format and uploaded to the test FTP server.
[route4] (Camel (camel-1) thread #2 - seda://processed) Uploaded books-Action-89A0EE24CB03A69-0000000000000069.csv [route4] (Camel (camel-1) thread #2 - seda://processed) Uploaded books-Crime-89A0EE24CB03A69-0000000000000069.csv [route4] (Camel (camel-1) thread #2 - seda://processed) Uploaded books-Horror-89A0EE24CB03A69-0000000000000069.csv
[route4] (Camel (camel-1) thread #2 - seda://processed) Uploaded books-Action-89A0EE24CB03A69-0000000000000069.csv [route4] (Camel (camel-1) thread #2 - seda://processed) Uploaded books-Crime-89A0EE24CB03A69-0000000000000069.csv [route4] (Camel (camel-1) thread #2 - seda://processed) Uploaded books-Horror-89A0EE24CB03A69-0000000000000069.csv
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To run the application in JVM mode, enter the following commands:
mvn clean package -DskipTests java -jar target/*-runner.jar
$ mvn clean package -DskipTests $ java -jar target/*-runner.jar
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can build and deploy the example application to OpenShift, by entering the following command:
mvn clean package -DskipTests -Dquarkus.kubernetes.deploy=true
$ mvn clean package -DskipTests -Dquarkus.kubernetes.deploy=true
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check that the pods are running:
$oc get pods NAME READY STATUS RESTARTS AGE camel-quarkus-examples-file-bindy-ftp-1-d72mb 1/1 Running 0 5m15s ssh-server-deployment-5f6f685658-jtr9n 1/1 Running 0 5m28s
$oc get pods NAME READY STATUS RESTARTS AGE camel-quarkus-examples-file-bindy-ftp-1-d72mb 1/1 Running 0 5m15s ssh-server-deployment-5f6f685658-jtr9n 1/1 Running 0 5m28s
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Enter the following command to monitor the application log:
oc logs -f camel-quarkus-examples-file-bindy-ftp-5d48f4d85c-sjl8k
oc logs -f camel-quarkus-examples-file-bindy-ftp-5d48f4d85c-sjl8k
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Additional resources