Skip to content

docs: Implementation of Java DSL Cookbook#394

Open
domhanak wants to merge 35 commits into
quarkiverse:mainfrom
domhanak:issue-393
Open

docs: Implementation of Java DSL Cookbook#394
domhanak wants to merge 35 commits into
quarkiverse:mainfrom
domhanak:issue-393

Conversation

@domhanak
Copy link
Copy Markdown
Contributor

@domhanak domhanak commented Apr 1, 2026

Closes #393

Based on https://docs.quarkiverse.io/quarkus-flow/dev/quarkus-flow-cookbook.html#

Here is the Java version of the cookbook.

@ricardozanini @mcruzdev @fjtirado Putting it up for first feedback round, in the meantime I will work on reviewing the test coverage for these examples.
Once done I will get back to you, right now looking for feedback if this is what is expected to be here.
Also please list out what other cases to add. 🙏

Comment thread docs/modules/ROOT/pages/quarkus-flow-java-cookbook.adoc Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 1, 2026

😭 Deploy PR Preview failed.

Comment thread docs/modules/ROOT/pages/quarkus-flow-java-cookbook.adoc Outdated
Copy link
Copy Markdown
Member

@ricardozanini ricardozanini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice write-up! Either for this cookbook and the YAML one, we must add tests within the docs module. So we guarantee we are not diverting our audience with wrong examples.

Feel free to also open issues on the points I made that are not working as it should.

Comment thread docs/modules/ROOT/pages/quarkus-flow-java-cookbook.adoc Outdated
Comment thread docs/modules/ROOT/pages/quarkus-flow-java-cookbook.adoc Outdated
Comment thread docs/modules/ROOT/pages/quarkus-flow-java-cookbook.adoc Outdated
Comment thread docs/modules/ROOT/pages/quarkus-flow-java-cookbook.adoc Outdated
Comment thread docs/modules/ROOT/pages/quarkus-flow-java-cookbook.adoc Outdated
Comment thread docs/modules/ROOT/pages/quarkus-flow-java-cookbook.adoc Outdated
Comment thread docs/modules/ROOT/pages/quarkus-flow-java-cookbook.adoc Outdated
Comment thread docs/modules/ROOT/pages/quarkus-flow-java-cookbook.adoc Outdated
Comment thread docs/modules/ROOT/pages/quarkus-flow-java-cookbook.adoc Outdated
Comment thread docs/modules/ROOT/pages/quarkus-flow-java-cookbook.adoc Outdated
@domhanak
Copy link
Copy Markdown
Contributor Author

domhanak commented Apr 8, 2026

@ricardozanini okay, to update the status.

I working on updating the docs module so it also runs the tests. It seems it has an issue right now and that prevents the tests from being run properly. Also they are not run during the regular maven build.

The idea will be as follows:

I will add workflow classes for each of the Java DSL example.
These classes will be included in the Cookbook page via include
I will add a test class that will execute these workflow classes and assert expected output/behavior.

@ricardozanini
Copy link
Copy Markdown
Member

@domhanak need help to figure it out the issue?

@domhanak
Copy link
Copy Markdown
Contributor Author

@ricardozanini not sure I understand your question? Care to elaborate please?

@ricardozanini
Copy link
Copy Markdown
Member

@ricardozanini not sure I understand your question? Care to elaborate please?

Just asking if you need any help to solve the issues you may have.

@domhanak
Copy link
Copy Markdown
Contributor Author

domhanak commented Apr 12, 2026

@ricardozanini no worries so far, just need to finish it all the way so I know where we are at. :) Halfway there, working on for example and testing now. Also, I need to rebase and fix the build.

@domhanak domhanak force-pushed the issue-393 branch 2 times, most recently from 71aa47b to d5dcd6c Compare April 13, 2026 07:28
@domhanak domhanak marked this pull request as ready for review April 13, 2026 11:17
@domhanak domhanak requested a review from a team as a code owner April 13, 2026 11:17
@domhanak
Copy link
Copy Markdown
Contributor Author

@ricardozanini Let's say the first part is done, there are still some missing but they have a different approach and can't use import io.serverlessworkflow.fluent.func.FuncWorkflowBuilder; but need to use import static io.serverlessworkflow.fluent.spec.WorkflowBuilder.workflow; with DoTaskBuilder to show raise and tryCatch

Not sure if this is expected or these methoed should also be present in FuncDoTaskBuilder.

@domhanak
Copy link
Copy Markdown
Contributor Author

domhanak commented Apr 13, 2026

4 Items missing:

  • Consolidation of the tests into one test suite. Having multiple small tests with @QuarkusTest annotation is probably not the best.
  • Configure the tests to run as part of mvn build.
  • Review the cookbook and add required properties that are relevant for the examples ( eventing, scheduler etc.)
  • Review the examples and figure out if they uncover bugs, or the implementation is wrong.

Comment thread docs/modules/ROOT/examples/org/acme/CronWorkflow.java Outdated
Comment thread docs/modules/ROOT/examples/org/acme/ConditionalWorkflow.java
Copy link
Copy Markdown
Member

@mcruzdev mcruzdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing pull request @domhanak, I left simple comments about the comments in the documentation.

Comment thread docs/modules/ROOT/examples/org/acme/ForEachWorkflow.java Outdated
Comment thread docs/modules/ROOT/examples/org/acme/OpenApiWorkflow.java Outdated
@ricardozanini
Copy link
Copy Markdown
Member

@ricardozanini Let's say the first part is done, there are still some missing but they have a different approach and can't use import io.serverlessworkflow.fluent.func.FuncWorkflowBuilder; but need to use import static io.serverlessworkflow.fluent.spec.WorkflowBuilder.workflow; with DoTaskBuilder to show raise and tryCatch

Not sure if this is expected or these methoed should also be present in FuncDoTaskBuilder.

Either WorkflowBuilder or FuncWorkflowBuilder will work, but the preferred approach is to use FuncWorkflowBuilder with FuncDSL.

@domhanak
Copy link
Copy Markdown
Contributor Author

domhanak commented Apr 24, 2026

@ricardozanini @mcruzdev Imho we could proceed with merging this and work on next in new issue.

I reported the follow-up - #487

Note: the tests are not being executed right now - I am running the locally via IDE, I think it would be better to ensure that as separate issue once the cookbook is finished. Reported here - #488

Let me know if this is ok.

@domhanak
Copy link
Copy Markdown
Contributor Author

One thing, that struck me now, is if we should add application.properties configurations to the examples where it is needed? Wdyt? @ricardozanini @mcruzdev

@ricardozanini
Copy link
Copy Markdown
Member

One thing, that struck me now, is if we should add application.properties configurations to the examples where it is needed? Wdyt? @ricardozanini @mcruzdev

When an application.property is needed? If so, yes we should add an excerpt of it.

Copy link
Copy Markdown
Member

@ricardozanini ricardozanini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's outstanding work! Many thanks!

Comment thread docs/modules/ROOT/examples/org/acme/ContextWorkflow.java Outdated
Comment thread docs/modules/ROOT/examples/org/acme/ParallelWorkflowBranch.java Outdated
Comment thread docs/modules/ROOT/pages/quarkus-flow-java-cookbook.adoc Outdated
Comment thread docs/modules/ROOT/pages/quarkus-flow-java-cookbook.adoc Outdated
Comment thread docs/modules/ROOT/pages/quarkus-flow-java-cookbook.adoc Outdated
Comment thread docs/src/main/resources/application.properties
@domhanak
Copy link
Copy Markdown
Contributor Author

@mcruzdev @ricardozanini updated with new addition to SDK, please squash if merging.

@Override
public Map<String, String> start() {
// Start WireMock on the fixed port expected by the example workflows
wireMockServer = new WireMockServer(8089);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
wireMockServer = new WireMockServer(8089);
WireMockConfiguration config = WireMockConfiguration.wireMockConfig().dynamicPort();
wireMockServer = new WireMockServer(config);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And you will probably have to change how Quarkus reads this port like:

  return Map.of("wiremock.port", String.valueOf(wireMockServer.port()));

Then use it in the endpoint:

  .endpoint("http://localhost:${wiremock.port}/api/people")

We run tests in parallel in many instances.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, however this is not really a problem now as docs module is skipping tests. I can update here or in the follow-up that specifically aims to make these updates.

public Map<String, String> start() {
// 1. Enable WireMock's built-in verbose logging using ConsoleNotifier
WireMockConfiguration config = WireMockConfiguration.wireMockConfig()
.port(8090)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.port(8090)
..dynamicPort()


@Inject
@Identifier("flow:echo-name") // namespace:name from document section
@Identifier("company:echo-name") // namespace:name from document section
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has the YAML referenced by this bean also changed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the YAML is fine, I just adapted the test so it works.

WorkflowDefinition cronFlowDefinition;

@Test
void testCronWorkflow() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not awaitability?

  await().atMost(5, TimeUnit.SECONDS)
         .untilAsserted(() ->
             assertThat(cronFlowDefinition.scheduledInstances().size()).isGreaterThan(2)
         );

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, can do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: Implementation of Java DSL Cookbook

3 participants