Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
fix(script): utilisation jbang
Browse files Browse the repository at this point in the history
ref: #12
  • Loading branch information
AntoineArthurG committed Jan 9, 2023
1 parent 0b65d02 commit a50ee05
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions route_java/TempsAttenteAgenceCamel.java
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();
}

}

0 comments on commit a50ee05

Please sign in to comment.