Skip to content
Permalink
Browse files
- log exceptions when reading forwarded mail
- fix reflection calls for methods having void parameter list

git-svn-id: https://svn.apache.org/repos/asf/james/postage/trunk@420489 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Bernd Fondermann committed Jul 10, 2006
1 parent 3b993f5 commit 0677519694c1e948c4f211edb3b79be1720463dc
Showing 2 changed files with 12 additions and 6 deletions.
@@ -37,6 +37,7 @@ public class JVMResourceSampler implements Sampler {
private Object jvmResourceSampleWorker = null;
private Method m_connectMethod;
private Method m_doSampleMethod;
private static final Class[] VOID_ARGUMENT_LIST = new Class[]{};

public static boolean isJMXAvailable() {
try {
@@ -64,22 +65,23 @@ public JVMResourceSampler(String host, int port, PostageRunnerResult results) {
try {
jvmResourceSampleWorker = constructor.newInstance(new Object[]{host, new Integer(port), results});
} catch (Exception e) {
throw new IllegalStateException("could not create JVMResourceSamplerWorker");
throw new IllegalStateException("could not create JVMResourceSamplerWorker", e);
}
if (jvmResourceSampleWorker == null) throw new IllegalStateException("could not create JVMResourceSamplerWorker");

try {
m_connectMethod = workerClass.getMethod("connectRemoteJamesJMXServer", (Class)null);
m_doSampleMethod = workerClass.getMethod("doSample", (Class)null);
m_connectMethod = workerClass.getMethod("connectRemoteJamesJMXServer", VOID_ARGUMENT_LIST);
m_doSampleMethod = workerClass.getMethod("doSample", VOID_ARGUMENT_LIST);
} catch (NoSuchMethodException e) {
throw new IllegalStateException("could not access delegation methods");
throw new IllegalStateException("could not access delegation methods", e);
}

}

public void connectRemoteJamesJMXServer() throws SamplingException {
if(jvmResourceSampleWorker == null) throw new SamplingException("JSE specific features not present. (compile the project with JSE 5)");
try {
m_connectMethod.invoke(jvmResourceSampleWorker, (Class)null);
m_connectMethod.invoke(jvmResourceSampleWorker, VOID_ARGUMENT_LIST);
} catch (Exception e) {
throw new SamplingException("could not establish connection to remote James JMX. is James really configured for JMX and running under JSE5 or later?");
}
@@ -88,7 +90,7 @@ public void connectRemoteJamesJMXServer() throws SamplingException {
public void doSample() throws SamplingException {
if(jvmResourceSampleWorker == null) throw new SamplingException("JSE specific features not present. (compile the project with JSE 5)");
try {
m_doSampleMethod.invoke(jvmResourceSampleWorker, (Class)null);
m_doSampleMethod.invoke(jvmResourceSampleWorker, VOID_ARGUMENT_LIST);
} catch (Exception e) {
throw new SamplingException(e);
}
@@ -49,6 +49,7 @@ public class SimpleMailServer implements MailServer {
private PostageRunnerResult m_results;

public void sendMail(MailAddress sender, Collection recipients, MimeMessage msg) throws MessagingException {
//log.info("start processing incoming mail having id = " + msg.getMessageID());
MailProcessingRecord mailProcessingRecord = new MailProcessingRecord();
mailProcessingRecord.setReceivingQueue("smtpOutbound");
mailProcessingRecord.setTimeFetchStart(System.currentTimeMillis());
@@ -71,6 +72,9 @@ public void sendMail(MailAddress sender, Collection recipients, MimeMessage msg)
// TODO mailProcessingRecord.setByteReceivedBinary();

mailProcessingRecord.setTimeFetchEnd(System.currentTimeMillis());
} catch(MessagingException e) {
log.error("error processing incoming mail: " + e.getMessage());
throw e; // rethrow after logging
} finally{
boolean matched = m_results.matchMailRecord(mailProcessingRecord);
if (!matched) {

0 comments on commit 0677519

Please sign in to comment.