1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.apache.camel.example.bam; |
18 |
|
|
19 |
|
import org.apache.camel.Exchange; |
20 |
|
import org.apache.camel.Processor; |
21 |
|
import org.apache.camel.bam.ActivityBuilder; |
22 |
|
import org.apache.camel.bam.ProcessBuilder; |
23 |
|
import org.apache.commons.logging.Log; |
24 |
|
import org.apache.commons.logging.LogFactory; |
25 |
|
|
26 |
|
import org.springframework.orm.jpa.JpaTemplate; |
27 |
|
import org.springframework.transaction.support.TransactionTemplate; |
28 |
|
|
29 |
|
import static org.apache.camel.builder.xml.XPathBuilder.xpath; |
30 |
|
import static org.apache.camel.util.Time.seconds; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
0 |
public class MyActivities extends ProcessBuilder { |
37 |
0 |
private static final Log LOG = LogFactory.getLog(MyActivities.class); |
38 |
|
|
39 |
|
protected MyActivities(JpaTemplate jpaTemplate, TransactionTemplate transactionTemplate) { |
40 |
0 |
super(jpaTemplate, transactionTemplate); |
41 |
0 |
} |
42 |
|
|
43 |
|
public void configure() throws Exception { |
44 |
|
|
45 |
|
|
46 |
0 |
ActivityBuilder purchaseOrder = activity("file:src/data/purchaseOrders?noop=true") |
47 |
|
.correlate(xpath("/purchaseOrder/@id")); |
48 |
|
|
49 |
0 |
ActivityBuilder invoice = activity("file:src/data/invoices?noop=true") |
50 |
|
.correlate(xpath("/invoice/@purchaseOrderId")); |
51 |
|
|
52 |
|
|
53 |
0 |
invoice.starts().after(purchaseOrder.completes()) |
54 |
|
.expectWithin(seconds(1)) |
55 |
|
.errorIfOver(seconds(2)).to("log:org.apache.camel.example.bam.BamFailures?level=error"); |
56 |
|
|
57 |
0 |
from("seda:failures").process(new Processor() { |
58 |
0 |
public void process(Exchange exchange) throws Exception { |
59 |
0 |
LOG.info("Failed process!: " + exchange + " with body: " + exchange.getIn().getBody()); |
60 |
0 |
} |
61 |
|
}); |
62 |
0 |
} |
63 |
|
}; |
64 |
|
|