-
Notifications
You must be signed in to change notification settings - Fork 417
[SOA] Bound outbound reply retries #9541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
93d3be4
[SOA] Bound outbound reply retries
qikram 6865f04
Merge branch 'main' of https://github.com/microsoft/BCApps into bugs/…
qikram d593f9d
Address reply retry review feedback
qikram 5efecfb
Address remaining reply retry feedback
qikram a1b125f
Merge branch 'main' of https://github.com/microsoft/BCApps into bugs/…
qikram 7854f94
Fix send mailbox
qikram 45f9cf0
Merge branch 'main' of https://github.com/microsoft/BCApps into bugs/…
qikram 266f4a9
Revert test code
qikram cad3801
Page optimised
qikram 6805b2d
Address reply retry review feedback
qikram File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/Apps/W1/SalesOrderAgent/app/src/Integration/SOAReplyAttempt.Table.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
| // ------------------------------------------------------------------------------------------------ | ||
|
|
||
| #pragma warning disable AS0007 | ||
| namespace Microsoft.Agent.SalesOrderAgent; | ||
|
|
||
| using System.Agents; | ||
|
|
||
| table 4589 "SOA Reply Attempt" | ||
| { | ||
| Access = Internal; | ||
| DataClassification = SystemMetadata; | ||
| InherentEntitlements = RIMDX; | ||
| InherentPermissions = RIMDX; | ||
| ReplicateData = false; | ||
|
|
||
| fields | ||
| { | ||
| field(1; "Task ID"; BigInteger) | ||
| { | ||
| DataClassification = SystemMetadata; | ||
| TableRelation = "Agent Task".ID; | ||
| } | ||
| field(2; "Message ID"; Guid) | ||
| { | ||
| DataClassification = SystemMetadata; | ||
| } | ||
| field(3; "Attempt Count"; Integer) | ||
| { | ||
| DataClassification = SystemMetadata; | ||
| } | ||
|
qasimikram marked this conversation as resolved.
|
||
| } | ||
|
|
||
| keys | ||
| { | ||
| key(Key1; "Task ID", "Message ID") | ||
| { | ||
| Clustered = true; | ||
| } | ||
| } | ||
| } | ||
103 changes: 103 additions & 0 deletions
103
src/Apps/W1/SalesOrderAgent/app/src/Integration/SOAReplyRetryMgt.Codeunit.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
| // ------------------------------------------------------------------------------------------------ | ||
|
|
||
| #pragma warning disable AS0007 | ||
| namespace Microsoft.Agent.SalesOrderAgent; | ||
|
|
||
| using System.Agents; | ||
|
|
||
| codeunit 4418 "SOA Reply Retry Mgt." | ||
| { | ||
| Access = Internal; | ||
|
qasimikram marked this conversation as resolved.
|
||
| InherentEntitlements = X; | ||
| InherentPermissions = X; | ||
| Permissions = tabledata "SOA Reply Attempt" = RIMD; | ||
|
|
||
| var | ||
| ReplyNotAuthorizedErr: Label 'You are not authorized to send this reply.'; | ||
|
|
||
| internal procedure RegisterFailedAttempt(TaskId: BigInteger; MessageId: Guid) | ||
| var | ||
| SOAReplyAttempt: Record "SOA Reply Attempt"; | ||
| begin | ||
| SOAReplyAttempt.LockTable(); | ||
| if SOAReplyAttempt.Get(TaskId, MessageId) then begin | ||
| if SOAReplyAttempt."Attempt Count" < GetMaxAttempts() then begin | ||
| SOAReplyAttempt."Attempt Count" += 1; | ||
| SOAReplyAttempt.Modify(); | ||
| end; | ||
| end else begin | ||
| SOAReplyAttempt."Task ID" := TaskId; | ||
| SOAReplyAttempt."Message ID" := MessageId; | ||
| SOAReplyAttempt."Attempt Count" := 1; | ||
| SOAReplyAttempt.Insert(); | ||
| end; | ||
| end; | ||
|
|
||
| internal procedure ResetAttempts(TaskId: BigInteger; MessageId: Guid) | ||
| var | ||
| AgentTaskMessage: Record "Agent Task Message"; | ||
| begin | ||
| AgentTaskMessage.Get(TaskId, MessageId); | ||
| ValidateMessageAccess(AgentTaskMessage); | ||
|
|
||
| ClearAttempts(TaskId, MessageId); | ||
| end; | ||
|
|
||
| internal procedure IsExhausted(TaskId: BigInteger; MessageId: Guid): Boolean | ||
| var | ||
| SOAReplyAttempt: Record "SOA Reply Attempt"; | ||
| begin | ||
| if not SOAReplyAttempt.Get(TaskId, MessageId) then | ||
| exit(false); | ||
|
|
||
| exit(SOAReplyAttempt."Attempt Count" >= GetMaxAttempts()); | ||
| end; | ||
|
|
||
| internal procedure ClearAttempts(TaskId: BigInteger; MessageId: Guid) | ||
| var | ||
| SOAReplyAttempt: Record "SOA Reply Attempt"; | ||
| begin | ||
| if SOAReplyAttempt.Get(TaskId, MessageId) then | ||
| SOAReplyAttempt.Delete(); | ||
| end; | ||
|
|
||
| internal procedure GetMaxAttempts(): Integer | ||
| begin | ||
| exit(5); | ||
| end; | ||
|
|
||
| local procedure ValidateMessageAccess(AgentTaskMessage: Record "Agent Task Message") | ||
| var | ||
| SOASetup: Record "SOA Setup"; | ||
| begin | ||
| ValidateMessageAccess(AgentTaskMessage, SOASetup); | ||
| end; | ||
|
|
||
| local procedure ValidateMessageAccess(AgentTaskMessage: Record "Agent Task Message"; var SOASetup: Record "SOA Setup") | ||
| var | ||
| OwnerUserSecurityID: Guid; | ||
| begin | ||
| SOASetup.GetBasedOnAgentUserSecurityID(AgentTaskMessage."Agent User Security ID", true); | ||
| OwnerUserSecurityID := SOASetup."Owner User Security ID"; | ||
| if IsNullGuid(OwnerUserSecurityID) then | ||
| OwnerUserSecurityID := SOASetup."User Security ID"; | ||
|
|
||
| if (UserSecurityId() <> OwnerUserSecurityID) and (UserSecurityId() <> SOASetup."User Security ID") then | ||
| Error(ReplyNotAuthorizedErr); | ||
| end; | ||
|
|
||
| [EventSubscriber(ObjectType::Table, Database::"Agent Task Message", 'OnAfterDeleteEvent', '', false, false)] | ||
| local procedure DeleteAttemptsOnAfterDeleteAgentTaskMessage(var Rec: Record "Agent Task Message"; RunTrigger: Boolean) | ||
| begin | ||
| if Rec.IsTemporary() then | ||
|
qasimikram marked this conversation as resolved.
|
||
| exit; | ||
|
|
||
| if Rec.Type <> Rec.Type::Output then | ||
| exit; | ||
|
|
||
| ClearAttempts(Rec."Task ID", Rec.ID); | ||
| end; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.