all
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package id.co.iconpln.apkt.data309.schedule;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.util.Base64;
|
||||
import io.quarkus.scheduler.Scheduled;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
|
||||
@ApplicationScoped
|
||||
|
||||
public class MyScheduledBean {
|
||||
// every month at day 7 on 23.59
|
||||
@Scheduled(cron = "0 59 23 7 * ?")
|
||||
void scheduleCron() throws Exception {
|
||||
HttpClient client = HttpClient.newHttpClient();
|
||||
// Username and password for basic authentication
|
||||
// String username = "apkt";
|
||||
// String password = "apkt@54321";
|
||||
|
||||
// Combine username and password for basic authentication
|
||||
// String auth = username + ":" + password;
|
||||
|
||||
// Encode the combined string with Base64
|
||||
// String encodedAuth = Base64.getEncoder().encodeToString(auth.getBytes());
|
||||
|
||||
// Add the Authorization header with Basic auth to the request
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
// .header("Authorization", "Basic " + encodedAuth)
|
||||
.uri(URI.create("http://10.14.212.9:32184/data309/sinkron"))
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
System.out.println("Scheduled task executed successfully");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user