Announcement

Collapse
No announcement yet.

Second destination depending on outcome on first else an error response

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Second destination depending on outcome on first else an error response

    Hello All,

    I have a situation where I read in an hl7 message, extract some string and send it to a webservice(my first destination). If the webservice returns with a 'true' then I send a string to my second destination(a JMS connector) which is the second destination and if it comes back with a 'false' I send back an error message/response instead.
    Can someone give me suggestions on how I can accomplish this task? Is it possible to do something like this?

    Thanks. I would greatly appreciate any help in this matter.
    -Nicky

  • #2
    You want two destinations (one to send an error back, one to hit JMS) and each one has a filter that tests the response from the webservice.

    You can also use the route method in a javascript step to pass the message along.
    Jon Bartels

    Zen is hiring!!!!
    http://consultzen.com/careers/
    Talented healthcare IT professionals wanted. Engineers to sales to management.
    Good benefits, great working environment, genuinely interesting work.

    Comment


    • #3
      Thanks for the quick response. Just a couple of questions to clarify:
      1. So in total I need 3 destinations. The last two will test the result of the first?
      2. route method in javascript: Did you mean 'router.routeMessage(channelName, 'message');'. I thought this method only lets you route messages to channels and not destinations. Am I wrong?
      The last question I had is about sending an error response, in another task I had used responseMap.put("ACKResponse", ResponseFactory.getSuccessResponse(finalResponse))
      in a postscript to send back a response .. that was the only way to get it to work. So if you say that I have one destination for sending back the error, how exactly do I do it? I do not have the url/port number of where the hl7message comes in from to be able to send it back. I was looking for some sort of NACK sort of a thing.

      Greatly appreciate your help.
      Thanks a ton,
      Nicky

      Comment


      • #4
        Hi,

        I have a similar situation as Nicky. I need to make an FTP transfer, and send a success email when the transfer is successful, and send an error email when the transfer failed for some reason.
        Right now, I have the src-target FTP connectors setup, and I can have two more destinations configured to send success/failure emails. How would I branch between them based on the response from the first destination ?

        Thanks,
        Deepa

        Comment


        • #5
          I just saw the sticky note on the guidelines, and wanted to provide more details about the problem.

          Mirth version - Mirth Connect Administrator 1.8.2.4472

          These are the different options I tried (but in vain) :

          1. Created 3 destinations. First was for FTP transfer, second for a failure email, third for a success email. Created filter across second destination to accept only if the FTP response code is an error code. But I am not exactly sure of what is returned by the first destination. And this setup is not working.

          2. Created a Javascript writer on destination, which would supposedly have code for transferring files on FTP, and in the catch block, I can send a failure email + return, and at the end of this all, send a success email. This is not completely implemented yet, its a whole bunch of code though.

          3. Tried to access the Response from first destination in the Postprocessor. Couldnt find a handle to the Response. ResponseMap only seems to give out any keys that we would have updated earlier in the flow. And ResponseMap.getRespone() returns a new Response object. Nothing seem to return the Response from my first destination's execution of operation.

          Please let me know more about the Response object returned from the destination FTP connector. How can I access this object on the script ?

          Thanks in advance.
          Deepa

          Comment


          • #6
            In the post processor you can get the response by using the following code:


            var status = responseMap.get("Destination 1").getStatus();

            this should return SUCCESS or FAILURE.

            use this in the post processor. This should help with routing your messages properly.

            -Brad

            Comment


            • #7
              Yes, this works. Thanks a lot Brad!

              -Deepa

              Comment


              • #8
                Originally posted by nickydavid View Post
                Thanks for the quick response. Just a couple of questions to clarify:
                1. So in total I need 3 destinations. The last two will test the result of the first?
                2. route method in javascript: Did you mean 'router.routeMessage(channelName, 'message');'. I thought this method only lets you route messages to channels and not destinations. Am I wrong?
                The last question I had is about sending an error response, in another task I had used responseMap.put("ACKResponse", ResponseFactory.getSuccessResponse(finalResponse))
                in a postscript to send back a response .. that was the only way to get it to work. So if you say that I have one destination for sending back the error, how exactly do I do it? I do not have the url/port number of where the hl7message comes in from to be able to send it back. I was looking for some sort of NACK sort of a thing.

                Greatly appreciate your help.
                Thanks a ton,
                Nicky
                someone can answer to the second question?
                many thanks!

                Comment


                • #9
                  route is used for routing to other channels, you are correct.

                  Comment

                  Working...
                  X