[Beginners Corner] - Mail Receiver
by RogerWBMD
I am new to Jboss and trying to write an email receiver by following http://wiki.jboss.org/wiki/InboundJavaMail. I created a new EJB3 MDB and put the sample code in it. It seems nothing happen after that. Is there anything I need to do, such as update the component.xml, to make it work.
Environment:
JBoss Developer Studio
jboss-4.2.2.GA
Code:
| package org.domain.OpsAI.mdb;
|
| import javax.ejb.ActivationConfigProperty;
| import javax.ejb.MessageDriven;
| import javax.mail.Message;
| import javax.mail.MessagingException;
|
| import org.jboss.annotation.ejb.ResourceAdapter;
| import org.jboss.resource.adapter.mail.inflow.MailListener;
| import org.jboss.logging.Logger;
| import org.jboss.seam.annotations.Name;
|
|
| /**
| * A JavaMail based MDB for EJB3 use
| */
| @MessageDriven(activationConfig={
| @ActivationConfigProperty(propertyName="mailServer", propertyValue="xx.xx.xx.xx"),
| @ActivationConfigProperty(propertyName="mailFolder", propertyValue="INBOX"),
| @ActivationConfigProperty(propertyName="storeProtocol", propertyValue="imap"),
| @ActivationConfigProperty(propertyName="userName", propertyValue="xxx"),
| @ActivationConfigProperty(propertyName="password", propertyValue="xxx")
| })
| @ResourceAdapter("mail-ra.rar")
| @Name("OpsaiMailListener")
| public class OpsaiMailListener implements MailListener
| {
| private static Logger log = Logger.getLogger(OpsaiMailListener.class);
|
| public void onMessage(Message msg)
| {
| try{
| log.info("onMessage, msg="+msg);
| System.out.println("got it"+msg.getSubject());
| }catch(MessagingException me){
| me.printStackTrace();
| }
| }
| }
|
I also put the following in component.xml - I am not sure if it is necessary
<mail:mail-session session-jndi-name="java:/Mail"/>
And the mail-service.xml
| <?xml version="1.0" encoding="UTF-8"?>
| <!-- $Id: mail-service.xml 62349 2007-04-15 16:48:15Z dimitris(a)jboss.org $ -->
| <server>
|
| <!-- ==================================================================== -->
| <!-- Mail Connection Factory -->
| <!-- ==================================================================== -->
|
| <mbean code="org.jboss.mail.MailService"
| name="jboss:service=Mail">
| <attribute name="JNDIName">java:/Mail</attribute>
| <attribute name="User">xxx</attribute>
| <attribute name="Password">xxx</attribute>
| <attribute name="Configuration">
| <!-- A test configuration -->
| <configuration>
| <!-- Change to your mail server prototocol -->
| <property name="mail.store.protocol" value="imap"/>
| <property name="mail.transport.protocol" value="smtp"/>
|
| <!-- Change to the user who will receive mail -->
| <property name="mail.user" value="nobody"/>
|
| <!-- Change to the mail server -->
| <property name="mail.imap.host" value="xx.xx.xx.xx"/>
|
| <!-- Change to the SMTP gateway server -->
| <property name="mail.smtp.host" value="xx.xx.net"/>
|
| <!-- The mail server port -->
| <property name="mail.smtp.port" value="25"/>
|
| <!-- Change to the address mail will be from -->
| <property name="mail.from" value="cms(a)qa.pol.net"/>
|
| <!-- Enable debugging output from the javamail classes -->
| <property name="mail.debug" value="true"/>
| </configuration>
| </attribute>
| <depends>jboss:service=Naming</depends>
| </mbean>
| </server>
|
And I got the log after I made the mail-service.xml change
| 13:50:22,963 INFO [MailService] Mail service 'java:/Mail' removed from JNDI
| 13:50:22,978 INFO [STDOUT] DEBUG: JavaMail version 1.4ea
| 13:50:22,978 INFO [STDOUT] DEBUG: java.io.FileNotFoundException: C:\Dev\Java\jdk1.5.0_15\jre\lib\javamail.providers (The system cannot find the file specified)
| 13:50:22,978 INFO [STDOUT] DEBUG: !anyLoaded
| 13:50:22,978 INFO [STDOUT] DEBUG: not loading resource: /META-INF/javamail.providers
| 13:50:22,978 INFO [STDOUT] DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
| 13:50:22,978 INFO [STDOUT] DEBUG: Tables of loaded providers
| 13:50:22,978 INFO [STDOUT] DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
| 13:50:22,978 INFO [STDOUT] DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
| 13:50:22,978 INFO [STDOUT] DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
| 13:50:22,978 INFO [STDOUT] DEBUG: !anyLoaded
| 13:50:22,978 INFO [STDOUT] DEBUG: not loading resource: /META-INF/javamail.address.map
| 13:50:22,978 INFO [STDOUT] DEBUG: java.io.FileNotFoundException: C:\Dev\Java\jdk1.5.0_15\jre\lib\javamail.address.map (The system cannot find the file specified)
| 13:50:22,994 INFO [MailService] Mail Service bound to java:/Mail
|
Any input is appreciated
Thanks
Roger
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4152457#4152457
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4152457
17 years, 11 months
[JBoss Cache: Core Edition] - Re: State transfer errors
by manik.surtani@jboss.com
Sorry for being so slow with this.
I don't see a problem here. Yes, your test fails, but that is due to a few minor issues.
1. Make sure you have the following enabled in your buddy replication config:
| <autoDataGravitation>true</autoDataGravitation>
|
2. After starting cache2, the BR organisation code takes a short while to assign buddies, etc. So calling switchCache() immediately after starting is a problem. You could either (1) wait for a short while, or much better, (2) register a listener on cache2 so you know when it has been assigned to a buddy group. I created a listener like:
| private void doTest()
| {
| ...
| final CountDownLatch latch = new CountDownLatch(1);
| cache2.addCacheListener(new BRListener(latch));
| cache2.start();
| latch.await();
|
| switchCache(OBJECTS / 2, OBJECTS, workers);
| ...
| }
|
| @CacheListener
| public static class BRListener
| {
| CountDownLatch latch;
|
| public BRListener(CountDownLatch latch)
| {
| this.latch = latch;
| }
|
| @BuddyGroupChanged
| public void releaseLatch(BuddyGroupChangedEvent event)
| {
| latch.countDown();
| }
| }
|
|
HTH,
Manik
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4152432#4152432
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4152432
17 years, 11 months