Camel seminar for university course: System Integration with JBoss.
Please do the following steps to properly set your environment for this seminar.
# create directory for this seminar:
mkdir camel-seminar
cd camel-seminar
# put JBoss Fuse 6.2.0 GA to this directory
cp _PATH_/jboss-fuse-full-6.2.0.redhat-133.zip ./
# unzip JBoss Fuse 6.2.0 GA
unzip jboss-fuse-full-6.2.0.redhat-133.zip
# clone systems which will be integrated: https://github.com/qa/course-sys-int-systems
# you will need to start / restart these systems during seminar repeatedly, see Readme
git clone https://github.com/qa/course-sys-int-systems.git
# clone seminar sources: https://github.com/qa/course-sys-int-camel-seminar
git clone https://github.com/qa/course-sys-int-camel-seminar.git
Your directory structure should then be:
camel-seminar
|-- course-sys-int-camel-seminar
|-- course-sys-int-systems
|-- jboss-fuse-6.2.0.redhat-133
+-- jboss-fuse-full-6.2.0.redhat-133.zip
cd jboss-fuse-6.2.0.redhat-133
Add users to etc/users.properties
- Uncomment
admin=admin,admin,...
user - Add new user
shipuser=shippwd,admin
Configure ActiveMQ etc/activemq.xml
- Add
openwire+ssl
transportConnector, the resulting element will be:
<transportConnectors>
<transportConnector name="openwire" uri="tcp://${bindAddress}:${bindPort}"/>
<transportConnector name="openwire+ssl" uri="ssl://${bindAddress}:61617?maximumConnections=1000"/>
</transportConnectors>
- Set SSL context:
<sslContext>
<sslContext keyStore="file:${karaf.base}/bin/keystore.jks"
keyStorePassword="redhat"
trustStore="file:${karaf.base}/bin/keystore.jks"
trustStorePassword="redhat"/>
</sslContext>
You can see the final activemq.xml in camel-seminar/course-sys-int-camel-seminar/src/test/resources/activemq.xml
.
To force your IDE to format properly java camel routes, set:
- Indentation by spaces (4 spaces)
- Continuation content to 4 (default would be 8)
cd jboss-fuse-6.2.0.redhat-133
bin/fuse
https://github.com/qa/course-sys-int-systems
cd course-sys-int-systems
mvn clean camel:run
Note you will need to restart these systems to reset their state during tasks development.
This section describes how to run / test the integration middleware developed during seminar.
cd course-sys-int-camel-seminar
# run as standalone app
mvn clean camel:run
# unit tests
mvn clean test
# single test execution
mvn clean test -Dtest=_NAME_
First install bundle into local maven repository, without tests:
mvn clean install -DskipTests -P bundle
Once you have test bundle in local maven repo, you can run integration tests.
mvn clean integration-test -P bundle
The first install without test is kind of hack. It's because of this pax configuration entry:
bundle("mvn:com.redhat.brq.integration/camel-seminar/1.0.0-SNAPSHOT"),
You need to create bundle with your camel route, and deploy this bundle into fuse.
It can be achieved by creating bundle during test executin, like this example,
or by deploying bundle from mvn://
or file://
.
In case the tested route is single blueprint.xml, it could be deployed like this:
bundle("file://absolute/path/to/blueprint.xml")
PaxExam creates features.xml, adds it into featureurls (can be verified with features:listurl
).
Generated xml can be found in target/unpacked-fuse/<some hash>/test-dependencies.xml
.
<?xml version="1.0" encoding="UTF-8"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0" name="test-dependencies">
<feature name="test-dependencies">
<bundle>mvn:com.redhat.brq.integration/camel-seminar/1.0.0-SNAPSHOT</bundle>
</feature>
</features>
Build as bundle:
mvn clean install -DskipTests -P bundle
Switch to JBoss Fuse console.
You need to install some features before deployment:
features:install camel-http4
features:install camel-jackson
features:install camel-restlet
Then you need to set system property with path to file inbox/outbox folders:
system-property endpoint.file.baseUrl _PATH_/camel-seminar/course-sys-int-systems/target
Now you can install bundle from maven:
osgi:install -s mvn:com.redhat.brq.integration/camel-seminar/1.0.0-SNAPSHOT
{
"address" : {
"firstName" : "Jiri",
"lastName" : "Novak",
"street" : "Purkynova",
"city" : "Brno",
"zipCode" : "61200"
},
"items" : [
{
"articleId" : "6",
"count" : "1",
"unitPrice" : "4.4"
}
]
}
Change count
of article to produce inventory error.
Change unitPrice
to value > 10000 to produce accounting error.
Change city
to 'Gotham' to produce shipment error.
POST:
curl -X POST "localhost:8080/orders" --data '{"address":{"firstName":"Jiri","lastName":"Novak","street":"Purkynova","city":"Brno","zipCode":"61200"},"items":[{"articleId":"6","count":"1","unitPrice":"4.4"}]}' -v --header "ContentType:application/json" -v
GET:
curl -X GET "localhost:8080/orders/1" -v
Detailed description with steps and hints of each task is described in OrderProcessRoute
class.
branch: camel-00
This route saves new Order to repository, sets response headers and returns.
branch: camel-01
This route tries to find Order in repository.
branch: camel-02
This route set status of order to 'in process' and sends request to the Inventory system.
branch: camel-03
This route receives response from the Inventory system and handles when item cannot be reserved.
branch: camel-04
Handle the ItemNotReservedException
thrown in TASK 4. Write test to verify exception handling.
branch: camel-05
This route sends an order to Accounting systems and handles response.
branch: camel-06
Handle the InvalidAccountingException
thrown in TASK 6. Write test to verify exception handling.
branch: camel-07
This route sends an address of a order to the Shipment system.
branch: camel-08
Finish ReceiveShipmentRouteTest
for receive-shipment
route, see hints in the test class.
branch: camel-09
Finish IntegrationTest
class. How to run integration test is described in Running section.
Result is in branch camel-10
.