我試圖接收帶有消息驅動bean的電子郵件。我正在使用jboss wildfly。 Unfortunatley,我找不到真正的文件。這是迄今爲止我發現的最多:用於接收電子郵件的MDB
@MessageDriven(activationConfig={
@ActivationConfigProperty(propertyName="mailServer", propertyValue="imap.gmail.com"),
@ActivationConfigProperty(propertyName="mailFolder", propertyValue="INBOX"),
@ActivationConfigProperty(propertyName="storeProtocol", propertyValue="imap"),
@ActivationConfigProperty(propertyName="userName", propertyValue="[email protected]"),
@ActivationConfigProperty(propertyName="password", propertyValue="xxx")
})
@ResourceAdapter("mail-ra.rar")
public class EMailReceiver implements MailListener {
@Override
public void onMessage(Message msg) {
System.out.println("MSG: " + msg.toString());
}
}
我對如何使這項工作有幾個問題。對不起,我把它們都歸爲一個問題,但我相信它們屬於一個整體。
- 什麼是此ResourceAdapter?我可以找到一個ResourceAdapter類,但不是註釋。
- 我在哪裏可以得到正確的mail-ra.rar,我在哪裏放?我揣測這可能會有不同的版本,我無法在野蠅內找到它。
- 是註釋配置足夠還是我需要在xml中配置任何東西?
'mail-ra.rar'由IronJacamar項目提供。 AS7有一個[論壇帖子](https://community.jboss.org/message/725319),可能也會幫助Wildfly。 Tbh,在提供的文檔中查看幾分鐘後,我感到害怕,並回到基於定時器的EJB的安全性。既然你使用gmail作爲例子,如果你投票(使用計時器服務)而不是對消息作出反應(無論如何將由投票服務產生),我想你可以省下很多工作。 – mabi
謝謝。我想我也會去定時器路線。 MDB看起來很誘人,因爲它看起來像一個開箱即用的解決方案。但我想這不是。 – EasterBunnyBugSmasher