Re: [JBoss-user] How can I use a background process with JBoss

2002-02-14 Thread Ivan Bolcina










Hi.



Interesting question...



How about that you write a entry in database table after order processing with
status. Now every struts action should check it and if order id matches order
id of current user, it can notify him. This is server-pull, since you pull data
from server and its only checked on clicks. You can
simulate server push, in this way that client constanty checks throug .do -
ejb- db for order processing status. After status is ok, it writes
javascript message or redirects or something. For this you need frame or iframe
and there javascript which every 15 seconds or something refreshes itself - to
.do action of course.



What do you think?








[JBoss-user] How can I use a background process with JBoss

2002-02-13 Thread Dirk Storck

Hi,

I want to do the following:

I have a ShoppingCart.
The users clicks on order and the items from the ShoppingCart are moved to
my OrderBean. ShoppingCart and OrderBean are EJB's.

Now it comes to the problem. The order must be proccessed in background
cause it will have a long durration.
After the order has be proccessed the user should be notived somehow.

How can I achieve this with JBoss and Struts ? What would be the best way to
implement this

Many thanks any any suggestions are welcome!!!


___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user



RE: [JBoss-user] How can I use a background process with JBoss

2002-02-13 Thread Coetmeur, Alain


a message bean can be a good idea...
send an XML or text message to your message EJB,
which will process the request in it's own thread...

by the way, for long transactions, if you can avoid transactions
(by default they timeout in 30 seconds. you can change
 that somewhere in the transaction config, but 
 anyway this is costly for the DB)

check the transaction mode used for the EJB...
using NotSupported for is interesting if their is no risk of
incoherence. note that such a non transactional bean 
can call transactional EJB (Required TX mode for example).
each independent method call will be either Commit'ed or Rollback'ed...

If you don't have Message EJB, you can try to add a Thread'able object
in the Servlet context. I did it on Websphere
to scan mail...

then, either use the load-on-startup elemnt in web.xml
or explicitly start and stop...

as far as I understand servler context guaranty that
only one instance of the thread is used

you may also look about non HTTP servlet
which may respond to any protocol...
or even to soap clients...

 -Message d'origine-
 De: Dirk Storck [mailto:[EMAIL PROTECTED]]
 Date: mercredi 13 février 2002 14:17
 À: Jboss User (E-Mail); Struts User (E-Mail)
 Objet: [JBoss-user] How can I use a background process with JBoss
 
 
 Hi,
 
 I want to do the following:
 
 I have a ShoppingCart.
 The users clicks on order and the items from the ShoppingCart 
 are moved to
 my OrderBean. ShoppingCart and OrderBean are EJB's.
 
 Now it comes to the problem. The order must be proccessed in 
 background
 cause it will have a long durration.
 After the order has be proccessed the user should be notived somehow.
 
 How can I achieve this with JBoss and Struts ? What would be 
 the best way to
 implement this

package fr.cdc.idt.receivemail;

/**
 * Insérez la description du type ici.
 * Date de création : (04/01/02 12:10:45)
 * @author: 
 */
import java.util.Date;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;

import javax.mail.*;
import javax.mail.internet.*;
import fr.cdc.idt.sendmail.*;

public class ReceiveMailServlet extends javax.servlet.http.HttpServlet {
/**
 * Free any resources the servlet has acquired
 * that will not be garbage collected.
 */
public void destroy() {
System.out.println(getClass().getName()+#destroy());
ServletContext cnt=getServletContext();
Object cobj=cnt.getAttribute(mailPollBean);
if(cobj!=null){
  ReceiveMailPollBean
mailPollBean=(ReceiveMailPollBean)cobj;
System.out.println(getClass().getName()+#destroy() bean stop);
  mailPollBean.stop();
System.out.println(getClass().getName()+#destroy()
removeattribute);
  cnt.removeAttribute(mailPollBean);
}
super.destroy();
}
/**
 * Process incoming HTTP GET requests 
 * 
 * @param request Object that encapsulates the request to the servlet 
 * @param response Object that encapsulates the response from the servlet
 */
public void doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) throws
javax.servlet.ServletException, java.io.IOException {

performTask(request, response);

}
/**
 * Process incoming HTTP POST requests 
 * 
 * @param request Object that encapsulates the request to the servlet 
 * @param response Object that encapsulates the response from the servlet
 */
public void doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) throws
javax.servlet.ServletException, java.io.IOException {

performTask(request, response);

}
/**
 * Returns the servlet info string.
 */
public String getServletInfo() {

return super.getServletInfo();

}
/**
 * Initializes the servlet.
 */
public void init() {
// insert code to initialize the servlet here

}
/**
* Initializes the servlet.
*/
public void init(ServletConfig cnf) throws ServletException {
// insert code to initialize the servlet here
super.init(cnf);

ServletContext cnt = cnf.getServletContext();

//String mailhostParm = cfg.getInitParameter(mailhost);

ReceiveMailPollBean mailPollBean = new ReceiveMailPollBean();
ReceiveMailBean receiveBean = mailPollBean.getReceiveMailBean();
receiveBean.setUserName(testportail);
receiveBean.setPassword(testportail);
receiveBean.setStoreType(imap);
receiveBean.setFolderName(INBOX);
receiveBean.setHostName(tsexchange.idt.cdc.fr);
AttachmentAdapter attachementListener = new AttachmentAdapter() {
public void onAttachement(AttachmentEvent event) {
/* do the job  */
}
};
receiveBean.addAttachmentListener(attachementListener);
mailPollBean.setPollingInterval(1000 * 30);

mailPollBean.start();
//  Thread.currentThread().sleep(1000*30);
//mailPollBean.stop();
cnt.setAttribute(mailPollBean, mailPollBean

Re: [JBoss-user] How can I use a background process with JBoss

2002-02-13 Thread Edward Q. Bridges


why not just send the user an email after the order has been processed?

you could process the order using a message-driven bean that sends an email 
when completed, since you won't know if the user is still available after 
processing the order.

HTH




On Wed, 13 Feb 2002 14:16:36 +0100, Dirk Storck wrote:

How can I achieve this with JBoss and Struts ? What would be the best way 
to
implement this



___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user



Re: [JBoss-user] How can I use a background process with JBoss

2002-02-13 Thread Ricardo Argüello

It looks like you would need Message Driven Beans.

Read O'Reilly's Enterprise JavaBeans 3rd. Edition.

And check JBoss 3.0.0alpha documentation:
http://www.jboss.org/online-manual/HTML/ch08s20.html


Greetings,

Ricardo Arguello


- Original Message - 
From: Dirk Storck [EMAIL PROTECTED]
To: Jboss User (E-Mail) [EMAIL PROTECTED]; Struts User (E-Mail) 
[EMAIL PROTECTED]
Sent: Wednesday, February 13, 2002 8:16 AM
Subject: [JBoss-user] How can I use a background process with JBoss


 Hi,
 
 I want to do the following:
 
 I have a ShoppingCart.
 The users clicks on order and the items from the ShoppingCart are moved to
 my OrderBean. ShoppingCart and OrderBean are EJB's.
 
 Now it comes to the problem. The order must be proccessed in background
 cause it will have a long durration.
 After the order has be proccessed the user should be notived somehow.
 
 How can I achieve this with JBoss and Struts ? What would be the best way to
 implement this
 
 Many thanks any any suggestions are welcome!!!
 
 
 ___
 JBoss-user mailing list
 [EMAIL PROTECTED]
 https://lists.sourceforge.net/lists/listinfo/jboss-user
 


___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user



AW: [JBoss-user] How can I use a background process with JBoss

2002-02-13 Thread Dirk Storck

I can't use MessageDrivenBeans cause we have to use EJB1.1

-Ursprüngliche Nachricht-
Von: Edward Q. Bridges [mailto:[EMAIL PROTECTED]]
Gesendet: Mittwoch, 13. Februar 2002 14:54
An: [EMAIL PROTECTED]; Jboss User (E-Mail)
Betreff: Re: [JBoss-user] How can I use a background process with JBoss



why not just send the user an email after the order has been processed?

you could process the order using a message-driven bean that sends an email
when completed, since you won't know if the user is still available after
processing the order.

HTH




On Wed, 13 Feb 2002 14:16:36 +0100, Dirk Storck wrote:

How can I achieve this with JBoss and Struts ? What would be the best way
to
implement this


___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user



Re: AW: [JBoss-user] How can I use a background process with JBoss

2002-02-13 Thread David Ward

JBoss 2.4.4 is EJB 1.1 but also has MessageDrivenBeans.

--

Dirk Storck wrote:
 I can't use MessageDrivenBeans cause we have to use EJB1.1
 
 -Ursprüngliche Nachricht-
 Von: Edward Q. Bridges [mailto:[EMAIL PROTECTED]]
 Gesendet: Mittwoch, 13. Februar 2002 14:54
 An: [EMAIL PROTECTED]; Jboss User (E-Mail)
 Betreff: Re: [JBoss-user] How can I use a background process with JBoss
 
 
 
 why not just send the user an email after the order has been processed?
 
 you could process the order using a message-driven bean that sends an email
 when completed, since you won't know if the user is still available after
 processing the order.
 
 HTH
 
 
 
 
 On Wed, 13 Feb 2002 14:16:36 +0100, Dirk Storck wrote:
 
 
How can I achieve this with JBoss and Struts ? What would be the best way

 to
 
implement this

 
 
 ___
 JBoss-user mailing list
 [EMAIL PROTECTED]
 https://lists.sourceforge.net/lists/listinfo/jboss-user
 



___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user



Re: [JBoss-user] How can I use a background process with JBoss

2002-02-13 Thread Joachim Schaaf

Hi,

Am Mittwoch, 13. Februar 2002 14:16 schrieb Dirk Storck:
 Hi,
 I want to do the following:
 I have a ShoppingCart.
 The users clicks on order and the items from the ShoppingCart are moved to
 my OrderBean. ShoppingCart and OrderBean are EJB's.

It's funny to see how everyone is working on similar problems (even the names 
of my classes are the same :) ).

 Now it comes to the problem. The order must be proccessed in background
 cause it will have a long durration.
 After the order has be proccessed the user should be notived somehow.

The EJB spec. doesn't allow threads, so I think you will have to use message 
driven beans (MDB, belongs to EJB 2.0). The notification could be done via 
email.

 How can I achieve this with JBoss and Struts ? What would be the best way
 to implement this

I haven't used MDB's yet, but the trick is to start a time consuming 
operation with a MDB and let it notify you when it's ready; your Struts 
action class would simply start the thing and return.

Joachim
-- 
Dipl.-Ing. Joachim Schaaf | Projektleiter | mailto:[EMAIL PROTECTED]
cataloom AG | Eupener Str. 148 | 50933 Köln | http://cataloom.com/
Tel: +49 221 4851807 | Fax: +49 221 4851907 | Mobil-Tel: +49 170 7667807

___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user



AW: [JBoss-user] How can I use a background process with JBoss

2002-02-13 Thread Dirk Storck

But I must have access to the filesystem for copying purpose.
How about using MBean's for that ? Can they be access as normal Beans ?

-Ursprüngliche Nachricht-
Von: Rajeshwar Rao V [mailto:[EMAIL PROTECTED]]
Gesendet: Mittwoch, 13. Februar 2002 16:23
An: Ricardo Argüello; [EMAIL PROTECTED]; Jboss User (E-Mail)
Betreff: RE: [JBoss-user] How can I use a background process with JBoss


Message Beans are the best option...
If not use Scheduler in JBoss.

-Original Message-
From: Ricardo Argüello [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 7:39 PM
To: [EMAIL PROTECTED]; Jboss User (E-Mail)
Subject: Re: [JBoss-user] How can I use a background process with JBoss


It looks like you would need Message Driven Beans.

Read O'Reilly's Enterprise JavaBeans 3rd. Edition.

And check JBoss 3.0.0alpha documentation:
http://www.jboss.org/online-manual/HTML/ch08s20.html


Greetings,

Ricardo Arguello


- Original Message -
From: Dirk Storck [EMAIL PROTECTED]
To: Jboss User (E-Mail) [EMAIL PROTECTED]; Struts User
(E-Mail) [EMAIL PROTECTED]
Sent: Wednesday, February 13, 2002 8:16 AM
Subject: [JBoss-user] How can I use a background process with JBoss


 Hi,

 I want to do the following:

 I have a ShoppingCart.
 The users clicks on order and the items from the ShoppingCart are moved to
 my OrderBean. ShoppingCart and OrderBean are EJB's.

 Now it comes to the problem. The order must be proccessed in background
 cause it will have a long durration.
 After the order has be proccessed the user should be notived somehow.

 How can I achieve this with JBoss and Struts ? What would be the best way
to
 implement this

 Many thanks any any suggestions are welcome!!!


 ___
 JBoss-user mailing list
 [EMAIL PROTECTED]
 https://lists.sourceforge.net/lists/listinfo/jboss-user



___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user


___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user



Re: AW: [JBoss-user] How can I use a background process with JBoss

2002-02-13 Thread David Ward

Dirk Storck wrote:
 But I must have access to the filesystem for copying purpose.
 How about using MBean's for that ? Can they be access as normal Beans ?

As much as the spec says you shouldn't do io from EJBs, technically you 
still can (though I'm not advocating it ;) ).  I tried it once and both 
JBoss and WebLogic didn't stop me.  I'm guessing there would have to be 
some ClassLoader or security magic to keep you from using anything in 
java.io, but in practice I doubt anybody does that.

AFAIK, they don't want you to do io because 1) io can block forever, 
and 2) the filesystem isn't transactionally managed.  I'm not sure if 
there's stuff in JDK 1.4's new nio package that can address the first 
point.  There might also be a 3rd party product to address the second. 
Probably (as I think someone else already mentioned) as a .rar.

David


___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user



RE: AW: [JBoss-user] How can I use a background process with JBoss

2002-02-13 Thread Coetmeur, Alain



 -Message d'origine-
 some ClassLoader or security magic to keep you from using anything in 
 java.io, but in practice I doubt anybody does that.
the java.policy and the security manage should do that job

 AFAIK, they don't want you to do io because 1) io can block 
 forever, 
 and 2) the filesystem isn't transactionally managed.  I'm not sure if 
 there's stuff in JDK 1.4's new nio package that can address the first 
 point.  There might also be a 3rd party product to address 
 the second. 
 Probably (as I think someone else already mentioned) as a .rar.

that is only an idea ...
in a perfect J2EE world, all that is ner to the system,
should be a JCA component (a .rar)...

it could be a good tutorial for .rar developement...
any volunteer ?

___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user



Re: AW: [JBoss-user] How can I use a background process with JBoss

2002-02-13 Thread Ricardo Argüello

 AFAIK, they don't want you to do io because 1) io can block forever, 
 and 2) the filesystem isn't transactionally managed

I don't know if you can do this with EJB:
http://www.onjava.com/pub/a/onjava/2002/02/06/atomic.html




___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user