Scenario: Customer uses AppTest to test their backend service that has RabbitMQ as broker. JSON payload is used for request and response
1. Customer wants to use an ID attribute in request and response for Correlation. Customer needs help and direction on how to set such a correlation scheme. Our documentation severely lack examples on this front
2. RabbitMQ Receive step reads all the messages in a given queue if 'Correlation Scheme' flag is checked though it returns the correct message
In this post I am attempting to answer the first question, I will explain part 2 in another separate post.
Setting up JSON PAYLOAD CORRELATION SCHEME with RabbitMQ
|Customer wants to use the field 'provisioningOrderId' as correlation scheme as the backend service returns the same value in response|
The screenshot below shows how to configure RabbitMQ Send/Receive step. It is important to understand how this works. Read the text below the screenshot:
- First things first, correlation scheme is always defined as part of 'Receive Step'
- 'RabbitMQ Payload's is used for correlation scheme since the 'correlation' field is part of the JSON Payload
- Note that our tool has deep functionliaty as we have the option to generate a correlation ID by the tool, (an UUID). If you wish Devtest tool to create a correlation ID for the message, just set the flag 'Auto Generate' to YES. In the current defect, customer fills the value for field 'provisioningOrderId' and hence this flag has been set to NO
- The flag 'Reuse ID' has a meaning only if 'Auto Generate' is set to YES. WIth auto generated correlation ID, the 'Reuse ID' flag means that the same correlation ID is used for the duration of entire test otherwise a new ID is generated every time
- The interesting point to note here is that if you choose 'Auto Generate' YES, then the REQUEST payload is modified to include the auto-generated UUID. See the example below:
- FOR NEXT POINT, SCROLL DOWN BELOW THIS SCREENSHOT
PAYLOAD in SEND STEP
PAYLOAD MODIFIED BY DEVTEST TO INCLUDE AUTO-GENERTED CORRELATION ID
|Devtest 'RabbitMQ Send' step inserts a new Correlation ID precisely at the place pointed by 'Request Rege' and 'Request Group'|
7. Next step is to set the REGEX pattern to use for REQUEST as well as RESPONSE
In this case, since the correlation ID is the same for both REQUEST and RESPONSE, we use the following expression
This expression was arrived at with the help of an ONLINE REGEX TESTER https://www.regextester.com/99141 Over here, you can just provide your JSON content and play with REGEX expression to choose what you want to be matched, NOTE HERE CAREFULLY THAT THE
TOOL SUPPORT THE CONCEPT OF GROUPS. THAT MEANS, THE ATTRIBUTE NAME IS GROUP0 AND ATTRIBUTE VALUE IS GROUP1, SINCE WE USE THE VALUE OF provisioningOrderId as correlation ID, we need to choose group 1.
Hope it is clear as to how to frame the REGEX that matches a specific attribute in a JSON REQUESE and RESPONSE
Next, lets understand certain IMPORTANT functional aspects that I understood, Unfortunately these details are not documented at all.
If ASYNCHRONOUS flag is chosen in RECEIVE step, then instead of reading a single message, all the messges are consumed, though in SEND/RECEIVE STEP Response, you would see only one message.
This is the observation and RC for the point #2 reported by customer and there are few weird things that I noticed here.
NUMBER OF MESSAGES READ BY RECEIVE STEP