You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a use case where the client calls an HTTP endpoint, receives a 202 status code, and the real response payload is delivered asynchronously through a queue. So far I have been able to model this use case in mockintosh by using an async producer and triggering it in my endpoint with triggerAsyncProducer.
My problem right now is that the full use case requires the endpoint to return a correlation-id to the caller, and the async message delivered later must reference this same correlation-id.
I almost made it work by using the counters feature, with a config like this:
My problem right now is that it seems that the async message is produced BEFORE the counter has been incremented.
So in the first execution, the http endpoint correctly gives me a correlation-id of 1, but I receive this in my queue:
For the next executions, the http endpoint correctly returns the incremented counter, but the produced message is always one step behind.
I don't know if this is a bug or the expected behavior.
If this is expected, is there any other way to make my use case work?
One idea that came to my mind is this: mockintosh keeps a count of the requests as we can see on the Statistics tab. If there's a way to reference this count in the templated responses (something like {{requestCount}}), then I could also use this count to model my correlation-id requirement.
I was thinking about adding some conditionals to check if the counter exists (first execution) and then always adding 1 to it's value but I haven't tried it yet, don't even know if it's possible.
Thanks!
The text was updated successfully, but these errors were encountered:
AND IT WORKS! 😄
First execution returns 1 in the http response and also in the produced message!
In summary, when counter is used in the headers, the value is incremented before the async producer is triggered. When it's used in the body, it seems to be the other way around.
Since this is not a deterministic behavior, I'd say this is a bug.
Hello guys.
I have a use case where the client calls an HTTP endpoint, receives a 202 status code, and the real response payload is delivered asynchronously through a queue. So far I have been able to model this use case in mockintosh by using an async producer and triggering it in my endpoint with
triggerAsyncProducer
.My problem right now is that the full use case requires the endpoint to return a correlation-id to the caller, and the async message delivered later must reference this same correlation-id.
I almost made it work by using the counters feature, with a config like this:
My problem right now is that it seems that the async message is produced BEFORE the counter has been incremented.
So in the first execution, the http endpoint correctly gives me a correlation-id of
1
, but I receive this in my queue:For the next executions, the http endpoint correctly returns the incremented counter, but the produced message is always one step behind.
I don't know if this is a bug or the expected behavior.
If this is expected, is there any other way to make my use case work?
One idea that came to my mind is this: mockintosh keeps a count of the requests as we can see on the Statistics tab. If there's a way to reference this count in the templated responses (something like
{{requestCount}}
), then I could also use this count to model my correlation-id requirement.I was thinking about adding some conditionals to check if the counter exists (first execution) and then always adding 1 to it's value but I haven't tried it yet, don't even know if it's possible.
Thanks!
The text was updated successfully, but these errors were encountered: