我需要在通道读取器中从数据库中读取一个 blob 字段,然后通过 TCP 发送它。
我可以使用数据库阅读器轻松完成此操作,除非我有 Blob 字段,因此我尝试使用 JavaScript 阅读器:
var dbConn = DatabaseConnectionFactory.createDatabaseConnection('org.postgresql.Driver','jdbc:postgresql://127.0.0.1:5432/ris','postgres','postgres');
// You may access this result below with $('column_name')
var resultQuery = "select mensajehl7, p.ip, p.port from turnohl7 h7 join pacs p on p.idpacs=h7.idpacs where h7.estado='NW'";
var qryResult = dbConn.executeCachedQuery(resultQuery);
var result = new Packages.java.util.ArrayList();
while(qryResult.next())
{
var columna = new Array();
columna['hl7'] = qryResult.getBytes(1);
result.add(columna);
}
dbConn.close();
return result;
正如堆栈跟踪所暗示的,结果似乎需要是一个 XML:
[2012-12-04 12:56:29,227] ERROR (org.mule.impl.DefaultComponentExceptionStrategy:95): Caught exception in Exception Strategy for: f4a3cccb-902e-4504-86f5-0bfa473ad144: org.mule.umo.routing.RoutingException: Failed to transform message before applying the filter. Failed to route event via endpoint: ImmutableMuleEndpoint{connector=com.mirth.connect.connectors.js.JavaScriptConnector@379cf50c, endpointUri=js://sink, transformer=Transformer{name='ResultMapToXML', returnClass=false, returnClass=false, sourceTypes=[interface java.util.Map, class java.lang.String]}, name='_jsEndpoint#-1389160782', type='receiver', properties={}, transactionConfig=org.mule.impl.MuleTransactionConfig@44adab2d, filter=null, deleteUnacceptedMessages=false, initialised=true, securityFilter=null, synchronous=true, initialState=started, createConnector=0}. Message payload is of type: java.lang.String
org.mule.umo.routing.RoutingException: Failed to transform message before applying the filter. Failed to route event via endpoint: ImmutableMuleEndpoint{connector=com.mirth.connect.connectors.js.JavaScriptConnector@379cf50c, endpointUri=js://sink, transformer=Transformer{name='ResultMapToXML', returnClass=false, returnClass=false, sourceTypes=[interface java.util.Map, class java.lang.String]}, name='_jsEndpoint#-1389160782', type='receiver', properties={}, transactionConfig=org.mule.impl.MuleTransactionConfig@44adab2d, filter=null, deleteUnacceptedMessages=false, initialised=true, securityFilter=null, synchronous=true, initialState=started, createConnector=0}. Message payload is of type: java.lang.String
at org.mule.routing.inbound.SelectiveConsumer.isMatch(SelectiveConsumer.java:64)
at org.mule.routing.inbound.InboundMessageRouter.route(InboundMessageRouter.java:79)
at org.mule.providers.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:487)
at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:266)
at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:225)
at com.mirth.connect.connectors.js.JavaScriptMessageReceiver.processMessage(JavaScriptMessageReceiver.java:101)
at com.mirth.connect.connectors.js.JavaScriptMessageReceiver.poll(JavaScriptMessageReceiver.java:82)
at org.mule.providers.PollingMessageReceiver.run(PollingMessageReceiver.java:97)
at org.mule.impl.work.WorkerContext.run(WorkerContext.java:290)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
at java.lang.Thread.run(Unknown Source)Caused by: org.mule.umo.transformer.TransformerException: java.lang.StringIndexOutOfBoundsException: String index out of range: -2 (com.mirth.connect.server.mule.adaptors.AdaptorException)
at com.mirth.connect.server.mule.transformers.JavaScriptTransformer.transform(JavaScriptTransformer.java:285)
at org.mule.transformers.AbstractEventAwareTransformer.doTransform(AbstractEventAwareTransformer.java:48)
at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:197)
at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:200)
at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:200)
如何在变压器中使用我的 bytea 字段?