Receiving mail
erikslagter Jul 23, 2008 11:25 AMI'm trying to receive e-mails in my seam application. I'm using Seam 2.0.2SP1 and Jboss 4.2.2GA.
The problem is that my onMessage call in my message driven bean isn't called. My bean looks as the following:
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.mail.Message;
import org.jboss.annotation.ejb.ResourceAdapter;
import org.jboss.resource.adapter.mail.inflow.MailListener;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.log.Log;
@MessageDriven(activationConfig={
@ActivationConfigProperty(propertyName="mailServer", propertyValue="pop3.mydomain.nl"),
@ActivationConfigProperty(propertyName="mailFolder", propertyValue="INBOX"),
@ActivationConfigProperty(propertyName="storeProtocol", propertyValue="pop3"),
@ActivationConfigProperty(propertyName="userName", propertyValue="myUser"),
@ActivationConfigProperty(propertyName="password", propertyValue="myPass")
})
@ResourceAdapter("mail-ra.rar")
@Name("emailRetrieverMDB")
public class MailListenerBean implements MailListener {
@Logger
private Log log;
@In(create=true)
MailProcessor mailProcessor;
public void onMessage(Message message) {
// Process the message
log.info(" ");
log.info("onMessage being called");
log.info(" ");
System.out.println("on Message");
mailProcessor.processMail(message);
}
}
The funny thing is that when I sniff for TCP packets I see normal behaviour. I can connect with the mail server and am able to read the number of messages that are in the INBOX.
Also in the logging of Jboss I see that the emailRetrieverMDB is initialized:
[Component] Component: emailRetrieverMDB, scope: STATELESS, type: MESSAGE_DRIVEN_BEAN, class: nl.chess.pos.MailListenerBean, JNDI: pos/MailListenerBean/local
Why isn't my onMessage(Message) function called at a new message?
The problem is that my onMessage call in my message driven bean isn't called. My bean looks as the following:
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.mail.Message;
import org.jboss.annotation.ejb.ResourceAdapter;
import org.jboss.resource.adapter.mail.inflow.MailListener;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.log.Log;
@MessageDriven(activationConfig={
@ActivationConfigProperty(propertyName="mailServer", propertyValue="pop3.mydomain.nl"),
@ActivationConfigProperty(propertyName="mailFolder", propertyValue="INBOX"),
@ActivationConfigProperty(propertyName="storeProtocol", propertyValue="pop3"),
@ActivationConfigProperty(propertyName="userName", propertyValue="myUser"),
@ActivationConfigProperty(propertyName="password", propertyValue="myPass")
})
@ResourceAdapter("mail-ra.rar")
@Name("emailRetrieverMDB")
public class MailListenerBean implements MailListener {
@Logger
private Log log;
@In(create=true)
MailProcessor mailProcessor;
public void onMessage(Message message) {
// Process the message
log.info(" ");
log.info("onMessage being called");
log.info(" ");
System.out.println("on Message");
mailProcessor.processMail(message);
}
}
The funny thing is that when I sniff for TCP packets I see normal behaviour. I can connect with the mail server and am able to read the number of messages that are in the INBOX.
Also in the logging of Jboss I see that the emailRetrieverMDB is initialized:
[Component] Component: emailRetrieverMDB, scope: STATELESS, type: MESSAGE_DRIVEN_BEAN, class: nl.chess.pos.MailListenerBean, JNDI: pos/MailListenerBean/local
Why isn't my onMessage(Message) function called at a new message?