web stats
Queue Message on DB Lookup failure - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 12-09-2019, 12:52 PM
shanedewitt shanedewitt is offline
What's HL7?
 
Join Date: May 2013
Posts: 3
shanedewitt is on a distinguished road
Default Queue Message on DB Lookup failure

After recent Mirth upgrade from version 3.5.1 to version 3.5.2, we started to get: Communications link failure when doing a database lookup < 5% of the time.

When I reprocess the message, the code is able to do the lookup.

Old appliance was centos 5 running Mirth 3.5.1. New appliance is centos running Mirth 3.5.2.

Here is my lookup in the transformer:

// doctor number cross-reference
// duz to series lookup
var doctorNumbers = new Array();
var dbConn;
var result;
try {
dbConn = DatabaseConnectionFactory.createDatabaseConnection ('com.mysql.jdbc.Driver', 'jdbc:mysql://servername:3306/doctor_numbers_tst', 'username', 'password');
result = dbConn.executeCachedQuery('SELECT * FROM xref;');
while(result.next()) {
var series = result.getString(1);
var duz = result.getString(2);
var name = result.getString(3);
doctorNumbers[duz] = series;
}
}
finally {
if (dbConn) {
dbConn.close();
}
}

var interpretingProvider = msg['FT1']['FT1.20']['FT1.20.1'].toString();

// replace interpreting provider with value from lookup table
if(typeof doctorNumbers[interpretingProvider] !== 'undefined' ) {
msg['FT1']['FT1.20']['FT1.20.1'] = doctorNumbers[interpretingProvider];
}

var orderingProvider = msg['FT1']['FT1.21']['FT1.21.1'].toString();

// replace ordering provider with value from lookup table
if(typeof doctorNumbers[orderingProvider] !== 'undefined' ) {
msg['FT1']['FT1.21']['FT1.21.1'] = doctorNumbers[orderingProvider];
}

Here is the full error message:

Transformer error
ERROR MESSAGE: Error evaluating transformer
com.mirth.connect.server.MirthJavascriptTransforme rException:
CHANNEL: VISTA Billing to McKesson Live
CONNECTOR: McKesson Series
SCRIPT SOURCE: TRANSFORMER
SOURCE CODE:
126: // duz to series lookup
127: var doctorNumbers = new Array();
128: var dbConn;
129: var result;
130: try {
131: dbConn = DatabaseConnectionFactory.createDatabaseConnection ('com.mysql.jdbc.Driver', 'jdbc:mysql://ohfdb1:3306/doctor_numbers', 'doc_num', 'doc!pass');
132: result = dbConn.executeCachedQuery('SELECT * FROM xref;');
133: while(result.next()) {
134: var series = result.getString(1);
135: var duz = result.getString(2);
LINE NUMBER: 131
DETAILS: Wrapped com.mysql.jdbc.exceptions.jdbc4.CommunicationsExce ption: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at 70109b0b-e2db-494e-8f63-3f6cfc4f10bc:131 (doTransform)
at 70109b0b-e2db-494e-8f63-3f6cfc4f10bc:187 (doScript)
at 70109b0b-e2db-494e-8f63-3f6cfc4f10bc:189
at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:154)
at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:119)
at com.mirth.connect.server.util.javascript.JavaScrip tTask.call(JavaScriptTask.java:113)
at java.util.concurrent.FutureTask.run(FutureTask.jav a:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker( ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsExce ption: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.GeneratedConstructorAccessor360.newIns tance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Construc tor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:40 8)
at com.mysql.jdbc.SQLError.createCommunicationsExcept ion(SQLError.java:1137)
at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:673 )
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:10 85)
at com.mysql.jdbc.ConnectionImpl.coreConnect(Connecti onImpl.java:2494)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(Co nnectionImpl.java:2527)
at com.mysql.jdbc.ConnectionImpl.createNewIO(Connecti onImpl.java:2309)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImp l.java:834)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connect ion.java:46)
at sun.reflect.GeneratedConstructorAccessor99.newInst ance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Construc tor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:40 8)
at com.mysql.jdbc.ConnectionImpl.getInstance(Connecti onImpl.java:419)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonReg isteringDriver.java:344)
at java.sql.DriverManager.getConnection(DriverManager .java:664)
at java.sql.DriverManager.getConnection(DriverManager .java:208)
at com.mirth.connect.server.userutil.DatabaseConnecti on.<init>(DatabaseConnection.java:63)
at com.mirth.connect.server.userutil.DatabaseConnecti onFactory.createDatabaseConnection(DatabaseConnect ionFactory.java:61)
at sun.reflect.GeneratedMethodAccessor85.invoke(Unkno wn Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mozilla.javascript.MemberBox.invoke(MemberBox. java:126)
at org.mozilla.javascript.NativeJavaMethod.call(Nativ eJavaMethod.java:225)
at org.mozilla.javascript.Interpreter.interpretLoop(I nterpreter.java:1479)
at org.mozilla.javascript.Interpreter.interpret(Inter preter.java:815)
at org.mozilla.javascript.InterpretedFunction.call(In terpretedFunction.java:109)
at org.mozilla.javascript.ContextFactory.doTopCall(Co ntextFactory.java:393)
at org.mozilla.javascript.ScriptRuntime.doTopCall(Scr iptRuntime.java:3280)
at org.mozilla.javascript.InterpretedFunction.exec(In terpretedFunction.java:120)
at com.mirth.connect.server.util.javascript.JavaScrip tTask.executeScript(JavaScriptTask.java:150)
at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:143)
... 6 more
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputS tream.java:116)
at java.net.SocketInputStream.read(SocketInputStream. java:171)
at java.net.SocketInputStream.read(SocketInputStream. java:141)
at com.mysql.jdbc.util.ReadAheadInputStream.fill(Read AheadInputStream.java:112)
at com.mysql.jdbc.util.ReadAheadInputStream.readFromU nderlyingStreamIfNecessary(ReadAheadInputStream.ja va:159)
at com.mysql.jdbc.util.ReadAheadInputStream.read(Read AheadInputStream.java:187)
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:3140 )
at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:597 )
... 35 more


We are on support and I put in a ticket, but so fair no solution.
Reply With Quote
  #2  
Old 12-09-2019, 12:56 PM
shanedewitt shanedewitt is offline
What's HL7?
 
Join Date: May 2013
Posts: 3
shanedewitt is on a distinguished road
Default

Since reprocessing the message works, I was wondering if adding this code to a catch block would force the message to Queue.

catch (e) {
if (dbConn) {
dbConn.close();
}
logger.error('Vista Billing to Mckesson Test: Queued message ' + msg['MSH']['MSH.10']['MSH.10.1'].toString() + ' Exception: ' + e);
return responseMap.put(connector, ResponseFactory.getQueuedResponse(msg));
}
Reply With Quote
  #3  
Old 12-09-2019, 01:01 PM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,344
cory_cole is on a distinguished road
Default

try this...

var loopCount = 0; //loopCount is to prevent never ending loop.
while(!dbConn && loopCount < 10)
{
try {
dbConn = DatabaseConnectionFactory.createDatabaseConnection
('com.mysql.jdbc.Driver', 'jdbc:mysql://ohfdb1:3306/doctor_numbers',
'doc_num', 'doc!pass');
}
catch(e)
{
}
loopCount++;
}
Reply With Quote
  #4  
Old 12-10-2019, 11:24 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,058
agermano is on a distinguished road
Default

Any value you return from a transformer is ignored. I have an open feature request for scenarios like this. More votes are welcome. Use the same account info as the forum if you've never signed in to the Jira page before. http://www.mirthcorp.com/community/i...wse/MIRTH-4255

Cory's solution might work for you depending on your situation, but it won't cause your message to queue.

If you want it to queue, how you do that will really depend on your destination type. I have a slightly better solution than the workaround I presented in the ticket. Now for file writers I set a queue flag in the connectorMap and redirect the files to write to /dev/null (or the windows equivalent.) The write is successful, and then in the response transformer I check for the queue flag and change the status from SENT to QUEUED.

This is very easy to do with a javascript writer as you can return a status directly from there. When desired to queue tcp/http senders could write incomplete messages to channels on your local mirth instance that just swallow the data without failing, and then change to queue status.
Reply With Quote
Reply

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 09:58 PM.


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