Skip to main content

Hello,

We have a batch application that is doing some background process.

So far for this batch application, we need to add an infinite loop in trigger ApStart like:
while (1)
  ; do some background process
  activate "BACKGROUND".backgroupdprocess()
  ; sleep some time
  sleep (10000)
endwhile

If we don't add this loop in the apStart trigger, the applications stops immediately at the end of the trigger.

Problem is then that we cannot have a timer working : the receiveMessage trigger is never fired.

Is there any other way to start a batch application and prevents it from stopping unless we use the apexit instruction ?

Or is there any other reason that the receiveMessage trigger is not fired ?

Thanks,

Stephane



------------------------------
Stephane Pfefer
Information Technology Manager
It Services B.V.
------------------------------

Hello,

We have a batch application that is doing some background process.

So far for this batch application, we need to add an infinite loop in trigger ApStart like:
while (1)
  ; do some background process
  activate "BACKGROUND".backgroupdprocess()
  ; sleep some time
  sleep (10000)
endwhile

If we don't add this loop in the apStart trigger, the applications stops immediately at the end of the trigger.

Problem is then that we cannot have a timer working : the receiveMessage trigger is never fired.

Is there any other way to start a batch application and prevents it from stopping unless we use the apexit instruction ?

Or is there any other reason that the receiveMessage trigger is not fired ?

Thanks,

Stephane



------------------------------
Stephane Pfefer
Information Technology Manager
It Services B.V.
------------------------------

Hi Stephane,

The Uniface StartUpShell, also called Uniface Application, it is an external shell enabling to start your first component, into ApStart trigger.

In a desktop application this first component is usually a form while in a batch application is a service or an hidden form (no edit nor display instruction into Execute trigger).

Hope this help.

Regards,
Gianni



------------------------------
Gianni Sandigliano
IT
------------------------------

Hi Stephane,

The Uniface StartUpShell, also called Uniface Application, it is an external shell enabling to start your first component, into ApStart trigger.

In a desktop application this first component is usually a form while in a batch application is a service or an hidden form (no edit nor display instruction into Execute trigger).

Hope this help.

Regards,
Gianni



------------------------------
Gianni Sandigliano
IT
------------------------------

Hi Gianni,

Thanks for your answer.

Unfortunately, I still cannot get it work.

I created this apStart trigger in the Application Shell

trigger apStart
putmess "apStart trigger"
putmess "Call SPU10FRM"
newinstance "SPU10FRM", "SPU10FRM"
activate "SPU10FRM".exec()
apStart ; optional tried with or without. No change
end

And a form SPU10FRM with one Dummy entiry and its exec trigger:
operation exec
putmess("SPU10FRM Exec")
newinstance "UTIMER", "UTIMER"
activate "UTIMER".setMessage("SPU10FRM", "Timer", "Wake-up!")
activate "UTIMER".setRepeat(0)
activate "UTIMER".start("00:00:01")
putmess("status: %%$status procerror: %%$procerror")
putmess("SPU10FRM Fin Exec")
end

When I launch the application as a batch (Red Hat 8 Server), it starts and stops at the end of the apStart trigger.

Is there anything that I am missing here?

Thanks

Stephane



------------------------------
Stephane Pfefer
Information Technology Manager
It Services B.V.
------------------------------

Hi Gianni,

Thanks for your answer.

Unfortunately, I still cannot get it work.

I created this apStart trigger in the Application Shell

trigger apStart
putmess "apStart trigger"
putmess "Call SPU10FRM"
newinstance "SPU10FRM", "SPU10FRM"
activate "SPU10FRM".exec()
apStart ; optional tried with or without. No change
end

And a form SPU10FRM with one Dummy entiry and its exec trigger:
operation exec
putmess("SPU10FRM Exec")
newinstance "UTIMER", "UTIMER"
activate "UTIMER".setMessage("SPU10FRM", "Timer", "Wake-up!")
activate "UTIMER".setRepeat(0)
activate "UTIMER".start("00:00:01")
putmess("status: %%$status procerror: %%$procerror")
putmess("SPU10FRM Fin Exec")
end

When I launch the application as a batch (Red Hat 8 Server), it starts and stops at the end of the apStart trigger.

Is there anything that I am missing here?

Thanks

Stephane



------------------------------
Stephane Pfefer
Information Technology Manager
It Services B.V.
------------------------------
I suspect you can't do exactly what you plan to do here, because the UTIMER sends an async message to the target, which is then caught when it is in 'idle' in the UI. Batch applications have no UI and therefore are never idle. 
Maybe we need to back up a step and see what you want to actually do when the message is received, and see if we can get to doing that somehow?

I presume this is to do something like 'scheduled tasks' in windows? Or is it a 'spooler' kind of affair where it waits for messages from another running copy of uniface?

------------------------------
Iain Sharp
Head of Technical Services
Pci Systems Ltd
Sheffield GB
------------------------------
I suspect you can't do exactly what you plan to do here, because the UTIMER sends an async message to the target, which is then caught when it is in 'idle' in the UI. Batch applications have no UI and therefore are never idle. 
Maybe we need to back up a step and see what you want to actually do when the message is received, and see if we can get to doing that somehow?

I presume this is to do something like 'scheduled tasks' in windows? Or is it a 'spooler' kind of affair where it waits for messages from another running copy of uniface?

------------------------------
Iain Sharp
Head of Technical Services
Pci Systems Ltd
Sheffield GB
------------------------------
Hello Iain,

So you confirm that in order to have the batch running all the time, I need to have an infinite loop like
while (1)
  ; do whatever it has  to do
  sleep(1000)  ; wait some time before doing anything else
endwhile

Thanks

Stephane



------------------------------
Stephane Pfefer
Information Technology Manager
It Services B.V.
------------------------------
Hello Iain,

So you confirm that in order to have the batch running all the time, I need to have an infinite loop like
while (1)
  ; do whatever it has  to do
  sleep(1000)  ; wait some time before doing anything else
endwhile

Thanks

Stephane



------------------------------
Stephane Pfefer
Information Technology Manager
It Services B.V.
------------------------------
Assuming you want something to 'heartbeat' every 10 seconds then yes. 
Regards, 
Iain

------------------------------
Iain Sharp
Head of Technical Services
Pci Systems Ltd
Sheffield GB
------------------------------
Hello Iain,

So you confirm that in order to have the batch running all the time, I need to have an infinite loop like
while (1)
  ; do whatever it has  to do
  sleep(1000)  ; wait some time before doing anything else
endwhile

Thanks

Stephane



------------------------------
Stephane Pfefer
Information Technology Manager
It Services B.V.
------------------------------

Hi Stephane,

my gotfeel after reading this thread is "you are conceptually in the middle of the river".

IMHO you should first of all clarify to yourself if you want to build a Uniface batch application or a Uniface batch scheduler.

They are two different Uniface objects, there are many ways to implement them but substantially:
- A Uniface batch scheduler every X seconds it checks if should start a Uniface batch application; its scheduling is probably saved into a DBMS table. It runs forever, probably sleeping like in your answer, until it receives a command to exit, probably via interprocess communication.
- A Uniface batch application is started from the Uniface scheduler, somehow update its state on scheduler DBMS table then execute its task and finally somehow update again its state on scheduler DBMS table and then it exits.

Hope this helps.

Best Regards,
Gianni



------------------------------
Gianni Sandigliano
IT
------------------------------

Hello,

We have a batch application that is doing some background process.

So far for this batch application, we need to add an infinite loop in trigger ApStart like:
while (1)
  ; do some background process
  activate "BACKGROUND".backgroupdprocess()
  ; sleep some time
  sleep (10000)
endwhile

If we don't add this loop in the apStart trigger, the applications stops immediately at the end of the trigger.

Problem is then that we cannot have a timer working : the receiveMessage trigger is never fired.

Is there any other way to start a batch application and prevents it from stopping unless we use the apexit instruction ?

Or is there any other reason that the receiveMessage trigger is not fired ?

Thanks,

Stephane



------------------------------
Stephane Pfefer
Information Technology Manager
It Services B.V.
------------------------------
Hi Stephane,

What a newinstance :-)

newinstance "BACKGROUND",v_INST_BACKGROUND
activate v_INST_BACKGROUND."backgroupdprocess"()

Ingo

------------------------------
Ingo Stiller
Aareon Deutschland GmbH
------------------------------

Hi Stephane,

my gotfeel after reading this thread is "you are conceptually in the middle of the river".

IMHO you should first of all clarify to yourself if you want to build a Uniface batch application or a Uniface batch scheduler.

They are two different Uniface objects, there are many ways to implement them but substantially:
- A Uniface batch scheduler every X seconds it checks if should start a Uniface batch application; its scheduling is probably saved into a DBMS table. It runs forever, probably sleeping like in your answer, until it receives a command to exit, probably via interprocess communication.
- A Uniface batch application is started from the Uniface scheduler, somehow update its state on scheduler DBMS table then execute its task and finally somehow update again its state on scheduler DBMS table and then it exits.

Hope this helps.

Best Regards,
Gianni



------------------------------
Gianni Sandigliano
IT
------------------------------

Thanks for your help Iain and Gianni,

Actually we already have a batch application that is running as a scheduler.

We use a loop with a wake-up every minute and we check in the database whether there are some tasks to be run.

I was expecting to improve it by changing the wake-up mechanism (timer instead of loop/sleep) but also mostly being able to wake it up through interprocess communication: a userver would be able to wake-up the scheduler in order to start a task before its planned schedule.

I guess that this won't be possible and the only solution will be for the userver to change the start date in the database and wait for the scheduler to get out of its 1 minute sleep.

Thanks again for your help.



------------------------------
Stephane Pfefer
Information Technology Manager
It Services B.V.
------------------------------

Thanks for your help Iain and Gianni,

Actually we already have a batch application that is running as a scheduler.

We use a loop with a wake-up every minute and we check in the database whether there are some tasks to be run.

I was expecting to improve it by changing the wake-up mechanism (timer instead of loop/sleep) but also mostly being able to wake it up through interprocess communication: a userver would be able to wake-up the scheduler in order to start a task before its planned schedule.

I guess that this won't be possible and the only solution will be for the userver to change the start date in the database and wait for the scheduler to get out of its 1 minute sleep.

Thanks again for your help.



------------------------------
Stephane Pfefer
Information Technology Manager
It Services B.V.
------------------------------

Hi Stephane,

I went into same issue in the past and my solution was like this:
- I have taken the sleep period variable based on scheduler status but never too long (from 2 secs up to 10 secs)
- my wakeUp method "on the need" was to add a specific occurrence in the scheduler DBMS table to be "executed immediately"

In the worst case the application functionality to be executed immediately was executed within 10 secs and this was considered acceptable from the customer.

Hope it helps.

Regards,
Gianni



------------------------------
Gianni Sandigliano
IT
------------------------------

Hi Stephane,

I went into same issue in the past and my solution was like this:
- I have taken the sleep period variable based on scheduler status but never too long (from 2 secs up to 10 secs)
- my wakeUp method "on the need" was to add a specific occurrence in the scheduler DBMS table to be "executed immediately"

In the worst case the application functionality to be executed immediately was executed within 10 secs and this was considered acceptable from the customer.

Hope it helps.

Regards,
Gianni



------------------------------
Gianni Sandigliano
IT
------------------------------

Yes I think that we will end with this solution that fits perfectly the functional need.

Thanks

Stephane



------------------------------
Stephane Pfefer
Information Technology Manager
It Services B.V.
------------------------------