Skip to content

Commit 2ae69bc

Browse files
authored
update springboot camel sample (#618)
Signed-off-by: Tihomir Surdilovic <tihomir@temporal.io>
1 parent 01b6ba1 commit 2ae69bc

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

springboot/src/main/java/io/temporal/samples/springboot/camel/CamelRoutes.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
public class CamelRoutes extends RouteBuilder {
3030

3131
@Autowired private WorkflowClient workflowClient;
32+
@Autowired OrderRepository repository;
3233

3334
@Override
3435
public void configure() {
@@ -47,5 +48,13 @@ public void configure() {
4748
exchange.getIn().setBody(workflow.start());
4849
})
4950
.end();
51+
52+
from("direct:findAllOrders")
53+
.routeId("direct-findAllOrders")
54+
.process(
55+
exchange -> {
56+
exchange.getIn().setBody(repository.findAll());
57+
})
58+
.end();
5059
}
5160
}

springboot/src/main/java/io/temporal/samples/springboot/camel/OrderActivityImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,22 @@
2121

2222
import io.temporal.spring.boot.ActivityImpl;
2323
import java.util.List;
24+
import org.apache.camel.ProducerTemplate;
2425
import org.springframework.beans.factory.annotation.Autowired;
2526
import org.springframework.stereotype.Component;
2627

2728
@Component
2829
@ActivityImpl(taskQueues = "CamelSampleTaskQueue")
2930
public class OrderActivityImpl implements OrderActivity {
3031

31-
@Autowired OrderRepository repository;
32+
@Autowired private ProducerTemplate producerTemplate;
3233

3334
@Override
3435
public List<OfficeOrder> getOrders() {
35-
return repository.findAll();
36+
producerTemplate.start();
37+
List<OfficeOrder> orders =
38+
producerTemplate.requestBody("direct:findAllOrders", null, List.class);
39+
producerTemplate.stop();
40+
return orders;
3641
}
3742
}

springboot/src/main/java/io/temporal/samples/springboot/camel/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88

99
http://localhost:3030/orders
1010

11-
This sample starts an Apache Camel route which runs our orders Workflow.
12-
Results of the workflow are returned by the Camel route
11+
This sample starts an Apache Camel route which starts our orders Workflow.
12+
The workflow starts an activity which starts Camel route to get all orders JPA.

0 commit comments

Comments
 (0)