Skip to content

Conversation

@tsurdilo
Copy link
Contributor

@tsurdilo tsurdilo commented Jul 9, 2025

Packet delivery sample - runs multiple packet deliveries paths async within same execution

Signed-off-by: Tihomir Surdilovic <[email protected]>
@tsurdilo tsurdilo requested review from a team and antmendoza as code owners July 9, 2025 21:57
tsurdilo added 4 commits July 9, 2025 18:00
Signed-off-by: Tihomir Surdilovic <[email protected]>
Signed-off-by: Tihomir Surdilovic <[email protected]>
Signed-off-by: Tihomir Surdilovic <[email protected]>
Signed-off-by: Tihomir Surdilovic <[email protected]>
@tsurdilo tsurdilo changed the title [WIP] Async package delivery sample Async package delivery sample Jul 12, 2025
tsurdilo added 6 commits July 12, 2025 13:29
Signed-off-by: Tihomir Surdilovic <[email protected]>
Signed-off-by: Tihomir Surdilovic <[email protected]>
Signed-off-by: Tihomir Surdilovic <[email protected]>
Signed-off-by: Tihomir Surdilovic <[email protected]>
Signed-off-by: Tihomir Surdilovic <[email protected]>
Signed-off-by: Tihomir Surdilovic <[email protected]>
Copy link
Member

@antmendoza antmendoza left a comment

Choose a reason for hiding this comment

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

Thanks @tsurdilo

Having different paths within the same workflow (rather than child workflows) makes it difficult to understand what is happening to each parcel in the UI. Perhaps activity.summary could help with this

```

Run sample multiple times to see different scenarios (delivery failure and retry and delivery cancelation)
There is a 10% chance delivery is going to be canceled and 20% chane it will fail. No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
There is a 10% chance delivery is going to be canceled and 20% chane it will fail.
There is a 10% chance delivery is going to be canceled and a 20% chance it will fail.

Copy link
Member

Choose a reason for hiding this comment

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

It might be helpful as well to have a comment here (in the README.md) or in the code regarding the event history length and CAN

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. Added

if (!packetDeliveries.get(deliveryId).getDelivered().isCompleted()) {
logger.info("Sending cancellation for delivery : " + deliveryId + " and reason: " + reason);
packetDeliveries.get(deliveryId).cancelDelivery(reason);
}
Copy link
Member

Choose a reason for hiding this comment

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

I believe an else is missing here

Copy link
Contributor Author

@tsurdilo tsurdilo Jul 17, 2025

Choose a reason for hiding this comment

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

its on purpose, we dont want to call cancelDelivery on a packet if its already completed (its completable future completed)

// more
while (true) {
sleep(3);
// for "fun", reverse the list we get from delivery confirmation list
Copy link
Member

Choose a reason for hiding this comment

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

this comment is duplicated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. Removed duplicate

for (int i = 0; i < 4; i++) {
try {
// Perform the heartbeat. Used to notify the workflow that activity execution is alive
context.heartbeat(i);
Copy link
Member

Choose a reason for hiding this comment

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

Is the idea here to have a "long-running" activity that can be cancelled? Activity execution latency in this example is between 5-7 ms and heartbeatTimeout is 2 seconds.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

its to handle cancelation in activity, similar to HelloCancellation sample

Copy link
Member

Choose a reason for hiding this comment

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

Understand, . Of all the times I’ve run the example, none have resulted in a cancelled activity. maybe 7 ms is not enough, but I will try again later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah you can change the "percentages" of cancel / failure to increase change for cancelation locally

for (int i = 0; i < 4; i++) {
try {
// Perform the heartbeat. Used to notify the workflow that activity execution is alive
context.heartbeat(i);
Copy link
Member

Choose a reason for hiding this comment

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

Understand, . Of all the times I’ve run the example, none have resulted in a cancelled activity. maybe 7 ms is not enough, but I will try again later

tsurdilo added 2 commits July 18, 2025 09:56
Signed-off-by: Tihomir Surdilovic <[email protected]>
Signed-off-by: Tihomir Surdilovic <[email protected]>
@tsurdilo tsurdilo merged commit 84b4fee into main Jul 20, 2025
13 of 14 checks passed
@tsurdilo tsurdilo deleted the multisignalsample branch July 20, 2025 15:42
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.

3 participants