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

Contract negotiation loop #538

Closed
hlange opened this issue Jan 21, 2022 · 3 comments
Closed

Contract negotiation loop #538

hlange opened this issue Jan 21, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@hlange
Copy link

hlange commented Jan 21, 2022

Hi,
I have a problem with the sample 4.0. I fixed the issue with keyName like mentioned in the discussions. But this generated new problems because after everything gone through and the file was moved from one directory to a different, the CPU load of one core gone up to 100%.

Because I thought maybe this could be because it was not the newest version I clone the current version. This generated a complete new issue because the negotiation was running in a loop.

Consumer:
grafik

Provider:
grafik

By running the following command:
curl -X POST -H "Content-Type: application/json" -d @samples/04.0-file-transfer/contractoffer.json "http://localhost:9191/api/negotiation?connectorAddress=http://localhost:8181/api/ids/multipart"

And I added keyName to ConsumerApiController.java

Best regards,
Henrik

@ndr-brt
Copy link
Member

ndr-brt commented Jan 24, 2022

Thanks for finding out, here I see two problems:

  • the sample 04 was renamed to 04.0 but its README was not updated accordingly (PR samples: Update sample path on README #543 )
  • on the consumer side ContractNegotiation REQUESTING state has two meanings:
    • ContractNegotiation created and waiting to be sent to the provider
    • ContractNegotiation sent to the provider and waiting for response

This causes the infinite loop, because every REQUESTING negotiation is sent to the provider, but it should not

@ndr-brt ndr-brt added the bug Something isn't working label Jan 24, 2022
@ndr-brt
Copy link
Member

ndr-brt commented Jan 24, 2022

I noticed strange behavior into the contract negotiation repositories (stores).
In fact, both of the "production" (I mean "production code", not "production ready") implementations contain this logic:

if (ContractNegotiationStates.UNSAVED.code() == negotiation.getState()) {
            if (ContractNegotiation.Type.CONSUMER.equals(negotiation.getType())) {
                negotiation.transitionRequesting();
            } else {
                negotiation.transitionRequested();
            }
        }

this is dangerous because this kind of domain logic should stay in the domain classes, in this case in ContractNegotiation probably. Otherwise every time someone implement a ContractNegotiationStore should report that logic in their implementation, and that would bring to duplication.

However my proposal is to define an additional state between UNSAVED and REQUESTING called INITIALIZED (or INITIAL, to make it consisted with the TransferProcess one). The negotiations on consumer state in that state will be sent to provider and moved to PROCESSING. That would resolve this bug

@mspiekermann
Copy link
Contributor

closed by #545

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants