Install the component as an EAServer service

In order to run as a service, your service component must be added to the host server’s list of services, as follows:

StepsInstalling services

  1. Start EAServer Manager if it is not already running.

  2. Expand the Servers folder.

  3. Expand the icon for the server.

  4. Highlight the Installed Services folder under the server icon, then choose File | Install Services from the menu.

  5. Components that implement the CtsComponents::GenericService interface are listed. Pick the component to install, then click OK.

  6. The service will run the next time you refresh or restart the server.

StepsConfiguring a service to run in multiple threads

By default, one thread runs per service. You can specify a larger number of threads as follows:

  1. Display the server properties.

  2. In the list of properties, select “com.sybase.jaguar.server.services”, then click Modify.

  3. The value of this property is the list of services, using the form Package/Component, with entries separated by commas. To specify multiple threads for a service, enter the number of threads in brackets after the component name. For example:

    YourPackage/YourService[10]
    
  4. Click Ok to close the Modify Property window.

  5. Click Ok to close the Server Properties window.

  6. The change takes affect the next time you refresh or restart the server.

When multiple threads are requested

The host server calls the component’s run method from the specified number of threads. If the Sharing option is enabled, all threads call run on the same component instance as start was called in. Otherwise, each thread will create a new instance of the component and call run on that instance. Each thread terminates when run returns. This feature is useful when your service component performs a background task that lends itself to parallel processing. For example, if the run implementation extracts work requests from a queue and performs the requested operation, you can configure the server so multiple threads read requests from the queue and process them simultaneously. The component must be coded to ensure that access to the queue is thread-safe, for example, in Java, you might create synchronized methods to queue and dequeue.

The component must be stateless in order to run in multiple threads. Make sure the Automatic Demarcation/Deactivation is option is checked on the Transactions tab in the Component Properties window.

NoteThe start method and stop methods are only called on one instance of a service component. If Sharing is not set for the component, start must store any data required by the run method or other methods. For access by multiple instances, data must be stored in static fields or a persistent data store.