Skip to content

Commit

Permalink
update springboot camel sample (#618)
Browse files Browse the repository at this point in the history
Signed-off-by: Tihomir Surdilovic <[email protected]>
  • Loading branch information
tsurdilo authored May 5, 2024
1 parent 01b6ba1 commit 2ae69bc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
public class CamelRoutes extends RouteBuilder {

@Autowired private WorkflowClient workflowClient;
@Autowired OrderRepository repository;

@Override
public void configure() {
Expand All @@ -47,5 +48,13 @@ public void configure() {
exchange.getIn().setBody(workflow.start());
})
.end();

from("direct:findAllOrders")
.routeId("direct-findAllOrders")
.process(
exchange -> {
exchange.getIn().setBody(repository.findAll());
})
.end();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,22 @@

import io.temporal.spring.boot.ActivityImpl;
import java.util.List;
import org.apache.camel.ProducerTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@ActivityImpl(taskQueues = "CamelSampleTaskQueue")
public class OrderActivityImpl implements OrderActivity {

@Autowired OrderRepository repository;
@Autowired private ProducerTemplate producerTemplate;

@Override
public List<OfficeOrder> getOrders() {
return repository.findAll();
producerTemplate.start();
List<OfficeOrder> orders =
producerTemplate.requestBody("direct:findAllOrders", null, List.class);
producerTemplate.stop();
return orders;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

http://localhost:3030/orders

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

0 comments on commit 2ae69bc

Please sign in to comment.