Service Virtualization

  • 1.  Can we read the messages, its count and store in a File from IBM M6 - WMQ Explorer

    Posted Jun 21, 2017 01:50 AM

    I have a interface in which, Source System is MQ and Target System is DB. When i run the interface, messages which are available in the MQ,  get transformed and reached the Target System (DB). 

     

    MQ Message format will be in xml. DB Result set will be in table structure. I need to validate the mapping from xml tag to db column value.

     

    So, my query here is do we have any step in DevTest Tool to read the message count and messages in MQ Explorer. If yes, please provide me the steps.

     

    Say For Ex : I have 100 messages in MQ. When i run the interface. MQ Count should be 0. DB Count should get increased to Existing Count + 100.

     

    Note : Source team will post the messages in MQ at any time, they will intimate us to validate the same. Consumers might be many for that Queue. So, whenever messages are available in that Queue. We should pick it up by running our interface.

     

    Thanks much, if anyone come across the solution, pls provide your steps.



  • 2.  Re: Can we read the messages, its count and store in a File from IBM M6 - WMQ Explorer
    Best Answer

    Posted Jun 22, 2017 05:54 AM

    MQ Explorer uses a separate management interface that's not technically private, but it's not exactly stable or well documented either.

     

    A better option would be to use the various "browse" Get Options in to iterate over messages in the queue without removing them, and count them that way.  I believe this is doable with the IBM MQ Native Send Receive step, but I'd have to do some experimentation before I could tell you exactly how to do it.  Getting the first message on the queue non-destructively is pretty easy, but getting *every* message on the queue non-destructively is complicated.

     

    That being said, unless you can guarantee no new messages will come in between the time you count the queue depth and the time you count the DB rows at the end, then your test case can still fail with a mismatched number even if nothing went wrong.



  • 3.  Re: Can we read the messages, its count and store in a File from IBM M6 - WMQ Explorer

    Posted Jun 30, 2017 12:00 AM

    Thanks Kevin for your reply.

     

    Can you help me in getting the first message on the queue atleast and store in any of temp file.. With that i can show them we are able to read the messages from queue . Will show the validation for one scenario.

     

    Do we have any steps in Workstation or do we need to write a java code for this..

     

    Note : Messages will be picked from queue when it is more than one consumer. So, whenever message is available in queue. We should store it in any of Temp File.

     

    But, it will be complicated when it is 100's or 1000's of messages to validate... In real time my interface is picking 1000's and 10000's  of messages from queue in seconds or minimum of 15 minutes time period and reaches to target DB. Please do reply if you come across the solution. Have any idea on how to implement.

     

     

     

     



  • 4.  Re: Can we read the messages, its count and store in a File from IBM M6 - WMQ Explorer

    Posted Jun 30, 2017 02:38 PM

    Here is how to build a test case that browses all the messages in an IBM MQ Queue without removing them

     

     1. Create a copy of your Queue asset and edit it.  Make sure 'PRO' is enabled, find 'Open Options' and click 'Open Editor...', find 'Input Options' and select 'Browse'.

     

     2. Create an IBM MQ Send Receive step.  Call it "Start" and make the following changes:

     2.1: Disable the 'IBM MQ PUT' section

     2.2: Get Queue: Select your "browse" queue asset

     2.3: Timeout: Make sure it's something small, like 5 seconds.  The only way to know that we've browsed to the end of the queue is to wait for a timeout, so we don't want to wait a long time.

     2.4: Get Options: Click 'Open Editor...", find 'Browse Options', click 'Open Editor...', find 'Navigation', select 'Browse First'.

     2.5: Scope: Select 'Model'.

     3. Create a copy of this step.  Call it "Loop".  It should be identical to "Start", except for the following change:

     3.1: Get Options: Click 'Open Editor...", find 'Browse Options', click 'Open Editor...', find 'Navigation', select 'Browse Next'.

     

     4. Build your test case so the "Loop" step loops back to itself.  On both the "Start" and "Loop" steps, change the 'If Timeout' connection from Fail to End, or to another step if you have things that need to happen after all messages are processed.  If you need an additional step or steps to process each message then you can insert them in between "Start" and "Loop", and have "Loop" loop back to that step instead of itself.  The message processing step can just used {{LASTRESPONSE}} to get the last message body.

     

    > store in any of temp file

     

    I don't think we have a built-in step that just writes stuff to a file.  However, You can accomplish this with a pretty simple script step.

     1. Use a Script step as the "Process Last Message" step in the above test model.

     2. Add a data set to the script step, 'Create a Numeric Counting Data Set'.

     2.1. Local: checked

     2.2. Property Key: use 'COUNT'

     2.3. From: 1

     2.4: To: 9999999, just something large

     3. Enter the following contents for the script step:

     

    fileName = "C:/<file path>/message" + testExec.getStateValue("COUNT") + ".txt";
    messageBody = testExec.getStateValue("LASTRESPONSE");
    java.nio.file.Files.write(java.nio.file.FileSystems.getDefault().getPath(fileName), messageBody.getBytes());

     

    Where "<file path>" is wherever you want your message files to go.

     

    Your test should look something like this:

     

    > Note : Messages will be picked from queue when it is more than one consumer. So, whenever message is available in queue. We should store it in any of Temp File.

     

    I don't understand what this means.

     

    > But, it will be complicated when it is 100's or 1000's of messages to validate... In real time my interface is picking 1000's and 10000's of messages from queue in seconds or minimum of 15 minutes time period and reaches to target DB. 

     

    My earlier caveat still stands.  This method of counting the messages in a queue may not have a well-defined result if messages are being added and removed from the queue at the same time it's being counted.  The only way to be 100% sure you have an accurate count, and no other messages arrive or are removed before you are done with your validation, is to use a proxy queue, and have your test case actually move messages from the proxy queue to the live queue as they are being counted.



  • 5.  Re: Can we read the messages, its count and store in a File from IBM M6 - WMQ Explorer

    Posted Aug 28, 2017 10:39 PM

    Thanks Bowman,

     

    Sorry for the delayed reply. I missed doing that part for the last 2 months. Now again, I started working on it.

     

    I understand the steps which you have mentioned, I m trying to implement and verify will it work out for my interface.

     

    Can u please help me by providing ur contact number / e-mail to explain the scenario much better and we can share the screen and do some research on ...

     

    Thanks much...

    Preethi R



  • 6.  Re: Can we read the messages, its count and store in a File from IBM M6 - WMQ Explorer

    Posted Aug 29, 2017 01:20 PM

    > Can u please help me by providing ur contact number / e-mail to explain the scenario much better and we can share the screen and do some research on ...

     

    Sorry, but if you need that level of support then you need to go through actual Support and file a case.  The above post is as much as I can do for you.