[EJB 3.0] - Issuing Commands to a Running Process
by suatkaya
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
18Â years, 10Â months
[JBoss Seam] - Question about explicit conversation id
by bsmithjj
I have the following SeamTest (FacesRequest) method:
| @Override
| protected void invokeApplication() throws Exception {
|
| AccessRequestManager2 arm2 = (AccessRequestManager2) getInstance("accessRequestManager2");
| assert arm2 != null;
| arm2.startRequest();
| log.info("conversationId = "+getConversationId());
|
| }
|
|
and AccessRequestManager2.startRequest() looks like this:
| @Begin(id="#{draftAccessRequestMaster.id}",join=true)
| public void startRequest() {
| log.info("draftAccessRequestMaster.id = "+draftAccessRequestMaster.getId());
| }
|
Furthermore, I use the @Factory pattern to create a persistent instance of draftAccessRequestMaster which is @In(jected) to AccessRequestManager2. When I run the test, I get the following in the log output:
| 10:36:40,265 INFO com.evergreen.accesscontrol.AccessRequestManager2Test.(info:94) - updateModelValues()
| 10:36:40,812 INFO com.evergreen.accesscontrol.impl.AccessRequestManager2Bean.(startRequest:54) - draftAccessRequestMaster.id = 5
| 10:36:40,875 INFO com.evergreen.accesscontrol.AccessRequestManager2Test.(info:94) - conversationId = 1
|
My question here is ....
Why isn't the conversationId equal to the explicit id that I created in the @Begin(...) annotation?
Thanks,
Brad Smith
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4052622#4052622
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4052622
18Â years, 10Â months