How to send VSE Responses to different Queues in DevTest

Document ID : KB000100485
Last Modified Date : 07/06/2018
Show Technical Document Details
Introduction:
How to direct a virtual service  message  based on some criteria  to multiple queues? 

For example if incoming request payload contains <field id="User" value="A0001JH3"/> , the requirement is that 
  If  value="A0001JH2" -> go to Queue 1    and if value="A0001JH3" -> Queue 2




Environment:
DevTest 10.1 and up
Instructions:

There are multiple ways to do this, Please see the options described below: 

Option A: 
With the new 'IBM MQ Native' protocol, you can put multiple response queues into a single Respond step.
 1. Create a separate queue asset for each of your response queues. 
User-added image

 2. Add multiple response channels in your VSM 'Respond' step (or in the VSE recorder when generating your VSM).  Create a separate channel for each response queue and give it a name.

User-added image
 3. In your VSI service image, find the 'channel.name' property in the response meta-data of each transaction and change its value to match the name of the response channel corresponding to the correct response queue.

User-added image

 User-added image

Option B:

You can do this with a response-side scripted DPH :
if ("A0001JH3".equals(lisa_vse_request.getMetaData().getParameterValue("...field.Usario"))) {
    lisa_vse_response.getMetaData().setParameterValue("channel.name", "Response 2");

} else {
    lisa_vse_response.getMetaData().setParameterValue("channel.name", "Response 1");
}




Option C:

Add a Scripted Assertion, 
  • Change the assertion in the Image Selection Step to a Scripted Assertion and set the responseChannel property based on the input parameter.
Set the Assertion to FAIL if False.
 
// set the response channel 1 or 2 depending on the input arg
// use getStateString in case the argument is not parsed by the XML dph
 
if ( “A0001JH3”.equals( testExec.getStateString(“requestMsg_dse_formattedData_kColl_field_1_value”, “unknown”) ) {
      testExec.setStateValue(“responseChannel”, “Response 1”);
} else {
      testExec.setStateValue(“responseChannel”, “Response 2”);
}


 
Additional Information:
https://communities.ca.com/message/242033364-re-parameterizing-the-mq-name-in-native-mq-step?commentID=242033364#comment-242033364