Question

Is it possible to deploy an application to a GlassFish app server that would behave more like a daemon than a web app? I'd like to set up some sort of daemon app that would relay requests to an API that only allows for one connection at a time.

This way I could have multiple servlet instances that could simply submit API requests through the daemon and avoid ever needing more than one connection to the API.

I'm fairly new to Java-based web apps, so I'm not entirely certain what to search for, or if this kind of functionality is available in, say, the Java-EE development kit. Any help appreciated!

Updates/Ideas:

Was it helpful?

Solution

GlassFish v3 supports EJB 3.1 Singleton Beans:

A Singleton Bean could be used to implement the requirement "relay requests to an API that only allows for one connection at a time".

By default, all Singleton methods are made thread-safe and transactional. This means that all multithreaded access to the bean is serialized (...)

(from New Features in EJB 3.1 - theserverside.com)

OTHER TIPS

Sounds like you want a servlet that feeds a message queue. Then you can have some code that pulls entries off the queue and processes them. Look up Message-Driven Beans.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top