Skip to content
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

Accessing Saga Association Values #1125

Closed
Polish-Civil opened this issue Jun 13, 2019 · 2 comments · Fixed by #2141
Closed

Accessing Saga Association Values #1125

Polish-Civil opened this issue Jun 13, 2019 · 2 comments · Fixed by #2141
Assignees
Labels
Priority 4: Would Lowest priority. Would-be-nice to include issues when time allows it. Status: Resolved Use to signal that work on this issue is done. Type: Feature Use to signal an issue is completely new to the project.
Milestone

Comments

@Polish-Civil
Copy link

Polish-Civil commented Jun 13, 2019

Hello,

In my sagas sometimes i have situation where im communicating with external service which does not have any information about the id of the internal service aggregate.
When i receive event back from the external service i would like to continue the organization process internally with the id that has been associated with the saga prior to dispatching the command to the external service.

Currently a way of doing that is to just put the associated value inside saga class so it would be serialized and therefor i'm able to access it and continue the work.

However those situations happen quite a lot, and its just boiler plate code.

It would be really nice to have a way of accessing the association values within the saga event handler.

Example:

class Saga {
    @SagaEventHandler(associationProperty = "internal")
    fun start(evt: InternalEvent) {
        SagaLifecycle.associateWith("external",evt.externalId)
        this.commandGateway.send<Any>(ExternalCommand(evt.externalId))
    }
    
    @SagaEventHandler(associationProperty = "external")
    fun start(evt: ExternalEvent) {
        val internal = SagaLifecycle.getAssociationValue("internal")
        this.commandGateway.send<Any>(InternalCommand(internal))
    }
}
@smcvb smcvb added the Status: Under Discussion Use to signal that the issue in question is being discussed. label Jun 13, 2019
@smcvb
Copy link
Member

smcvb commented Jun 13, 2019

I recall this question from earlier scenarios too, not sure what the conclusion was though.
I'll make it a point we discuss this in our following meeting, @Polish-Civil.

For now, thanks for the detailed description of your scenario and the suggested solution!

@smcvb smcvb changed the title Accessing saga association values Accessing Saga Association Values Jun 13, 2019
@smcvb smcvb added this to the Release 4.5 milestone Aug 10, 2020
@smcvb smcvb removed this from the Release 4.5 milestone Jan 11, 2021
@smcvb smcvb added this to the Release 4.6.0 milestone Sep 3, 2021
@CodeDrivenMitch CodeDrivenMitch self-assigned this Mar 17, 2022
@CodeDrivenMitch CodeDrivenMitch linked a pull request Mar 17, 2022 that will close this issue
@smcvb
Copy link
Member

smcvb commented Mar 18, 2022

I like the proposal you made there, @MORLACK.
Let's go ahead with it :-)

@smcvb smcvb added Priority 4: Would Lowest priority. Would-be-nice to include issues when time allows it. Type: Feature Use to signal an issue is completely new to the project. Status: In Progress Use to signal this issue is actively worked on. and removed Status: Under Discussion Use to signal that the issue in question is being discussed. labels Mar 18, 2022
@close-label close-label bot added the Status: Resolved Use to signal that work on this issue is done. label Mar 22, 2022
CodeDrivenMitch added a commit that referenced this issue Mar 22, 2022
[#1125] Introduce `SagaLifecycle.associationValues()`
@smcvb smcvb removed the Status: In Progress Use to signal this issue is actively worked on. label Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority 4: Would Lowest priority. Would-be-nice to include issues when time allows it. Status: Resolved Use to signal that work on this issue is done. Type: Feature Use to signal an issue is completely new to the project.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants