...
- the child src/data/purchaseOrders directory for XML purchase orders
- the child _ src/data/invoices directory for XML invoices
The MyActivities class defines the BAM activities; that is
- the input sources (the two directories above) which could be any of the supported camel URIs
- how the activities relate to each other - namely the Correlation Identifier pattern
- the maixmum amount of time allowed from the time a purchase order is received when if an invoice is not received an error should be raised.
The there There is the also a spring configuration file in src/resources/META-INF/services/camel-context.xml which defines the JPA template EntityManagerFactory
and tells Camel to look in the org.apache.camel.example.bam package to find its routes.
...
So lets start with the activities definition in MyActivities
Wiki Markup |
---|
{snippet:id=exampledemo|lang=java|url=activemq/camel/trunk/examples/camel-example-bam/src/main/java/org/apache/camel/example/bam/MyActivities.java} |
...
- the URIs of the inputs (which could come from any of the Camel Components
- the Correlation Identifier used to correlate together the purchase order and invoice messages which can be any Expression via any of the Languages Supported. In this case we are using XPath.
Then the final line of code defines the temporal rules to use; namely that it is considered to be an error if an invoice is not received within 2 seconds of a purchase order being received. When a failure occurs in this example we just send it to the Log component to log out an error level message to commons-logging / log4j. You could change this to use some of the other Components such as ActiveMQ, JMS, IRC, Mail, XMPP etc.
...
To run the example we use the Camel Maven Plugin. For example from the source or binary distribution the following should work
Code Block |
---|
cd examples/camel-example-bam
mvn camel:run
|
If you prefer you can just run the Main directly using
Code Block |
---|
mvn compile exec:java
|
Failing that you can run the Main from inside your IDE if you prefer. Follow the Building instructions to create an Eclipse/IDEA project to import