Skip to content
Snippets Groups Projects
Commit 13b51cd1 authored by Damien MARCHAT's avatar Damien MARCHAT
Browse files

Commented parts in the signal exercise that would not compile during working on day 1 exercises

parent 8e0bd9ec
Branches
No related tags found
No related merge requests found
package io.takima.temporalpractice.signals;
@ActivityInterface
// TODO : remove comments when starting the mastering signals exercise
//@ActivityInterface
public interface InventoryActivity {
void reserve(ConsumeSignal input);
......
package io.takima.temporalpractice.signals;
@WorkflowInterface
// TODO : remove comments when starting the mastering signals exercise
//@WorkflowInterface
public interface InventoryWorkflow {
@WorkflowMethod
// @WorkflowMethod
void run();
@SignalMethod
// @SignalMethod
void reserve(ConsumeSignal input);
}
package io.takima.temporalpractice.signals;
// TODO : remove comments when starting the mastering signals exercise
//import io.temporal.client.WorkflowClient;
//import io.temporal.client.WorkflowOptions;
import static io.takima.temporalpractice.temporal.TemporalUtils.*;
import static io.takima.temporalpractice.temporal.TemporalQueues.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
//import static io.takima.temporalpractice.temporal.TemporalUtils.*;
//import static io.takima.temporalpractice.temporal.TemporalQueues.*;
public class MSMain {
// Our inventory will contain 100 elements and we will send 100 signals, lets see how it goes
static int inventoryToDecrement = 100;
public static void main(String[] args) {
var worker = FACTORY.newWorker(MASTERING_SIGNALS);
worker.registerActivitiesImplementations(new InventoryActivityImpl(inventoryToDecrement));
worker.registerWorkflowImplementationTypes(InventoryWorkflowImpl.class);
// var worker = FACTORY.newWorker(MASTERING_SIGNALS);
// worker.registerActivitiesImplementations(new InventoryActivityImpl(inventoryToDecrement));
// worker.registerWorkflowImplementationTypes(InventoryWorkflowImpl.class);
FACTORY.start();
// FACTORY.start();
var workflow = CLIENT.newWorkflowStub(
InventoryWorkflow.class,
WorkflowOptions.newBuilder().setTaskQueue(MASTERING_SIGNALS).setWorkflowId("inventory").build()
);
WorkflowClient.start(workflow::run);
// var workflow = CLIENT.newWorkflowStub(
// InventoryWorkflow.class,
// WorkflowOptions.newBuilder().setTaskQueue(MASTERING_SIGNALS).setWorkflowId("inventory").build()
// );
// WorkflowClient.start(workflow::run);
try (ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor()) {
// Submit 100 tasks
for (int i = 1; i < inventoryToDecrement; i++) {
executor.submit(() -> {
workflow.reserve(new ConsumeSignal(1));
// workflow.reserve(new ConsumeSignal(1));
});
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment