Announcement

Collapse
No announcement yet.

Wait on response for destination

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

  • Wait on response for destination

    Hello,

    i have a pdf reader channel that works as below,

    1. source read *.hl7 from a folder
    2. transformer based on the name of *.hl7 file reads the pdf file and add it to msg.
    3. destination sends this modified msg.

    now i want to wait in transformer to check if the msg got accepted and ack by the destination system , if the message was accepted i want to delete that particular "pdf" file and if not then i want to keep that pdf for troubleshooting. same HL7 file gets deleted by source connector once it is successfully processed.

    the destination uses a queue with attempt first option.

    i tried to put the delete code in response transformer for that destination and check if the message status was "SENT" but i never get that deletion code executed. it always call the else part of the code. i always get no delete.

    var responsemsg =responseMap.get('name of destination').getStatus();
    if(responsemsg=='SENT')
    {
    logger.info("Now Start");
    var file = new java.io.File(DirectoryPath+$('FileName')+'.pdf');
    file.delete();
    }
    else
    {
    logger.info('No delete');
    }

    Thank you,

  • #2
    You want to put code in the post processor.

    Comment


    • #3
      Thank you cory for the reply.

      i tried that but it is still not waiting or monitor the message.
      i mean by that is, if the receiving application or network is running and accept the message the pdf gets deleted fine.
      but if the message gets into the queue for whatever reason like network down or application not running then it do not work. the queued messages gets sent fine after the network is back up but the delete logic do not work as it has already been executed.

      Also is postprocessor individual to each destination or is it common for all?

      Comment


      • #4
        If you want such logic to take place even if the message gets queued, then you can use the response transformer instead. The response transformer executes after every send attempt, and you'll have access to the status (e.g. SENT/ERROR/QUEUED) of the response to perform conditional logic against.
        Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

        Nicholas Rupley
        Work: 949-237-6069
        Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


        - How do I foo?
        - You just bar.

        Comment


        • #5
          do i use Source transformer or destination response transformer?
          on destination response transformer it gives error "null" do not have getStatus() method.

          i moved the code to response transformer. I have "attempt first" for destination so if network is down it get queued and at time response transformer dont even get called. now when network is back up it gives below error message but message still gets sent and the response map for that message has status "SENT".

          And sometimes when messages gets sent it gets response "Queued" which was previous status.


          121: function doTransform() {122: 123: 124: logger.info("in response transformer");125: //var responsemsg =responseMap.get('name Practice').getStatus();126: var responsemsg = response.getStatus();127: logger.info(responsemsg);128: if(responsemsg=='SENT'){129: logger.info("Now Start");130: var file = new java.io.File(DirectoryPath+$('FileName')+'.pdf');L INE NUMBER:
          126DETAILS:
          TypeError: Cannot find function getStatus in object com.mirth.connect.server.userutil.ImmutableRespons [email protected]

          This is confusing can you explain how this response transformer works.
          Last edited by shenkey; 07-07-2014, 06:51 PM.

          Comment


          • #6
            Can someone help me with above ?

            Comment


            • #7
              The response transformer runs after each send attempt, if there is an actual response payload. If there is no payload (like if there's an ACK timeout) then it will not run. The only exception is when the response inbound data type is Raw; in that case the response transformer will always run.

              There are templates in the References tab specific to the response transformer, so use those.
              Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

              Nicholas Rupley
              Work: 949-237-6069
              Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


              - How do I foo?
              - You just bar.

              Comment


              • #8
                Thank you for guiding me but i am still having problem.

                so if the message is Queued, i will always get that error right?

                Am i trying to achieve something not possible or can you provide some psudo code so that i can fix this.
                Thank you
                Shenkey

                Comment

                Working...
                X