欢乐:由基于 JS 的数据库编写器中的错误触发的警报无法访问 {messageId}?
Mirth: Alerts triggered by errors in JS-based database writer don't have access to {messageId}?
使用 mirth 版本 3.8.1。我已经为频道的错误设置了警报。当错误来自目标转换器(Javascript)时,警报能够访问 {messageId} 变量并提取正确的 ID。但是,当基于 Javascript 的数据库编写器发生错误时,警报只是 returns '{messageId}' 而不是值。
我尝试了很多东西...
可以从警报访问全局地图,但是在其中放置消息 ID 会被另一个处理线程覆盖。
其他目标类型 - http 发送方、tcp 发送方、通道编写器,甚至是非 javascript 数据库编写器目标都可以工作。
我什至将数据库编写器代码简化为:
var dbConn;
dbConn = DatabaseConnectionFactory.createDatabaseConnection('com.mysql.cj.jdbc.Driver','jdbc:mysql://host:port/dbname','','');
我是否只需要在数据库编写器代码中引发特定异常并在遇到这些异常时引发警报,并在错误字符串中发送消息 ID?
您遇到了一个错误。我开了一个issue and a fix.
如果不是另一个bug that also neglects to provide the messageId, you should be able to use alerts.sendAlert('Custom Error Message')
. alerts
is an instance of AlertSender
from the User API that mirth creates for you. I created a fix也是如此。
我目前知道的手动发送包含 messageId 的警报的唯一解决方法是直接调用 EventController。需要注意的是,这作为 public API 的一部分在技术上不受支持,并且在未来的版本中使用可能会中断,恕不另行通知。
com.mirth.connect.server.controllers.ControllerFactory
.getFactory()
.createEventController()
.dispatchEvent(new com.mirth.connect.donkey.server.event.ErrorEvent(
connectorMessage.getChannelId(),
connectorMessage.getMetaDataId(),
connectorMessage.getMessageId(),
com.mirth.connect.donkey.model.event.ErrorEventType.USER_DEFINED_TRANSFORMER,
connectorMessage.getConnectorName(),
null, /* connectorType */
'A TEST ERROR MESSAGE',
null /* throwable */
)
);
这将在 javascript 模式下从过滤器、转换器、Javascript 写入器或数据库写入器写入。在其他情况下,connectorMessage 不会被定义,您必须以不同的方式提供其中一些值。如果您不需要 messageId 并且不想抛出异常,只需使用 alerts.sendAlert(errorMessage)
因为这不需要调用不受支持的内部 类.
使用 mirth 版本 3.8.1。我已经为频道的错误设置了警报。当错误来自目标转换器(Javascript)时,警报能够访问 {messageId} 变量并提取正确的 ID。但是,当基于 Javascript 的数据库编写器发生错误时,警报只是 returns '{messageId}' 而不是值。
我尝试了很多东西... 可以从警报访问全局地图,但是在其中放置消息 ID 会被另一个处理线程覆盖。 其他目标类型 - http 发送方、tcp 发送方、通道编写器,甚至是非 javascript 数据库编写器目标都可以工作。
我什至将数据库编写器代码简化为:
var dbConn;
dbConn = DatabaseConnectionFactory.createDatabaseConnection('com.mysql.cj.jdbc.Driver','jdbc:mysql://host:port/dbname','','');
我是否只需要在数据库编写器代码中引发特定异常并在遇到这些异常时引发警报,并在错误字符串中发送消息 ID?
您遇到了一个错误。我开了一个issue and a fix.
如果不是另一个bug that also neglects to provide the messageId, you should be able to use alerts.sendAlert('Custom Error Message')
. alerts
is an instance of AlertSender
from the User API that mirth creates for you. I created a fix也是如此。
我目前知道的手动发送包含 messageId 的警报的唯一解决方法是直接调用 EventController。需要注意的是,这作为 public API 的一部分在技术上不受支持,并且在未来的版本中使用可能会中断,恕不另行通知。
com.mirth.connect.server.controllers.ControllerFactory
.getFactory()
.createEventController()
.dispatchEvent(new com.mirth.connect.donkey.server.event.ErrorEvent(
connectorMessage.getChannelId(),
connectorMessage.getMetaDataId(),
connectorMessage.getMessageId(),
com.mirth.connect.donkey.model.event.ErrorEventType.USER_DEFINED_TRANSFORMER,
connectorMessage.getConnectorName(),
null, /* connectorType */
'A TEST ERROR MESSAGE',
null /* throwable */
)
);
这将在 javascript 模式下从过滤器、转换器、Javascript 写入器或数据库写入器写入。在其他情况下,connectorMessage 不会被定义,您必须以不同的方式提供其中一些值。如果您不需要 messageId 并且不想抛出异常,只需使用 alerts.sendAlert(errorMessage)
因为这不需要调用不受支持的内部 类.