Jimmy

If you use the Comments section you eliminate the need to create your own custom routing engine.

Your ProcessMessage approach still should work.

Given your custom RoutingEngine includes the following statements:

Property ProcessMessage As %Boolean;

Parameter SETTINGS = "ProcessMessage:Catagory";

And if you issue a:

select Settings from Ens_Config.Item where Production = ‘YourProduction’

 and Name = ‘YourProcessName’

Do you see “ProcessMessage” in Settings List?

The Settings are stored in Ens_Config.Item and can be retrieved  with

ClassMethod GetAdapterSettingValue() or ClassMethod GetHostSettingValue()

set SourceConfigName = "YourCustomRouter”  ;Must be enabled when non-unique

Set tSetting = "ProcessMessage"

Set tHostSettingValue=##class(Ens.Director).GetHostSettingValue(##class(Ens.Director).GetActiveProductionName()_"||"_SourceConfigName,tSetting,.tSC)

write !,"System.Status.GetErrorCodes "_$System.Status.GetErrorCodes(.tSC)_" : "_$System.Status.GetOneStatusText(.tSC)

write !,tSetting_" = ("_tHostSettingValue_") tSC=("_tSC_")"

Waren, it is possible to pass messages to a business service via a scheduled task.

Create a Class that extends %SYS.Task.Definition. This will be the class executed by Task Manager.
Include Ensemble
/// Task to trigger the business service 
Class Sample.Util.Task.PatientService Extends (%SYS.Task.Definition, %Persistent) [ Inheritance = right ]
{
Parameter TaskName = "Sample.Util.Task.PatientService";
Method OnTask() As %Status
{
    SET qStatement = ##class(%SQL.Statement).%New()
    SET qStatus = qStatement.%Prepare("Select Distinct by (PatientId)  PatientId,PatientNameLast,PatientNameMiddle,PatientNameFirst,PatientAddress1,PatientAddress2,PatientCity,PatientState,PatientZipCode,PatientSexCode,PatientDateOfBirth,PatientRace,PatientPhone,PatientSSN,PatientMaritalStatus,PatientAdmissionDate,PatientDept from PREVOST_AthenaHealth.Patient Order by PatientId")
    IF qStatus'=1
    {
        WRITE !,"%Prepare failed",$System.Status.DisplayError(qStatus)
        Quit $$$ERROR($System.Status.GetErrorCodes(qStatus),$System.Status.GetErrorText(qStatus))
    }
    Set rset = qStatement.%Execute()
    set k0=0
    WHILE rset.%Next()
    {
        Set target=##class(EnsLib.HL7.Message).%New()
        .
        .
        .
        Set tSC=##class(Ens.Director).CreateBusinessService("Sample.AthenaHealth.PatientService",.tService)
        Set tSC=tService.ProcessInput(target) ; call ProcessInput(target) to send the transaction to the BS
    }
    Quit $$$OK
}

}


Create a class for your Business Service.
/// 
Class Sample.AthenaHealth.PatientService Extends Ens.BusinessService [ ProcedureBlock ]
{
/// Name of a Business Partner Profile associated with this item
Property BusinessPartner As %String(MAXLEN = 128);
/// Configuration item(s) to which to send messages
Property TargetConfigNames As %String(MAXLEN = 2000);
Parameter SETTINGS = "BusinessPartner:Info:partnerSelector,TargetConfigNames:Basic:selector?multiSelect=0&context={Ens.ContextSearch/ProductionItems?targets=1&productionName=@productionId}";
Method OnProcessInput(tResult As EnsLib.HL7.Message, Output pOutput As %RegisteredObject) As %Status
{
    ;Only route to 1st TargetConfigName
    Set SC = ..SendRequestAsync($piece(..TargetConfigNames,","),tResult)
    Quit $$$OK
}

}

Create a Business Service using your newly defined class in your Production.
<Item Name=“Sample.AthenaHealth.PatientService" Category="PREVOST" ClassName=“Sample.AthenaHealth.PatientService" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
    <Setting Target="Host" Name="TargetConfigNames">HL7MsgRouter</Setting>
    <Setting Target="Host" Name="BusinessPartner">A60</Setting>
  </Item>