Page 1 of 1

JiwaPluginSchedulerService.config multiple database issue

PostPosted: Tue Feb 02, 2021 10:54 am
by neil.interactit
Hi guys,

I have issues on a server running file watcher plugins for 2 databases. In checking for solutions I found this was fixed here https://service.jiwa.com.au/browse/DEV-3231, however I'm still running into problems.

Code: Select all
JiwaPluginSchedulerService.exe.config:
    <Databases>
      <Database>
        <DatabaseName>Jiwa1</DatabaseName>
        <ServerName>IIT-SQL</ServerName>
        <JiwaUsername>***</JiwaUsername>
        <JiwaPassword>***</JiwaPassword>
      </Database>
      <Database>
        <DatabaseName>Jiwa2</DatabaseName>
        <ServerName>IIT-SQL</ServerName>
        <JiwaUsername>***</JiwaUsername>
        <JiwaPassword>***</JiwaPassword>
      </Database>
    </Databases>

The TonerUsage file watcher plugin runs on Jiwa1
The PrintUsage file watcher plugin runs on Jiwa2

With the above config, TonerUsage works correctly (ie. with Jiwa2 also in the config) however PrintUsage fails. If Jiwa1 is removed from the config, the PrintUsage works correctly.

The specific error is "Invalid object name 'Addin_Printers'." which refers to an extra table that I have manually added to Jiwa2. I access Addin_Printers as follows (simplified):

Code: Select all
        var row = Helper.SqlDataRow("SELECT TOP 1 * FROM Addin_Printers");

        public static DataRow SqlDataRow(string sql, SqlParameter[] paramList = null)
        {
            var table = new DataTable();
            var database = Manager.Database;
            var connection = database.SQLConnection;
            try
            {
                using (var sqlCmd = new SqlCommand(sql, connection, database.SQLTransaction))
                {
                    if (paramList != null) sqlCmd.Parameters.AddRange(paramList);
                    table.Load(sqlCmd.ExecuteReader());
                }
                return table.Rows.Count == 0 ? null : table.Rows[0];
            }
        }

It "feels" as though, with the config as shown above, that this code is accessing Jiwa1 instead of Jiwa2, and not finding Addin_Printers.

Could you advise where I'm going astray?

Cheers,
Neil

Re: JiwaPluginSchedulerService.config multiple database issu  Topic is solved

PostPosted: Tue Feb 02, 2021 6:16 pm
by Mike.Sheen
Hard to say without setting up the same scenario ourselves and testing with your plugins.

Before we do that, you might want to consider splitting your Plugin Scheduler into two different services - it can make things a bit more manageable - especially when performing maintenance or moving things around - and I bet it makes your problem go away.

You do this by following the instructions here.

Back to troubleshooting the problem - can you give me two plugins I can run in two demo databases which shows the problem? I'll also need a script to create your table that one of your plugins refers to.

Re: JiwaPluginSchedulerService.config multiple database issu

PostPosted: Wed Feb 03, 2021 10:11 am
by neil.interactit
Thanks Mike.

We'll split the services.

For troubleshooting, I've emailed you the files.

Cheers,
Neil

Re: JiwaPluginSchedulerService.config multiple database issu

PostPosted: Thu Feb 04, 2021 6:52 am
by pricerc
Mike.Sheen wrote:Before we do that, you might want to consider splitting your Plugin Scheduler into two different services -

...

You do this by following the instructions here.



It might be sufficient to just make a copy of the scheduler exe and config, instead of the whole folder.