Repository navigation
feat(async): Implement request-reply for kafka - #2031
Conversation
Signed-off-by: Adam Hicks <[email protected]>
|
|
This one could be merged "just-in-time" for 1.14.0. Cool 👍 |
| import java.util.Iterator; | ||
|
|
||
| /** | ||
| * Compute dispatch criteria for async request-reply events. |
There was a problem hiding this comment.
I tried to define a JSON_BODY dispatch criteria when parsing the example but I think I struggled to get AND behaviour. I was trying to create "equals" criterion for each leaf of the example json. e.g. if the example was:
{
"payment_request_id": 123,
"user": {
"id": 456
}
}
I wanted the criteria to behave like (pseudo code):
if body.payment_request_id == 123 && body.user.id == 456 then
return "example-1"
else
return "unmatched"
end if
|
|
||
| Operation signedupOperation = new Operation(); | ||
| signedupOperation.setName("SUBSCRIBE user/signedup"); | ||
| signedupOperation.addResourcePath(TOPIC_NAME); |
There was a problem hiding this comment.
this test actually broke in 9f78c58 where I changed getTopicName to use the channel name from the API doc (rather than a generated one)
There was a problem hiding this comment.
Yes, but channels/topic name override is super important to guarantee the isolation of mocks from different versions or even different APIs. We need to keep generated topic names with support of dynamic parts when using {} in the name.
Signed-off-by: Adam Hicks <[email protected]>
|
Tried to fix the sonar action as it was failing on getting coverage for an adjacent test to this PR. Got a different error now that indicates auth with Sonar isn't set up or has expired |
I think this PR is ready for review, just making sure you're not waiting for me to do something more? |
No that's cool. It's just me: I'm super busy and slow at the moment. Apologies for that 🙏 |
lbroudoux
left a comment
There was a problem hiding this comment.
Thanks @adamhicks for pushing and thanks for your patience! There are some minor change requests but a major concern here is related to the dynamic topic resolution - it seems to be broken/removed now and I don't understand why you have to do so.
|
|
||
| String topicName = producerManager.getTopicName(definition, eventMessage); | ||
| assertEquals("StreetlightsAPI-0.1.0-receiveLightMeasurement", topicName); | ||
| assertEquals("smartylighting.streetlights.1.0.event.lighting.measured", topicName); |
There was a problem hiding this comment.
This is not correct and breaks the existing conventions => we must ensure uniqueness of topic to avoid collisions between different versions or even different AsyncAPIs.
The dynamic resolution (using parts of the example message) does need to come back. The dynamic naming using service/operation/version info, I don't know how to make this compatible. How do clients currently find these topic names? E.g. if my application is expecting mocked events, does it need logic to be able to find microcks defined topic names? I'd expect the topic to be a fixed name defined in the spec, but I'm aware that I'm only really looking at my experience/use case here, so I'm keen to know how this is supposed to work 🙏 |
Ok, let me try to explain. Let's reason from an example: imagine the channel address in To allow isolation of APIs and versions, Microcks will ignore the address from the spec and define the mock topic as being But here, the channel address is defined using a So imagine, your event sample has a
The topic name (either static or dynamic) is rendered on the Microcks UI. So if you define multiple message samples in your AsyncAPI, you will have multiple thumbs in the Microcks UI with different topic names on each thumb. Hope it makes it clearer. Let me know if it needs any further clarification. |
Signed-off-by: Adam Hicks <[email protected]>
I'm coming at this from the perspective of an application that is expecting to receive events and do something with them. So it needs to know where to listen for these events. Would the expected workflow be for the user to use the Microcks UI to get the topic name and then configure there application with something like: ? If so, I think I get it :) |
|
Yes, that's it. Maybe my example with |
Signed-off-by: Laurent Broudoux <[email protected]>
feat(async): restore isolated and dynamic topics
* feat(async): Implement request-reply for kafka Signed-off-by: Adam Hicks <[email protected]> * fix: Try to fix the sonar cloud analysis Signed-off-by: Adam Hicks <[email protected]> * fix: File metadata and field case Signed-off-by: Adam Hicks <[email protected]> * feat(async): restore isolated and dynamic topics Signed-off-by: Laurent Broudoux <[email protected]> --------- Signed-off-by: Adam Hicks <[email protected]> Co-authored-by: Laurent Broudoux <[email protected]> (cherry picked from commit 9e53710)
* feat(async): Implement request-reply for kafka Signed-off-by: Adam Hicks <[email protected]> * fix: Try to fix the sonar cloud analysis Signed-off-by: Adam Hicks <[email protected]> * fix: File metadata and field case Signed-off-by: Adam Hicks <[email protected]> * feat(async): restore isolated and dynamic topics Signed-off-by: Laurent Broudoux <[email protected]> --------- Signed-off-by: Adam Hicks <[email protected]> Co-authored-by: Laurent Broudoux <[email protected]> Signed-off-by: sudheerr937-ai <[email protected]>
Description
Related issue(s)
See #1916