I have one scenario where i need to send a different responses for a same request(i.e) for first hit of the request i need to send a different response , second hit i need to send a different response and finally for third hit i need to send different response. So for one particular request i need to send three different responses.
Transport Protocol: Http/s
My first though would be to use a cache to store the number of requests from a client. This way you can also easily set a time for the requests and you don't need to build up some kind of external solution. But the cache also has some limitations: it is single node and won't survive a gateway restart. But if that's not a problem, I think the cache can be a solution.
I am not very clear as to what is the condition that must be met for a different response to be sent. If the requirement is
1st Hit à Response 1
2nd Hit à Response 2
3rd Hit à Response 3
I would start a counter in a variable and keep increasing it for each hit. Then forward the request to another service within the same gateway or another gateway.
I assume you would have to keep that counter in a cluster property or external in a DB to have it available across requests, right?
My concern would be that you probably have to start a counter for each client, resulting in a hug list of cluster properties which you probably also want to clean up automatically at some point. By using the client-id or some other identifier as the cache key, you could easily achieve this.
In the end the best answer all depends on the details of the requirements.
Please find below the details of my requirement:
User will be logging in with invalid credential for three times. For first two times, i need to send a error message as a response and for the third time i need to send another error message as response.
As I am quite new to CA i don't know how to use cache. It would be a great help for me if you tell me how to use that.(In this case i know the exact email id what user going to give in the request.)
Thanks Seenu. You are right. I have explained my requirements to Michiel.
If we use a counter variable will it no get reset whenever the gateway closes?? My question might be silly.. Since i am new to Service Virtualization i want to understand how this variable thing works.
Here is a good description about how the Cache assertion works
Thanks Seenu.. So for the above mentioned scenario using cache is the only method or is there any other method we can try??
Dear Ragul ,
I agree with MichielHelder , cache assertion is not cluster-wide, using it as counter may not be accurate.
You may think of remote cache (which is a tactical assertion, you can open a support ticket to ask for it), or you can persist the counter to database using jdbc connection.