[jboss-user] [EJB 3.0] - Issuing Commands to a Running Process
suatkaya
do-not-reply at jboss.com
Fri Jun 8 10:45:10 EDT 2007
Hi,
For some reason, my stateless session bean starts a long running "process" (not in OS terms) like this code:
| private @Resource SessionContext sctx;
| .....
| sctx.getTimerService().createTimer(1, obj);
|
The long running process is in timer code. And it creates a Queue object and gives it a JNDI name like this:
| @Timeout
| public void timeoutHandler(javax.ejb.Timer timer)
| {
| InitialContext inictx = new InitialContext();
| this.commandQueue = new ConcurrentLinkedQueue<SomeMsg>();
| inictx.bind("CmdQueue", this.commandQueue);
| }
|
And this created queue is used to accept commands from other session beans, like this:
| SomeMsg msg = this.commandQueue.poll();
|
And then acts accordingly. Other session beans can send a message to this process like the following:
| InitialContext ctx = new InitialContext();
| Queue<SomeMsg> queue = (Queue<SomeMsg>) ctx.lookup("CmdQueue");
| queue.add(msg);
|
And the process unbinds the name before finishing.
Are there any pitfalls in this approach?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4052623#4052623
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4052623
More information about the jboss-user
mailing list