How to halt flow using an Extension Tool

jefftuckerbofajefftuckerbofa Posts: 61

I am doing some custom processing in a Message Responder using an Extension Tool. I need to be able to interrupt the current flow and return HTTP 500 so that the Message Proxy will move to the secondary connection. What's the best way to do this? Should I be using a different type of tool? Thanks JT

Comments

  • williammccuskerwilliammccusker Posts: 408 ✭✭

    Hi,

    When you say to halt the current flow what behavior are you needing? Are there other chained tools that you don't want to have executed?

    You could use a parameterized status code and then as the last tool chained you could have an extension tool to check your condition for routing to the secondary endpoint. Then you could update the parameterized status code so that it routes to the secondary.

  • jefftuckerbofajefftuckerbofa Posts: 61

    I have a request to get profile data from a web service. The request has a unique profile ID. Of all the profile IDs in my environment, I want to conditionally route the request for 5 of the IDs to a secondary environment. The IDs for these 5 requests need to be mapped to an alternate ID before the request is sent. All others should be routed to the BAU environment.

    I had things set up where I created 5 different message responders which included the ID in the Responder Correlation. For the 5 that matched, I updated the ID and forwarded using the Message Forward tool. Works, but I had a lot of duplication because each of the 5 responders contained essentially the same components and tools.

    Next, I collapsed the 5 responders into a single responder, and used an expanded xpath statement (//id/text()='1' or //id/text()='2' or //id/text()='3' or //id/text()='4' or //id/text()='5') and used an if/else if statement to map the ID to the alternate ID. Again, worked, but I suspect it doesn't scale well based on the practical limits of how the xpath might look with hundreds of IDs.

    I"d like to have a single responder that just has the if/else if statement from above to map the IDs, but if if none of the IDs were matched it would just stop the current request and pass the ball back to the message proxy so that the request would hit the secondary connection.

  • williammccuskerwilliammccusker Posts: 408 ✭✭

    Hi,

    I would recommend making a Table Data Source for the ids you want to match and then set up a Data Source correlation to for the id. That way you will have only a single XPath to extract the incoming id and then the correlation will do the lookup in the table data source to find the match.

    That would scale and you could continue to use your current approach.

    Would that work for your use case?

  • jefftuckerbofajefftuckerbofa Posts: 61

    Yes, I do believe that is a great approach.

    Is there a way to use that same table to drive the mapping? Maybe if the table had a second row containing the alternate IDs.

    Thanks! JT

  • williammccuskerwilliammccusker Posts: 408 ✭✭

    Hi,

    Yes! Just have the "mapped" id and a second column, then when you use that column the data source correlation will have picked the row based on the incoming id and can use the "mapped" id from the second column.

  • jefftuckerbofajefftuckerbofa Posts: 61

    Do you have an example of the xpath that I would use to check the Table datasource? THanks JT

  • williammccuskerwilliammccusker Posts: 408 ✭✭

    Hi,

    You wouldn't need an XPath to check the table. You would set up the data source correlation to extract the incoming id using your existing XPath, e.g. /id/text(), then tell the data source correlation which column in the data source it should match. At runtime, it will use the XPath to extract a value then look for a row that has that value in the configured column.

    Here is a link to some documentation that may help
    https://docs.parasoft.com/display/VIRT9106/Message+Responder+Overview#MessageResponderOverview-DataSourceCorrelationTab

  • jefftuckerbofajefftuckerbofa Posts: 61

    Works great. Thanks again. I'm building a super cool POC using these tools that my employer is going to absolutely love. JT

  • williammccuskerwilliammccusker Posts: 408 ✭✭

    Awesome! Glad I could help :smile:

Sign In or Register to comment.