Hi- I'm looking for some design pattern suggestions. I have a Jaguar method which executes very slowly. Whether or not the method executes properly is irrelevant to my client; therefore, I want some sort of "fire and forget" design pattern. I understand spawning a new thread in the Jaguar component will not work and causes problems in the server. I have looked at the asynchronous Events sample, and can see that I might be able to use some variation on the technique. However, in the example, there is a separate application responsible for handling a queue of requests (and in a sense has the desired affect of creating the separate request handling thread.) How can I achieve a similar model inside Jaguar (without having to create a separate "server" app)? My initial idea would be to create a scheduled jaguar service which runs in an infinite loop, waiting for notification of changes to the queue, and processing them as they occur. However, I'm not sure how one can create a schedule service which runs only once (basically, after server start up.) Thanks in advance for your suggestions, Randy
![]() |
0 |
![]() |
In your case where quality of service is not an issue, why not have a single queue component which runs as a service. In this service component store a message inside a stack. In the run() method, wake up every few mintes and check the stack, popping jobs off as they come. For better quality of service, put it in a database table rather than a stack. We are looking into being able to spawn a user defined number of any service component so you could have say a dozen of these dispatchers checking the same queue (static member). Would this work? The other option is an async thread on the client side. Dave Wolf EAServer Product Team Randy Puro wrote: > Hi- > I'm looking for some design pattern suggestions. I have a Jaguar method > which executes very slowly. Whether or not the method executes properly > is irrelevant to my client; therefore, I want some sort of "fire and > forget" design pattern. I understand spawning a new thread in the > Jaguar component will not work and causes problems in the server. I > have looked at the asynchronous Events sample, and can see that I might > be able to use some variation on the technique. However, in the > example, there is a separate application responsible for handling a > queue of requests (and in a sense has the desired affect of creating the > separate request handling thread.) How can I achieve a similar model > inside Jaguar (without having to create a separate "server" app)? > > My initial idea would be to create a scheduled jaguar service which runs > in an infinite loop, waiting for notification of changes to the queue, > and processing them as they occur. However, I'm not sure how one can > create a schedule service which runs only once (basically, after server > start up.) > > Thanks in advance for your suggestions, > > Randy
![]() |
0 |
![]() |
Actually if you want a service component to run only once, dont loop inside run(). This will accomplish that. so public class SillServiceImpl { public void start() {} public void stop() {} public void run() { System.out.println("Just wanted to say hello!"); } } Dave Wolf EAServer Product Team markf wrote: > Randy, > How about specifying a handler to respond to Jaguars Start event handler ? > This is trggered when a request to start the jaguar server is made > Would that meet your objective to: > >create a schedule service which runs only once (basically, after server > >start up.) ? > > hndler launching your process > Randy Puro wrote in message <365A0B97.857E59C4@sybase.com>... > >Hi- > >I'm looking for some design pattern suggestions. I have a Jaguar method > >which executes very slowly. Whether or not the method executes properly > >is irrelevant to my client; therefore, I want some sort of "fire and > >forget" design pattern. I understand spawning a new thread in the > >Jaguar component will not work and causes problems in the server. I > >have looked at the asynchronous Events sample, and can see that I might > >be able to use some variation on the technique. However, in the > >example, there is a separate application responsible for handling a > >queue of requests (and in a sense has the desired affect of creating the > >separate request handling thread.) How can I achieve a similar model > >inside Jaguar (without having to create a separate "server" app)? > > > >My initial idea would be to create a scheduled jaguar service which runs > >in an infinite loop, waiting for notification of changes to the queue, > >and processing them as they occur. However, I'm not sure how one can > >create a schedule service which runs only once (basically, after server > >start up.) > > > >Thanks in advance for your suggestions, > > > >Randy
![]() |
0 |
![]() |
Randy, How about specifying a handler to respond to Jaguars Start event handler ? This is trggered when a request to start the jaguar server is made Would that meet your objective to: >create a schedule service which runs only once (basically, after server >start up.) ? hndler launching your process Randy Puro wrote in message <365A0B97.857E59C4@sybase.com>... >Hi- >I'm looking for some design pattern suggestions. I have a Jaguar method >which executes very slowly. Whether or not the method executes properly >is irrelevant to my client; therefore, I want some sort of "fire and >forget" design pattern. I understand spawning a new thread in the >Jaguar component will not work and causes problems in the server. I >have looked at the asynchronous Events sample, and can see that I might >be able to use some variation on the technique. However, in the >example, there is a separate application responsible for handling a >queue of requests (and in a sense has the desired affect of creating the >separate request handling thread.) How can I achieve a similar model >inside Jaguar (without having to create a separate "server" app)? > >My initial idea would be to create a scheduled jaguar service which runs >in an infinite loop, waiting for notification of changes to the queue, >and processing them as they occur. However, I'm not sure how one can >create a schedule service which runs only once (basically, after server >start up.) > >Thanks in advance for your suggestions, > >Randy
![]() |
0 |
![]() |
The message below states that: "I understand spawning a new thread in the >> >Jaguar component will not work and causes problems in the server. " Which I would take to mean "You must not create a new thread programatically in a Java component". I cannot find any reference to this in the documentation, so I would appreciate it if someone could confirm whether or not this is the case, or direct me to documentation that does so. Thanks, Ian Leader On Wed, 16 Dec 1998 17:09:18 -0500, in powersoft.public.easerver David Wolf <dwolf@sybase.com> wrote: >Actually if you want a service component to run only once, dont loop inside >run(). This will accomplish that. > >so > >public class SillServiceImpl >{ > public void start() > {} > public void stop() > {} > > public void run() > { > System.out.println("Just wanted to say hello!"); > } >} > >Dave Wolf >EAServer Product Team > >markf wrote: > >> Randy, >> How about specifying a handler to respond to Jaguars Start event handler ? >> This is trggered when a request to start the jaguar server is made >> Would that meet your objective to: >> >create a schedule service which runs only once (basically, after server >> >start up.) ? >> >> hndler launching your process >> Randy Puro wrote in message <365A0B97.857E59C4@sybase.com>... >> >Hi- >> >I'm looking for some design pattern suggestions. I have a Jaguar method >> >which executes very slowly. Whether or not the method executes properly >> >is irrelevant to my client; therefore, I want some sort of "fire and >> >forget" design pattern. I understand spawning a new thread in the >> >Jaguar component will not work and causes problems in the server. I >> >have looked at the asynchronous Events sample, and can see that I might >> >be able to use some variation on the technique. However, in the >> >example, there is a separate application responsible for handling a >> >queue of requests (and in a sense has the desired affect of creating the >> >separate request handling thread.) How can I achieve a similar model >> >inside Jaguar (without having to create a separate "server" app)? >> > >> >My initial idea would be to create a scheduled jaguar service which runs >> >in an infinite loop, waiting for notification of changes to the queue, >> >and processing them as they occur. However, I'm not sure how one can >> >create a schedule service which runs only once (basically, after server >> >start up.) >> > >> >Thanks in advance for your suggestions, >> > >> >Randy >
![]() |
0 |
![]() |
This is the case, and unfortunatly did not make it into the documentation. We have corrected the documentation and are working on two solutions: 1) In the current EBF to 2.0, we have included the ability to spawn X instances of a service component. Since a service component is a shared instance (singleton) You will have X threads running in it concurrently 2) In the next EBF, we will have added a property to the Java ORB to allow you to specify you are inside Jaguar. Rather than using the in-memory orb/marshalling, this will force the ORB runtime to reconnect to jaguar as if it was a client itself, this alleviating the issue. Dave Wolf EAServer Product Team Ian Leader wrote: > The message below states that: > > "I understand spawning a new thread in the > >> >Jaguar component will not work and causes problems in the server. " > > Which I would take to mean "You must not create a new thread programatically in > a Java component". > > I cannot find any reference to this in the documentation, so I would appreciate > it if someone could confirm whether or not this is the case, or direct me to > documentation that does so. > > Thanks, > > Ian Leader > > On Wed, 16 Dec 1998 17:09:18 -0500, > in powersoft.public.easerver > David Wolf <dwolf@sybase.com> wrote: > >Actually if you want a service component to run only once, dont loop inside > >run(). This will accomplish that. > > > >so > > > >public class SillServiceImpl > >{ > > public void start() > > {} > > public void stop() > > {} > > > > public void run() > > { > > System.out.println("Just wanted to say hello!"); > > } > >} > > > >Dave Wolf > >EAServer Product Team > > > >markf wrote: > > > >> Randy, > >> How about specifying a handler to respond to Jaguars Start event handler ? > >> This is trggered when a request to start the jaguar server is made > >> Would that meet your objective to: > >> >create a schedule service which runs only once (basically, after server > >> >start up.) ? > >> > >> hndler launching your process > >> Randy Puro wrote in message <365A0B97.857E59C4@sybase.com>... > >> >Hi- > >> >I'm looking for some design pattern suggestions. I have a Jaguar method > >> >which executes very slowly. Whether or not the method executes properly > >> >is irrelevant to my client; therefore, I want some sort of "fire and > >> >forget" design pattern. I understand spawning a new thread in the > >> >Jaguar component will not work and causes problems in the server. I > >> >have looked at the asynchronous Events sample, and can see that I might > >> >be able to use some variation on the technique. However, in the > >> >example, there is a separate application responsible for handling a > >> >queue of requests (and in a sense has the desired affect of creating the > >> >separate request handling thread.) How can I achieve a similar model > >> >inside Jaguar (without having to create a separate "server" app)? > >> > > >> >My initial idea would be to create a scheduled jaguar service which runs > >> >in an infinite loop, waiting for notification of changes to the queue, > >> >and processing them as they occur. However, I'm not sure how one can > >> >create a schedule service which runs only once (basically, after server > >> >start up.) > >> > > >> >Thanks in advance for your suggestions, > >> > > >> >Randy > >
![]() |
0 |
![]() |
Dave, Having read your response, I now think our situation is slightly different from Randy's. We are not trying to spawn a new thread & then instanciate another Jaguar component instance, nor are we trying to get a Jaguar method to return while leaving a thread running. Instead, we are writing a component which uses a single instance of a third party java class, which spawns 3 new threads in its constructor, but does not clean them up properly. This was causing problems with memory leakage, so we used the EJB interface to create a pool of up to n (currently 10) components created on demand, which are pooled (canReuse() method always returns true), and therefore persist until the server is shut down. So far this design *appears* to work correctly - memory usages is exactly as expected, and we can manage resource usage by limiting the maximum number of components running, and rejecting further requests to instanciate components when this number has been reached. Two questions: 1. Using this design, do you thing we will have any unexpected problems due to the creation of these threads by the third party class. 2. How are you meant to spawn additional service components in the model you describe in point 1 below. Thanks, Ian Leader. On Mon, 21 Dec 1998 09:24:24 -0500, in powersoft.public.easerver David Wolf <dwolf@sybase.com> wrote: >This is the case, and unfortunatly did not make it into the documentation. We have >corrected the documentation and are working on two solutions: > >1) In the current EBF to 2.0, we have included the ability to spawn X instances of >a service component. Since a service component is a shared instance (singleton) >You will have X threads running in it concurrently > >2) In the next EBF, we will have added a property to the Java ORB to allow you to >specify you are inside Jaguar. Rather than using the in-memory orb/marshalling, >this will force the ORB runtime to reconnect to jaguar as if it was a client >itself, this alleviating the issue. > >Dave Wolf >EAServer Product Team > >Ian Leader wrote: > >> The message below states that: >> >> "I understand spawning a new thread in the >> >> >Jaguar component will not work and causes problems in the server. " >> >> Which I would take to mean "You must not create a new thread programatically in >> a Java component". >> >> I cannot find any reference to this in the documentation, so I would appreciate >> it if someone could confirm whether or not this is the case, or direct me to >> documentation that does so. >> >> Thanks, >> >> Ian Leader >> >> On Wed, 16 Dec 1998 17:09:18 -0500, >> in powersoft.public.easerver >> David Wolf <dwolf@sybase.com> wrote: >> >Actually if you want a service component to run only once, dont loop inside >> >run(). This will accomplish that. >> > >> >so >> > >> >public class SillServiceImpl >> >{ >> > public void start() >> > {} >> > public void stop() >> > {} >> > >> > public void run() >> > { >> > System.out.println("Just wanted to say hello!"); >> > } >> >} >> > >> >Dave Wolf >> >EAServer Product Team >> > >> >markf wrote: >> > >> >> Randy, >> >> How about specifying a handler to respond to Jaguars Start event handler ? >> >> This is trggered when a request to start the jaguar server is made >> >> Would that meet your objective to: >> >> >create a schedule service which runs only once (basically, after server >> >> >start up.) ? >> >> >> >> hndler launching your process >> >> Randy Puro wrote in message <365A0B97.857E59C4@sybase.com>... >> >> >Hi- >> >> >I'm looking for some design pattern suggestions. I have a Jaguar method >> >> >which executes very slowly. Whether or not the method executes properly >> >> >is irrelevant to my client; therefore, I want some sort of "fire and >> >> >forget" design pattern. I understand spawning a new thread in the >> >> >Jaguar component will not work and causes problems in the server. I >> >> >have looked at the asynchronous Events sample, and can see that I might >> >> >be able to use some variation on the technique. However, in the >> >> >example, there is a separate application responsible for handling a >> >> >queue of requests (and in a sense has the desired affect of creating the >> >> >separate request handling thread.) How can I achieve a similar model >> >> >inside Jaguar (without having to create a separate "server" app)? >> >> > >> >> >My initial idea would be to create a scheduled jaguar service which runs >> >> >in an infinite loop, waiting for notification of changes to the queue, >> >> >and processing them as they occur. However, I'm not sure how one can >> >> >create a schedule service which runs only once (basically, after server >> >> >start up.) >> >> > >> >> >Thanks in advance for your suggestions, >> >> > >> >> >Randy >> > >
![]() |
0 |
![]() |
The issue isnt with user created threads, but rather with intercomponent calls from within these threads. I dont think you'll have any issues. This works fine: public class SillyThread extends Thread { public void run() { try { com.sybase.jaguar.server.Jaguar.writeLog("Hello!"); } catch(Exception e) {} } public class SillyComponentImpl { public void beSilly() { new SillyThread().start(); com.sybase.jaguar.server.Jaguar.getInstanceContext().completeWork(); } } As for point two, you would set the property for the service component, in the server's All Properties tab as: com.sybase.jaguar.server.services=Package/Component[20] To start 20 threads inside the service component. I do have a question. How are you limiting the number of pooled components? Dave Wolf EAServer Product Team Ian Leader wrote: > Dave, > > Having read your response, I now think our situation is slightly different from > Randy's. We are not trying to spawn a new thread & then instanciate another > Jaguar component instance, nor are we trying to get a Jaguar method to return > while leaving a thread running. > > Instead, we are writing a component which uses a single instance of a third > party java class, which spawns 3 new threads in its constructor, but does not > clean them up properly. This was causing problems with memory leakage, so we > used the EJB interface to create a pool of up to n (currently 10) components > created on demand, which are pooled (canReuse() method always returns true), and > therefore persist until the server is shut down. > > So far this design *appears* to work correctly - memory usages is exactly as > expected, and we can manage resource usage by limiting the maximum number of > components running, and rejecting further requests to instanciate components > when this number has been reached. > > Two questions: > > 1. Using this design, do you thing we will have any unexpected problems due to > the creation of these threads by the third party class. > 2. How are you meant to spawn additional service components in the model you > describe in point 1 below. > > Thanks, > > Ian Leader. > > On Mon, 21 Dec 1998 09:24:24 -0500, > in powersoft.public.easerver > David Wolf <dwolf@sybase.com> wrote: > >This is the case, and unfortunatly did not make it into the documentation. We > have > >corrected the documentation and are working on two solutions: > > > >1) In the current EBF to 2.0, we have included the ability to spawn X > instances of > >a service component. Since a service component is a shared instance > (singleton) > >You will have X threads running in it concurrently > > > >2) In the next EBF, we will have added a property to the Java ORB to allow you > to > >specify you are inside Jaguar. Rather than using the in-memory > orb/marshalling, > >this will force the ORB runtime to reconnect to jaguar as if it was a client > >itself, this alleviating the issue. > > > >Dave Wolf > >EAServer Product Team > > > >Ian Leader wrote: > > > >> The message below states that: > >> > >> "I understand spawning a new thread in the > >> >> >Jaguar component will not work and causes problems in the server. " > >> > >> Which I would take to mean "You must not create a new thread programatically > in > >> a Java component". > >> > >> I cannot find any reference to this in the documentation, so I would > appreciate > >> it if someone could confirm whether or not this is the case, or direct me to > >> documentation that does so. > >> > >> Thanks, > >> > >> Ian Leader > >> > >> On Wed, 16 Dec 1998 17:09:18 -0500, > >> in powersoft.public.easerver > >> David Wolf <dwolf@sybase.com> wrote: > >> >Actually if you want a service component to run only once, dont loop inside > >> >run(). This will accomplish that. > >> > > >> >so > >> > > >> >public class SillServiceImpl > >> >{ > >> > public void start() > >> > {} > >> > public void stop() > >> > {} > >> > > >> > public void run() > >> > { > >> > System.out.println("Just wanted to say hello!"); > >> > } > >> >} > >> > > >> >Dave Wolf > >> >EAServer Product Team > >> > > >> >markf wrote: > >> > > >> >> Randy, > >> >> How about specifying a handler to respond to Jaguars Start event handler ? > >> >> This is trggered when a request to start the jaguar server is made > >> >> Would that meet your objective to: > >> >> >create a schedule service which runs only once (basically, after server > >> >> >start up.) ? > >> >> > >> >> hndler launching your process > >> >> Randy Puro wrote in message <365A0B97.857E59C4@sybase.com>... > >> >> >Hi- > >> >> >I'm looking for some design pattern suggestions. I have a Jaguar method > >> >> >which executes very slowly. Whether or not the method executes properly > >> >> >is irrelevant to my client; therefore, I want some sort of "fire and > >> >> >forget" design pattern. I understand spawning a new thread in the > >> >> >Jaguar component will not work and causes problems in the server. I > >> >> >have looked at the asynchronous Events sample, and can see that I might > >> >> >be able to use some variation on the technique. However, in the > >> >> >example, there is a separate application responsible for handling a > >> >> >queue of requests (and in a sense has the desired affect of creating the > >> >> >separate request handling thread.) How can I achieve a similar model > >> >> >inside Jaguar (without having to create a separate "server" app)? > >> >> > > >> >> >My initial idea would be to create a scheduled jaguar service which runs > >> >> >in an infinite loop, waiting for notification of changes to the queue, > >> >> >and processing them as they occur. However, I'm not sure how one can > >> >> >create a schedule service which runs only once (basically, after server > >> >> >start up.) > >> >> > > >> >> >Thanks in advance for your suggestions, > >> >> > > >> >> >Randy > >> > > >
![]() |
0 |
![]() |
Let me do note though, if you do what I did, there is no way to ever stop the instance of Silly Thread! This is one reason why async threads to do fire and forget is not such a good idea. Dave Wolf EAServer Product Team p.s. Dont call me to tell me that my sample filled your disk :) David Wolf wrote: > The issue isnt with user created threads, but rather with intercomponent calls from > within these threads. I dont think you'll have any issues. This works fine: > > public class SillyThread extends Thread > { > public void run() > { > try > { > com.sybase.jaguar.server.Jaguar.writeLog("Hello!"); > } > catch(Exception e) > {} > } > > public class SillyComponentImpl > { > public void beSilly() > { > new SillyThread().start(); > com.sybase.jaguar.server.Jaguar.getInstanceContext().completeWork(); > } > } > > As for point two, you would set the property for the service component, in the > server's All Properties tab as: > > com.sybase.jaguar.server.services=Package/Component[20] > > To start 20 threads inside the service component. > > I do have a question. How are you limiting the number of pooled components? > > Dave Wolf > EAServer Product Team > > Ian Leader wrote: > > > Dave, > > > > Having read your response, I now think our situation is slightly different from > > Randy's. We are not trying to spawn a new thread & then instanciate another > > Jaguar component instance, nor are we trying to get a Jaguar method to return > > while leaving a thread running. > > > > Instead, we are writing a component which uses a single instance of a third > > party java class, which spawns 3 new threads in its constructor, but does not > > clean them up properly. This was causing problems with memory leakage, so we > > used the EJB interface to create a pool of up to n (currently 10) components > > created on demand, which are pooled (canReuse() method always returns true), and > > therefore persist until the server is shut down. > > > > So far this design *appears* to work correctly - memory usages is exactly as > > expected, and we can manage resource usage by limiting the maximum number of > > components running, and rejecting further requests to instanciate components > > when this number has been reached. > > > > Two questions: > > > > 1. Using this design, do you thing we will have any unexpected problems due to > > the creation of these threads by the third party class. > > 2. How are you meant to spawn additional service components in the model you > > describe in point 1 below. > > > > Thanks, > > > > Ian Leader. > > > > On Mon, 21 Dec 1998 09:24:24 -0500, > > in powersoft.public.easerver > > David Wolf <dwolf@sybase.com> wrote: > > >This is the case, and unfortunatly did not make it into the documentation. We > > have > > >corrected the documentation and are working on two solutions: > > > > > >1) In the current EBF to 2.0, we have included the ability to spawn X > > instances of > > >a service component. Since a service component is a shared instance > > (singleton) > > >You will have X threads running in it concurrently > > > > > >2) In the next EBF, we will have added a property to the Java ORB to allow you > > to > > >specify you are inside Jaguar. Rather than using the in-memory > > orb/marshalling, > > >this will force the ORB runtime to reconnect to jaguar as if it was a client > > >itself, this alleviating the issue. > > > > > >Dave Wolf > > >EAServer Product Team > > > > > >Ian Leader wrote: > > > > > >> The message below states that: > > >> > > >> "I understand spawning a new thread in the > > >> >> >Jaguar component will not work and causes problems in the server. " > > >> > > >> Which I would take to mean "You must not create a new thread programatically > > in > > >> a Java component". > > >> > > >> I cannot find any reference to this in the documentation, so I would > > appreciate > > >> it if someone could confirm whether or not this is the case, or direct me to > > >> documentation that does so. > > >> > > >> Thanks, > > >> > > >> Ian Leader > > >> > > >> On Wed, 16 Dec 1998 17:09:18 -0500, > > >> in powersoft.public.easerver > > >> David Wolf <dwolf@sybase.com> wrote: > > >> >Actually if you want a service component to run only once, dont loop inside > > >> >run(). This will accomplish that. > > >> > > > >> >so > > >> > > > >> >public class SillServiceImpl > > >> >{ > > >> > public void start() > > >> > {} > > >> > public void stop() > > >> > {} > > >> > > > >> > public void run() > > >> > { > > >> > System.out.println("Just wanted to say hello!"); > > >> > } > > >> >} > > >> > > > >> >Dave Wolf > > >> >EAServer Product Team > > >> > > > >> >markf wrote: > > >> > > > >> >> Randy, > > >> >> How about specifying a handler to respond to Jaguars Start event handler ? > > >> >> This is trggered when a request to start the jaguar server is made > > >> >> Would that meet your objective to: > > >> >> >create a schedule service which runs only once (basically, after server > > >> >> >start up.) ? > > >> >> > > >> >> hndler launching your process > > >> >> Randy Puro wrote in message <365A0B97.857E59C4@sybase.com>... > > >> >> >Hi- > > >> >> >I'm looking for some design pattern suggestions. I have a Jaguar method > > >> >> >which executes very slowly. Whether or not the method executes properly > > >> >> >is irrelevant to my client; therefore, I want some sort of "fire and > > >> >> >forget" design pattern. I understand spawning a new thread in the > > >> >> >Jaguar component will not work and causes problems in the server. I > > >> >> >have looked at the asynchronous Events sample, and can see that I might > > >> >> >be able to use some variation on the technique. However, in the > > >> >> >example, there is a separate application responsible for handling a > > >> >> >queue of requests (and in a sense has the desired affect of creating the > > >> >> >separate request handling thread.) How can I achieve a similar model > > >> >> >inside Jaguar (without having to create a separate "server" app)? > > >> >> > > > >> >> >My initial idea would be to create a scheduled jaguar service which runs > > >> >> >in an infinite loop, waiting for notification of changes to the queue, > > >> >> >and processing them as they occur. However, I'm not sure how one can > > >> >> >create a schedule service which runs only once (basically, after server > > >> >> >start up.) > > >> >> > > > >> >> >Thanks in advance for your suggestions, > > >> >> > > > >> >> >Randy > > >> > > > >
![]() |
0 |
![]() |
Dave, We limit the number of components as follows: 1. We maintain an array of semaphores. 2. The default constructor of the Component Implementation Class tries to grab one of these. 3a. If it succeeds, it continues with set-up, including the instanciation of the 3rd party class 3b. If it fails, it throws an exception and exits. If a component is re-used from the pool, rather than being freshly instanciated, the constructor is not called, so semaphores aren't used up unless new components are actually created. All of this is done in an abstract class that each 'pooled' component extends. When writing a new component, so long as we remember to call super(); at the start of the constructor, all the above happens 'by magic'. Regards, Ian. On Mon, 21 Dec 1998 21:54:51 -0500, in powersoft.public.easerver David Wolf <dwolf@sybase.com> wrote: >The issue isnt with user created threads, but rather with intercomponent calls from >within these threads. I dont think you'll have any issues. This works fine: > >public class SillyThread extends Thread >{ > public void run() > { > try > { > com.sybase.jaguar.server.Jaguar.writeLog("Hello!"); > } > catch(Exception e) > {} >} > >public class SillyComponentImpl >{ > public void beSilly() > { > new SillyThread().start(); > com.sybase.jaguar.server.Jaguar.getInstanceContext().completeWork(); > } >} > >As for point two, you would set the property for the service component, in the >server's All Properties tab as: > >com.sybase.jaguar.server.services=Package/Component[20] > >To start 20 threads inside the service component. > >I do have a question. How are you limiting the number of pooled components? > >Dave Wolf >EAServer Product Team > >Ian Leader wrote: > >> Dave, >> >> Having read your response, I now think our situation is slightly different from >> Randy's. We are not trying to spawn a new thread & then instanciate another >> Jaguar component instance, nor are we trying to get a Jaguar method to return >> while leaving a thread running. >> >> Instead, we are writing a component which uses a single instance of a third >> party java class, which spawns 3 new threads in its constructor, but does not >> clean them up properly. This was causing problems with memory leakage, so we >> used the EJB interface to create a pool of up to n (currently 10) components >> created on demand, which are pooled (canReuse() method always returns true), and >> therefore persist until the server is shut down. >> >> So far this design *appears* to work correctly - memory usages is exactly as >> expected, and we can manage resource usage by limiting the maximum number of >> components running, and rejecting further requests to instanciate components >> when this number has been reached. >> >> Two questions: >> >> 1. Using this design, do you thing we will have any unexpected problems due to >> the creation of these threads by the third party class. >> 2. How are you meant to spawn additional service components in the model you >> describe in point 1 below. >> >> Thanks, >> >> Ian Leader. >> >> On Mon, 21 Dec 1998 09:24:24 -0500, >> in powersoft.public.easerver >> David Wolf <dwolf@sybase.com> wrote: >> >This is the case, and unfortunatly did not make it into the documentation. We >> have >> >corrected the documentation and are working on two solutions: >> > >> >1) In the current EBF to 2.0, we have included the ability to spawn X >> instances of >> >a service component. Since a service component is a shared instance >> (singleton) >> >You will have X threads running in it concurrently >> > >> >2) In the next EBF, we will have added a property to the Java ORB to allow you >> to >> >specify you are inside Jaguar. Rather than using the in-memory >> orb/marshalling, >> >this will force the ORB runtime to reconnect to jaguar as if it was a client >> >itself, this alleviating the issue. >> > >> >Dave Wolf >> >EAServer Product Team >> > >> >Ian Leader wrote: >> > >> >> The message below states that: >> >> >> >> "I understand spawning a new thread in the >> >> >> >Jaguar component will not work and causes problems in the server. " >> >> >> >> Which I would take to mean "You must not create a new thread programatically >> in >> >> a Java component". >> >> >> >> I cannot find any reference to this in the documentation, so I would >> appreciate >> >> it if someone could confirm whether or not this is the case, or direct me to >> >> documentation that does so. >> >> >> >> Thanks, >> >> >> >> Ian Leader >> >> >> >> On Wed, 16 Dec 1998 17:09:18 -0500, >> >> in powersoft.public.easerver >> >> David Wolf <dwolf@sybase.com> wrote: >> >> >Actually if you want a service component to run only once, dont loop inside >> >> >run(). This will accomplish that. >> >> > >> >> >so >> >> > >> >> >public class SillServiceImpl >> >> >{ >> >> > public void start() >> >> > {} >> >> > public void stop() >> >> > {} >> >> > >> >> > public void run() >> >> > { >> >> > System.out.println("Just wanted to say hello!"); >> >> > } >> >> >} >> >> > >> >> >Dave Wolf >> >> >EAServer Product Team >> >> > >> >> >markf wrote: >> >> > >> >> >> Randy, >> >> >> How about specifying a handler to respond to Jaguars Start event handler ? >> >> >> This is trggered when a request to start the jaguar server is made >> >> >> Would that meet your objective to: >> >> >> >create a schedule service which runs only once (basically, after server >> >> >> >start up.) ? >> >> >> >> >> >> hndler launching your process >> >> >> Randy Puro wrote in message <365A0B97.857E59C4@sybase.com>... >> >> >> >Hi- >> >> >> >I'm looking for some design pattern suggestions. I have a Jaguar method >> >> >> >which executes very slowly. Whether or not the method executes properly >> >> >> >is irrelevant to my client; therefore, I want some sort of "fire and >> >> >> >forget" design pattern. I understand spawning a new thread in the >> >> >> >Jaguar component will not work and causes problems in the server. I >> >> >> >have looked at the asynchronous Events sample, and can see that I might >> >> >> >be able to use some variation on the technique. However, in the >> >> >> >example, there is a separate application responsible for handling a >> >> >> >queue of requests (and in a sense has the desired affect of creating the >> >> >> >separate request handling thread.) How can I achieve a similar model >> >> >> >inside Jaguar (without having to create a separate "server" app)? >> >> >> > >> >> >> >My initial idea would be to create a scheduled jaguar service which runs >> >> >> >in an infinite loop, waiting for notification of changes to the queue, >> >> >> >and processing them as they occur. However, I'm not sure how one can >> >> >> >create a schedule service which runs only once (basically, after server >> >> >> >start up.) >> >> >> > >> >> >> >Thanks in advance for your suggestions, >> >> >> > >> >> >> >Randy >> >> > >> > >
![]() |
0 |
![]() |
Ok, cool, thats what I thought you were doing. Now if the max number is hit, then the contructor throws an exception, so the client would catch that, and could retry. What could be cool is rather to get the instance from a Facotory component. let the Factory try to get an instance, and if it cant, to block and try again. In this way the client doesnt need to have retry code in it. I'd really like to do a presentation like the other's I do at users groups, on design patterns, so that's why I asked. Dave Wolf EAServer Product Team Ian Leader wrote: > Dave, > > We limit the number of components as follows: > > 1. We maintain an array of semaphores. > 2. The default constructor of the Component Implementation Class tries to grab > one of these. > 3a. If it succeeds, it continues with set-up, including the instanciation of the > 3rd party class > 3b. If it fails, it throws an exception and exits. > > If a component is re-used from the pool, rather than being freshly instanciated, > the constructor is not called, so semaphores aren't used up unless new > components are actually created. > > All of this is done in an abstract class that each 'pooled' component extends. > When writing a new component, so long as we remember to call super(); at the > start of the constructor, all the above happens 'by magic'. > > Regards, > > Ian. > > On Mon, 21 Dec 1998 21:54:51 -0500, > in powersoft.public.easerver > David Wolf <dwolf@sybase.com> wrote: > >The issue isnt with user created threads, but rather with intercomponent calls > from > >within these threads. I dont think you'll have any issues. This works fine: > > > >public class SillyThread extends Thread > >{ > > public void run() > > { > > try > > { > > com.sybase.jaguar.server.Jaguar.writeLog("Hello!"); > > } > > catch(Exception e) > > {} > >} > > > >public class SillyComponentImpl > >{ > > public void beSilly() > > { > > new SillyThread().start(); > > com.sybase.jaguar.server.Jaguar.getInstanceContext().completeWork(); > > } > >} > > > >As for point two, you would set the property for the service component, in the > >server's All Properties tab as: > > > >com.sybase.jaguar.server.services=Package/Component[20] > > > >To start 20 threads inside the service component. > > > >I do have a question. How are you limiting the number of pooled components? > > > >Dave Wolf > >EAServer Product Team > > > >Ian Leader wrote: > > > >> Dave, > >> > >> Having read your response, I now think our situation is slightly different > from > >> Randy's. We are not trying to spawn a new thread & then instanciate another > >> Jaguar component instance, nor are we trying to get a Jaguar method to return > >> while leaving a thread running. > >> > >> Instead, we are writing a component which uses a single instance of a third > >> party java class, which spawns 3 new threads in its constructor, but does not > >> clean them up properly. This was causing problems with memory leakage, so we > >> used the EJB interface to create a pool of up to n (currently 10) components > >> created on demand, which are pooled (canReuse() method always returns true), > and > >> therefore persist until the server is shut down. > >> > >> So far this design *appears* to work correctly - memory usages is exactly as > >> expected, and we can manage resource usage by limiting the maximum number of > >> components running, and rejecting further requests to instanciate components > >> when this number has been reached. > >> > >> Two questions: > >> > >> 1. Using this design, do you thing we will have any unexpected problems due > to > >> the creation of these threads by the third party class. > >> 2. How are you meant to spawn additional service components in the model you > >> describe in point 1 below. > >> > >> Thanks, > >> > >> Ian Leader. > >> > >> On Mon, 21 Dec 1998 09:24:24 -0500, > >> in powersoft.public.easerver > >> David Wolf <dwolf@sybase.com> wrote: > >> >This is the case, and unfortunatly did not make it into the documentation. > We > >> have > >> >corrected the documentation and are working on two solutions: > >> > > >> >1) In the current EBF to 2.0, we have included the ability to spawn X > >> instances of > >> >a service component. Since a service component is a shared instance > >> (singleton) > >> >You will have X threads running in it concurrently > >> > > >> >2) In the next EBF, we will have added a property to the Java ORB to allow > you > >> to > >> >specify you are inside Jaguar. Rather than using the in-memory > >> orb/marshalling, > >> >this will force the ORB runtime to reconnect to jaguar as if it was a client > >> >itself, this alleviating the issue. > >> > > >> >Dave Wolf > >> >EAServer Product Team > >> > > >> >Ian Leader wrote: > >> > > >> >> The message below states that: > >> >> > >> >> "I understand spawning a new thread in the > >> >> >> >Jaguar component will not work and causes problems in the server. " > >> >> > >> >> Which I would take to mean "You must not create a new thread > programatically > >> in > >> >> a Java component". > >> >> > >> >> I cannot find any reference to this in the documentation, so I would > >> appreciate > >> >> it if someone could confirm whether or not this is the case, or direct me > to > >> >> documentation that does so. > >> >> > >> >> Thanks, > >> >> > >> >> Ian Leader > >> >> > >> >> On Wed, 16 Dec 1998 17:09:18 -0500, > >> >> in powersoft.public.easerver > >> >> David Wolf <dwolf@sybase.com> wrote: > >> >> >Actually if you want a service component to run only once, dont loop > inside > >> >> >run(). This will accomplish that. > >> >> > > >> >> >so > >> >> > > >> >> >public class SillServiceImpl > >> >> >{ > >> >> > public void start() > >> >> > {} > >> >> > public void stop() > >> >> > {} > >> >> > > >> >> > public void run() > >> >> > { > >> >> > System.out.println("Just wanted to say hello!"); > >> >> > } > >> >> >} > >> >> > > >> >> >Dave Wolf > >> >> >EAServer Product Team > >> >> > > >> >> >markf wrote: > >> >> > > >> >> >> Randy, > >> >> >> How about specifying a handler to respond to Jaguars Start event > handler ? > >> >> >> This is trggered when a request to start the jaguar server is made > >> >> >> Would that meet your objective to: > >> >> >> >create a schedule service which runs only once (basically, after > server > >> >> >> >start up.) ? > >> >> >> > >> >> >> hndler launching your process > >> >> >> Randy Puro wrote in message <365A0B97.857E59C4@sybase.com>... > >> >> >> >Hi- > >> >> >> >I'm looking for some design pattern suggestions. I have a Jaguar > method > >> >> >> >which executes very slowly. Whether or not the method executes > properly > >> >> >> >is irrelevant to my client; therefore, I want some sort of "fire and > >> >> >> >forget" design pattern. I understand spawning a new thread in the > >> >> >> >Jaguar component will not work and causes problems in the server. I > >> >> >> >have looked at the asynchronous Events sample, and can see that I > might > >> >> >> >be able to use some variation on the technique. However, in the > >> >> >> >example, there is a separate application responsible for handling a > >> >> >> >queue of requests (and in a sense has the desired affect of creating > the > >> >> >> >separate request handling thread.) How can I achieve a similar model > >> >> >> >inside Jaguar (without having to create a separate "server" app)? > >> >> >> > > >> >> >> >My initial idea would be to create a scheduled jaguar service which > runs > >> >> >> >in an infinite loop, waiting for notification of changes to the queue, > >> >> >> >and processing them as they occur. However, I'm not sure how one can > >> >> >> >create a schedule service which runs only once (basically, after > server > >> >> >> >start up.) > >> >> >> > > >> >> >> >Thanks in advance for your suggestions, > >> >> >> > > >> >> >> >Randy > >> >> > > >> > > >
![]() |
0 |
![]() |