This repository has been archived by the owner on Sep 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
32 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
// camel-k: language=java | ||
///usr/bin/env jbang "$0" "$@" ; exit $? | ||
// Use org.apache.camel:camel-bom:3.19.0@pom in order to avoid repeating the version in each line | ||
//DEPS org.apache.camel:camel-core:3.19.0 | ||
//DEPS org.apache.camel:camel-main:3.19.0 | ||
//DEPS org.apache.camel:camel-stream:3.19.0 | ||
//DEPS org.apache.camel:camel-http:3.19.0 | ||
//DEPS org.apache.camel:camel-jackson:3.19.0 | ||
|
||
import org.apache.camel.main.Main; | ||
import org.apache.camel.*; | ||
import org.apache.camel.builder.*; | ||
import org.apache.camel.main.*; | ||
import org.apache.camel.model.dataformat.JsonLibrary; | ||
|
||
import org.apache.camel.CamelContext; | ||
import org.apache.camel.builder.RouteBuilder; | ||
import org.apache.camel.impl.DefaultCamelContext; | ||
import static java.lang.System.*; | ||
|
||
public class TempsAttenteAgenceCamel { | ||
|
||
public static void main() throws Exception { | ||
try (CamelContext camel = new DefaultCamelContext()) { | ||
|
||
camel.addRoutes(new TempsAttenteRouteBuilder()); | ||
camel.start(); | ||
} | ||
catch (Exception e) { | ||
|
||
System.out.println("L'erreur suivante a été soulevé : " + e.toString()); | ||
|
||
} | ||
} | ||
|
||
public static class TempsAttenteRouteBuilder extends RouteBuilder { | ||
@Override | ||
public void configure() { | ||
from("timer://foo?period=5000") | ||
.to("http:8080://temps-attente/agence/4161") | ||
.log("The body was - ${body}"); | ||
|
||
/* from("timer:mytimer?repeatCount=1") | ||
.setBody(simple("${null}")) | ||
.setHeader("agence", constant("4161")) | ||
.toD("localhost:8080/temps-attente/agence/${header.agence}" + "?httpMethod=GET") | ||
.log("The body was - ${body}"); */ | ||
} | ||
public static void main(String... args) throws Exception { | ||
out.println("Hello World"); | ||
out.println("Running camel route..."); | ||
|
||
Main main = new Main(); | ||
|
||
// Configuration de la route | ||
main.configure().addRoutesBuilder(new RouteBuilder() { | ||
public void configure() throws Exception { | ||
from("timer://foo?period=5000") | ||
.to("http://localhost:8080/temps-attente/agences") | ||
.unmarshal().json(JsonLibrary.Jackson) | ||
.process(exchange -> { | ||
// On print la réponse | ||
out.println(exchange.getIn().getBody()); | ||
}); | ||
|
||
} | ||
}); | ||
main.run(); | ||
} | ||
|
||
} |