web stats
basic question regarding flow of message through a channel - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 01-03-2012, 05:11 AM
satyam satyam is offline
Mirth Newb
 
Join Date: Oct 2010
Location: Hyderabad,India
Posts: 24
satyam is on a distinguished road
Question basic question regarding flow of message through a channel

Hi,

1) What is the expected flow of message in a channel.

As per my understanding it is as below.
source connector --> preprocessor --> source transformers --> destination transformers -- > destination -- > postprocessor.

Please correct if i am wrong.

2) When using database reader as source connector, when is "run on update statement" executed. I expect it to run immediately after the fetch/select statement. But somehow for me it appears that , run on update runs after the destinations are executed.
Am I missing something ??

I am using javascript in the database reader, run on update is selected.
Reply With Quote
  #2  
Old 01-03-2012, 12:53 PM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

Mirth gurus, correct me if I'm wrong, but here's how I understand it:

True raw message ->
Global preprocessor ->
Channel preprocessor ->
Additional channel preprocessing as per the channel settings (stripping namespaces, LF/CR conversion, etc) -> (Source Raw Message)
Conversion from source inbound protocol to XML ->
Source filter ->
Source transformer -> (Source Transformed Message)
Conversion from XML to source outbound protocol -> (Source Encoded Message / Destination Raw Message)
Conversion from source outbound protocol to XML ->
Destination filter ->
Destination transformer -> (Destination Transformed Message)
Conversion from XML to destination outbound protocol -> (Destination Encoded Message)
Outbound message is compiled from destination template; usually just the encoded data -> (True Outbound Message)
Channel postprocessor; doesn't affect outbound message ->
Global postprocessor; doesn't affect outbound message ->
On-update statement, if a database reader source is used; if a channel isn't synchronized, then I think this runs right after the initial query code, but I'm not 100% on that, it may just not run at all...

So, that's a very basic example... certain settings in your channel will affect the exact order of this flow. For example, if a message is filtered on the source connector, it will still run the postprocessors. If a channel is not synchronized, then destinations may run out of order, and postprocessor scripts will not run.

Also, the postprocessors may run before or after a response is received by the destination, depending on your channel settings. An LLP sender will wait for a response before running the postprocessors, obviously because you usually don't want to run your finishing scripts until you're sure that the message has actually sent. In the case of an LLP Listener, you can set it up to respond based on the source filter or from a response variable set in the source transformer, in which case a response from your channel back to the inbound client is sent immediately. If instead the connector is set up to respond directly from a destination or from a response variable set in the destination transformer or the channel postprocessor, then obviously a response will not be sent back to the inbound client until all of the destinations have finished processing.

If there are no transformer steps in a connector, then no Transformed Message is created and saved to the database for that connector, but the message is still converted to and from XML, because the inbound/outbound protocols may be different.

As you can see, it can get rather complex....
Reply With Quote
  #3  
Old 01-04-2012, 06:03 AM
Bostad Bostad is offline
Level 85 Channel Wizard
 
Join Date: Mar 2009
Location: Stratford Ontario
Posts: 712
Bostad is an unknown quantity at this point
Default

Hi narupley;

That's a pretty detailed description and I think you've got most of it right.

IMO, if you're looking at where to insert code and filters this is the basic flow:

Raw Message -->
Pre-Processor -->
Source Filters -->
Source Transformers -->
Destination Filters -->
Destination Transformers -->
Destination -->
Post-Processors


To answer your second question I believe the "run on update" is run after you do your initial database read. I haven't played with it, but my concern is that it will run the update statement even if the message fails.

In my a PoC channel with a DB reader I set the processed field to true in the post processor if I get a successful return.
__________________
I can be reached through gmail and Google Talk using davidrothbauer at gmail dot com
http://www.linkedin.com/pub/david-rothbauer/5/923/518
codeismydrug.wordpress.com
hl7coders.wordpress.com

Test all my code suggestions prior to implementation
Reply With Quote
  #4  
Old 01-06-2012, 10:37 PM
satyam satyam is offline
Mirth Newb
 
Join Date: Oct 2010
Location: Hyderabad,India
Posts: 24
satyam is on a distinguished road
Default

Thanks Narupley and Bostad. I am clear with message flow .

I still need some answer on "run on update" statement. It is still confusing me.
My channel is synchronized and it appears that run on update is run after the destinations are processed. But this is not the desired behavior.
Reply With Quote
  #5  
Old 01-08-2012, 09:46 AM
Bostad Bostad is offline
Level 85 Channel Wizard
 
Join Date: Mar 2009
Location: Stratford Ontario
Posts: 712
Bostad is an unknown quantity at this point
Default

Hi;

Like I said, I've never used it.

The best way to find out might be to set up a test channel and db and give it a shot.
__________________
I can be reached through gmail and Google Talk using davidrothbauer at gmail dot com
http://www.linkedin.com/pub/david-rothbauer/5/923/518
codeismydrug.wordpress.com
hl7coders.wordpress.com

Test all my code suggestions prior to implementation
Reply With Quote
  #6  
Old 01-22-2012, 12:25 PM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

Quote:
Originally Posted by satyam View Post
Thanks Narupley and Bostad. I am clear with message flow .

I still need some answer on "run on update" statement. It is still confusing me.
My channel is synchronized and it appears that run on update is run after the destinations are processed. But this is not the desired behavior.
That's the expected behaviour; I believe that the "run on update" code will run immediately (and asynchronously) after the query itself if the channel is not synchronized. If the channel is synchronized, then it will run after your postprocessors I think.

A simple way around that would be to change your query code from SQL to JavaScript and make it do whatever you want. I'm not sure, but you may also be able to run multiple statements within the initial query SQL code as well. I always use JavaScript anyway though, so I've never actually tried that.
Reply With Quote
Reply

Tags
channel, database reader, source connector

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 04:05 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation