Service Virtualization

 View Only
  • 1.  Trigger Mail through Virtual service

    Posted Aug 26, 2019 05:21 AM

    Hi There,

    Iam triggering a mail based on specific flags(0 & 1), these flags are dynamic based on Http-Response Code.

    flags are by default set to 0.
    rsp-code: 500 -->flag value=0; trigger mail and changing flag value to 1
    Again, in second transaction when request received:
    rsp-code: 500 -->flag value=1 (as we have change flag to 1 in 1st transaction); Do not trigger mail.

    The issue i am facing is, locally when tested in ITR mode, all works fine, (For every transaction, i am running different ITR)
    but when i deployed my service to VSE, VS is triggering mail again & again as & when it request is received.

    Troubleshot done:
    1) every time flags is set to 0, for every transaction, separate folder is created in listtmp/lads.,
    2) to overcome above, i kept flag values in txt file which is kept on desktop, but same issue occurs.

    Kindly suggest what could be done to achieve above requirement.




    ------------------------------
    Thanks,
    Sabir
    ------------------------------


  • 2.  RE: Trigger Mail through Virtual service

    Posted Aug 27, 2019 01:15 AM
    Hi Sabir,

    You can initiate the variables in a separate Javascript step and reset them at the end of the step to a default value in another step (if needed). You can have an assertion on the response code from where you should be able to send control back to the email trigger step.

    Thanks.
    Vaibhav J


  • 3.  RE: Trigger Mail through Virtual service

    Posted Aug 27, 2019 03:04 AM
    Hi Vaibhav,

    Our flag value's are dynamic which will change according to our resp-code, thus we cannot reset it, that's the reason i kept my flag values outside CA lisa project

    ------------------------------
    Thanks,
    Sabir
    ------------------------------



  • 4.  RE: Trigger Mail through Virtual service

    Posted Aug 27, 2019 03:11 AM
    ​Hi Sabir,

    By Reset I meant, you can re-initiate the variable holding the value of flag. As you mentioned, the values are dynamic based on the response codes, in such scenario you can control it based on the codes sent/received.

    Alternate approach is to use two different variables one for initializing or resetting  the flag variable and another to persist its value so that it is not overridden by its previous value.

    Thanks.
    Vaibhav J



  • 5.  RE: Trigger Mail through Virtual service

    Posted Aug 27, 2019 03:23 AM
    It would have to be researched further why your flag properties do not hold their value and/or why your flag files do not seem to be reused/reopened.

    To overcome the former problem you have resorted to storing the flags outside the VSM workflow. Instead of using files I would store these flags in SharedMemoryMaps. This is a map object that you can create inside the VSE (java) process but it "lives" outside the running vsm instances. It is intended to be used is to communicate "data" between virtual services but I believe it would also cover your requirement.

    ------------------------------
    Cheers,
    Danny
    ------------------------------



  • 6.  RE: Trigger Mail through Virtual service

    Posted Aug 27, 2019 10:10 AM
    Dany,

    Are you saying about SharedModelMap ??

    if yes, then i used the same, but here as i need to update my flag values, how i can achieve that through Map



  • 7.  RE: Trigger Mail through Virtual service
    Best Answer

    Posted Aug 27, 2019 12:44 PM

    Hi,

     

    Apologies, you are correct, my mistake, I am indeed talking about the SharedModelMap.

     

    How I would use it for this case? I might not have the correct understanding of the requirements but it would be something like this:

     

    • First of all, you need to decide if you want to keep the flags between redeployments of your virtual service or not. If you don't want to keep them then it is best to clear the ModelMap when the virtual service starts. Add a script step as Starter and let it flow next to the Listen Step.

     

    The script would be something like:

     

           if (!com.itko.lisa.vse.SharedModelMap.isEmpty("<MyFlagTableName>"))

                  com.itko.lisa.vse.SharedModelMap.clear("<MyFlagTableName>");

     

     

    • The logic when receiving the response would be:

     

           if (!com.itko.lisa.vse.SharedModelMap.containsKey("<MyFlagTableName>", "<MyTransactionId>") || com.itko.lisa.vse.SharedModelMap.get("<MyFlagTableName>", "<MyTransactionId>").equals("0"))

           {

                  com.itko.lisa.vse.SharedModelMap.put("<MyFlagTableName>", "<MyTransactionId>", "1");

                 

                  //send email

           }

     

    Hope this helps!

     

    Cheers,

    Danny

    ::DISCLAIMER::
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only. E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents (with or without referred errors) shall therefore not attach any liability on the originator or HCL or its affiliates. Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the views or opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of this message without the prior written consent of authorized representative of HCL is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately. Before opening any email and/or attachments, please check them for viruses and other defects.
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------