문제

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:

도움이 되었습니까?

해결책

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)

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top