I cannot say with 100% certainty this will work, but in the Request metaData, DevTest used to carry the Client IP address and worker thread port of the consumer sending the request.
Perhaps, you could use this to identify the IP address of the consumer. Using a Scriptable DPH as the last Filter on the LISTEN Step. Please excuse potential typos.
%beanshell%
import com.itko.util.ParameterList;
// only do this logic for the GET /v1/branches operation
// NOTE: not sure if there is a "/" after /v1/branches on your request or not VERIFY AGAINST the Operation name in the VSI
if ( ! "GET /v1/branches".equals( lisa_vse_request.getOperation() ) ) {
_logger.info( "<<< Incoming REST request is NOT a /v1/branches request so existing the logic" );
return;
}
// Get the meta data from the incoming request and check to see if it has a client ID
ParameterList metadata = lisa_vse_request.getMetaData();
String serverName;
if ( metadata == null ) { // saftey check
_logger.info( "<<< lisa_vse_request getMetaData() returned NULL defaulting the SERVER NAME" );
serverName = "UNKNOWN";
} else if ( metadata.containsKey( "lisa.vse.request.client.id" ) ) {
_logger.info( "<<< Client ID and worker thread is: {}", metadata.get( "lisa.vse.request.client.id" ) );
int i = metadata.get( "lisa.vse.request.client.id" ).indexOf( ":" );
serverName = metadata.get( "lisa.vse.request.client.id" ).substring( 0, i );
_logger.info( "<<< The sending client id is: {}", serverName );
} else {
_logger.info( "<<< NO Client ID FOUND in META DATA defaulting to Unknown" );
serverName = "UNKNOWN";
}
// now add a key/value pair into the ArgumentList so the VSI can use the SERVER_IP during the lookup
ParameterList args = lisa_vse_request.getArguments();
args.addParameters("SERVER_IP=" + serverName);
lisa_vse_request.setArguments( args );
Now, in the GET /v1/branches operation in your VSI,
- CLICK the META Response
- Add a key named SERVER_IP and place "UNKNOWN" in the value
- CLICK OK and this will cause the specific transactions to be populated with the key
- CLICK on a specific transaction, CLICK on SERVER_IP and add the IP address for aaa.com
- Replace the response body with the content for AAA
- Copy the specific transaction, CLICK on SERVER_IP and add the IP address for bbb.com
- Replace the response body with the content for BBB
- Copy the specific transaction, CLICK on SERVER_IP and add the IP address for zzz.com
- Replace the response body with the content for ZZZ
If an IP address comes in or is not available, the value of SERVER_IP will be UNKNOWN so it will not match a specific transaction and select the META response.
If the IP Addresses for AAA, BBB, or ZZZ change or there can be multiple IP addresses, then add specific transactions as required.
Run the service VSM in ITR mode and have one of the applications send a request. Or, send a request from your localhost using SoapUI, PostMan, etc to the service running in ITR mode.
Single Step through the VSM LISTEN STEP in ITR. Stop and review the Properties and Events tabs to verify the code and make sure I did not have a typo in the above logic.
Step through the VSI Selection and send the response to the client checking to ensure that the proper response was sent.
If you are happy with the results, comment _logger.info statements, change them to _logger.debug or remove them so they don't appear in your vse.log when you deploy the service.