(NOTE : I have posted this in the EJB3 Forum too)
I've been using a simple Message Driven Bean to grab new emails from an imap account for the last 18 months very successfully on 4.2.1 GA
Bean code :
* EJB3 Message-Driven Bean (MDB).
* Called for every email received to an IMAP account
// @ActivationConfigProperty(propertyName="port", propertyValue="10143"),
public class ReceiverMDB implements MailListener
@PersistenceContext(unitName = "default")
private EntityManager em;
public void onMessage(Message msg)
(NOTE : I believe 'maxMessages' is ignored, so doesn't do anything)
Recently, we have been doing some testing on upgrading to 4.2.3 and something seems to be effecting this bean on our live server - Now when JBoss starts the bean triggers once and will happily devour 450 emails. But once it's finished getting the first block of pending emails, it never triggers again.
There's no exceptions. The bean's 'onMessage' never seems to get triggered. Even going onto the JBoss Console and stopping/starting/destroying/creating etc doesn't get the bean working.
Worse still going back to 4.2.1 doesn't seem to help. And only restarting JBoss clears the pending emails.
Does anyone have experience of similar issues with MDBs, especially with the mail-ra.rar resource? Or can anyone help?
Did you hear anything about this from the EJB3 forums?
Hi - No, nothing yet.
Futher testing has confirmed that the bean works on our test server. Also, if I disable this bean on the live server and deploy a new bean that accesses a different email account - it works.
So, there seems to be something different about the live server & this certain email account.
To get us working I have now re-written the bean so that I uses JavaMail to access the account and grab & process all the new emails - this works fine but needs to be scheduled to run every 15 minutes. The original way using a MDB with MailListener & onMessage trigger was much more elegant and appropriate for our system. So, any suggestions on causes of the problem would be good.
I don't have experience with this. But here's what you could try - when after 450 messages, the MDB stops receiving, obtain the thread dumps and see if it provides any useful information. The thread dumps can be obtained as explained here http://www.jboss.org/community/docs/DOC-12300
Also, the http://localhost:8080/jmx-console has some MBeans (i am not at my system now so i can't tell you the exact names) which show you the status of the MDB (including the instance count and other stuff). See if that provides any clues.
Has anyone found out why mail-ra stops working?
I'm actually seeing a very similar scenario where when the server starts up I can see it checking for email messages, but after a couple of hours it doesn't try to grab emails anymore. I haven't monitored it that closely to know the exact timing, but I know it's not even trying to check because I have it in debug mode and I don't see the mail commands being executed at all.
I'm going to have to implement this by going with a quartz trigger so I can manually check the mailbox using JAvaMail, but like the poster, I would prefer the more elegant MDB approach.
Are you aware of the fact, that the pollingInterval is defined in seconds and not in millis? Your onMessage method is only called every 30000 seconds which is about 8 hours.
Did you solve this issue? I am currently encountering exactly the same behaviour on JBoss 22.214.171.124-M5.
Note: pollingInterval is in millis I think. At least if I configure 60000 it checks the mailbox after exactly 60 seconds (and never ever after that).
I get jboss-6.1.0-Final and deploy my application containing the Message Driven Bean. Emails are consumed from the imap as expected when i start Jboss. But after that no more emails are read from the email account. Did somebody find out a way to solve it?
FWIW - I've just described the issue and uploaded a work around (replacement mail-ra.rar) in the jira.