Prototype JavaMail RAR in head
starksm64 Nov 21, 2004 1:12 PMA prototype JavaMail resource adaptor that support message inflow to allow messages from a mail folder to be delivered to MDBs has been added to head. Deployment of the mail-ra.rar allows one to deploy JavaMail based MDBs as shown by this example code:
ejb-jar.xml:
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
version="2.1">
<enterprise-beans>
<message-driven>
<description>An MDB that accepts mail messages</description>
<ejb-name>MailMDB</ejb-name>
<ejb-class>org.jboss.test.jca.inflowmdb.TestJavaMailMDB</ejb-class>
<messaging-type>org.jboss.resource.adapter.mail.inflow.MailListener</messaging-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>mailServer</activation-config-property-name>
<activation-config-property-value>${mailhost:mailhost}</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>mailFolder</activation-config-property-name>
<activation-config-property-value>INBOX</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>storeProtocol</activation-config-property-name>
<activation-config-property-value>imap</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>userName</activation-config-property-name>
<activation-config-property-value>jduke</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>password</activation-config-property-name>
<activation-config-property-value>theduke</activation-config-property-value>
</activation-config-property>
</activation-config>
<transaction-type>Container</transaction-type>
</message-driven>
</enterprise-beans>
</ejb-jar>
jboss.xml:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd"> <jboss> <enterprise-beans> <message-driven> <ejb-name>MailMDB</ejb-name> <resource-adapter-name>mail-ra.rar</resource-adapter-name> </message-driven> </enterprise-beans> </jboss>
Sample MDB:
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.test.jca.inflowmdb;
import javax.ejb.MessageDrivenBean;
import javax.ejb.MessageDrivenContext;
import javax.mail.Message;
import org.jboss.resource.adapter.mail.inflow.MailListener;
import org.jboss.logging.Logger;
/**
* A JavaMail based MDB.
*
* @author Scott.stark@jboss.org
* @version $Revision: 1.1 $
*/
public class TestJavaMailMDB
implements MessageDrivenBean, MailListener
{
private static Logger log = Logger.getLogger(TestJavaMailMDB.class);
private MessageDrivenContext ctx;
public void ejbCreate()
{
log.info("ejbCreate");
}
public void ejbRemove()
{
log.info("ejbRemove");
}
public void setMessageDrivenContext(MessageDrivenContext ctx)
{
this.ctx = ctx;
}
public void onMessage(Message msg)
{
log.info("onMessage, msg="+msg);
}
}