[JBoss Seam] - Re: SwingWorker and the Event Dispatcher Thread
by SmokingAPipe
Well, SwingWorker itself is a lot different from just handling things asynchronously. It's a thread class that you sub-class, and you have a few methods:
doInBackground: When the SwingWorker is executed, this is the part that starts running. Obviously it happens in a thread so the GUI keeps on redrawing and responding to events. This is the essence of good Swing app building. doInBackground can publish notifications to...
process(): This receives information of various types from doInBackground and CAN safely update the GUI. process() runs on the EDT and must return quickly.
and finally...
done(): this runs on the EDT after everything else is done.
This is the only right way to handle things in Swing (either using SwingWorker or some other similar thread-based model). And many processes on the web are similar. The web request must return promptly, just like things on the EDT must return promptly. Long-running work should not be done either during the web request or on the EDT, for similar reasons. In both cases we would like a publish() method to update the user of the status of long-running work. And in both cases we want a done() method to let the user know that the long-running task is done.
MDBs are not as light-weight or as natural of a fit as SwingWorker, but they're one of the few ways I can see to do things asynchronously within the Seam world. I could be totally wrong on that of course, being a newbie to it.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024927#4024927
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024927
19Â years, 1Â month
[JBossWS] - web service and asynchronous processing
by vitor_b
Hello
I really need your help, so please read my question and post your reply if you know the answer, so ...
Webservices generally have one or more business methods exposed for clients.
for example:
public ResponseObject businessMethod(RequestObject request)
A client sends a request, this request is transformed to an object, this object is passed as a parameter to our business method. The method do some work, then returns ResponseObject, application server sends the response to the client. The client waits for the answer. So this is synchronous communication.
WebServices use SOAP. Application server knows where has to send the reply.
But lets suppose that in some cases i would like to do some business logic later, not just when a request is received. I have been thinking of it and
i would like you to help me.
So I could expose another method, like:
public ConfirmationObject asyncBusinessMethod(RequestObject request)
This method would put RequestObject in JMS queue and then send reply. This reply
means that request is accepted, and will be processing later. Client can continue its work.
The Queue will hold all async requests.
Requests will be taken from the queue later, one after the other.
There will be for example a session bean (not MDB becouse i don't want it to take objects when they are available, just later), this bean will take a request from queue and then call first described method: businessMethod(...) . This method will create a reply, but now there is a big problem.
Where it should be send? We have no info about client which has sent this message to our application.
How to handle this? Generally client will have a end point, waiting for async response.
It will use SOAP. How to send the async response using SOAP to client?
Or should I do it in completely different way? The goal is asynchronous handling of requests.
If there was only one client i could create and send SOAP message like that:
ResponseObject response = ...
| //add the response object to SOAP message
| //then
| SOAPConnection connection = ...
| java.net.URL endpoint = new URL ("http://www.one.known.client");
| SOAPMessage response = connection.call(response, endpoint);
| //endpoint - client end point waiting for async reply, hardcoded or in app config
Could that be done from a session bean?
If there were many clients we wouldn't know to which client we should send the reply.
Once again how to handle that?
Please help me, I'm a beginner and this is not easy for me at all.
Thank you in advance.
vitor_b
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024926#4024926
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024926
19Â years, 1Â month
[JBoss Seam] - Re: @In(create = true) @Out works fine in 1.1.5.GA and not i
by msystems
"holtak" wrote : Just loud thinking:
|
| you always get a new (not nested) conversation with seam 1.2PATCH1 and then @In can`t inject the old instance? And this is not so when you move back to 1.1.5, for some reason...
|
With 1.2.0 and pages.xml I get a new conversation id at each request for the current conversation and that's not correct because @In can`t inject the old instance, but for 1.1.5 and pages.xml I have the same conversation id throughout the conversation.
"holtak" wrote :
| Also, I don`t understand why do you return a String from #{acountBean.begin}? That makes things somewhat overcomplicated to me.
|
Because my conversation consist of 3 pages (request).
Page 1) Disclaimer - accept yes or no (Conversation Begin)
Page 2) User enter personal data
Page 3) Welcome text
If a new user try to hit page 2 or page 3 without accepting the "Disclaimer" at page 1, then the conversation will end.
I return a String in #{acountBean.begin} to navigate to the right 'Begin' page (I'm using JSF navigation).
Maybe it's the wrong way to use Seam and page actions (from 1.2.0) but as I have mentioned earlier everything works just fine for 1.1.5 :-)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024921#4024921
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024921
19Â years, 1Â month
[JBoss Seam] - Email Listening MDB Accessing Seam Components
by djeverson
We are getting a Null Pointer Exception in an MDB that is listening for emails.
It appears that the Seam components are not being properly injected. We get errors when we attempt to use @Logger. We have changed these for the time being to System.out.printlns. Our service EJB components are not getting injected either.
Our environment is Seam 1.1.7RC1, JBoss 4.0.5. The mail-ra.rar file has been placed in the server\default\deploy folder.
The following is our MDB that is throwing the NPEs:
| package us.crimnet.iss.listeners;
|
| import javax.ejb.ActivationConfigProperty;
| import javax.ejb.MessageDriven;
| import javax.ejb.Stateless;
| import javax.mail.Message;
|
| import org.jboss.annotation.ejb.ResourceAdapter;
| import org.jboss.mail.MailException;
|
| import org.jboss.resource.adapter.mail.inflow.MailListener;
| import org.jboss.seam.Component;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Scope;
| import org.jboss.seam.ScopeType;
|
| import us.crimnet.iss.services.HistoryManagement;
| import us.crimnet.iss.services.impl.HistoryManagementImpl;
|
| @MessageDriven(activationConfig={
| @ActivationConfigProperty(propertyName="mailServer", propertyValue="domain.com"),
| @ActivationConfigProperty(propertyName="mailFolder", propertyValue="INBOX"),
| @ActivationConfigProperty(propertyName="storeProtocol", propertyValue="pop3"),
| @ActivationConfigProperty(propertyName="userName", propertyValue="uid"),
| @ActivationConfigProperty(propertyName="password", propertyValue="pwd")
| })
|
| @ResourceAdapter("mail-ra.rar")
| @Name("requestEmailListener")
|
| public class RequestEmailListener implements MailListener {
|
| @In(create=true)
| private HistoryManagement historyManagement;
|
| public void onMessage(Message message) {
| System.out.println("Can we inject the @Logger here???");
| System.out.println("RequestEmailListener.onMessage()");
| try {
| Long id = Long.parseLong(message.getSubject());
| System.out.println("History id [" + id + "]");
| //TODO : dj : The following line threw an NPE
| // was it not properly injected by Seam?
| historyManagement.sendRequest(id);
|
| System.out.println("back from HistoryManagement");
| } catch (Exception e) {
| e.printStackTrace();
| }
| }
| }
|
Any suggestions as to what the causing the Seam Components not to be injected or initialized?
Thanks!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024920#4024920
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024920
19Â years, 1Â month