axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Deepal Jayasinghe <dee...@opensource.lk>
Subject Re: [axis2] Re: svn commit: r538634 - in /webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail: EMailSender.java SimpleMailListener.java SynchronousMailListener.java
Date Wed, 16 May 2007 16:32:56 GMT
Hi Glen,

After release Axis2 we found issues with the SMTP transport , specially
when using RM so we are trying to fix those issues before next RM release.
We have not done enough testing on SMTP transport when we releases 1.2 ,
unfortunately we started to test that after we release 1.2.

In the meantime we have not merge 1.2 and trunk yet , so there are a
number of changes which are only in the branch, and need to merge them soon

Thanks
Deepal

Glen Daniels wrote:
> Hi Amila:
>
> Can I ask why these changes are going into the branch?  Do you have a
> JIRA they're targeting?  Have you already done these improvements in
> the trunk?  If these are really improvements and not critical fixes,
> they should be done on the trunk and not the branch....
>
> Thanks,
> --Glen
>
> amilas@apache.org wrote:
>> Author: amilas
>> Date: Wed May 16 08:58:34 2007
>> New Revision: 538634
>>
>> URL: http://svn.apache.org/viewvc?view=rev&rev=538634
>> Log:
>> 1. Improved Simple mail listener logic
>> 2. Improved Sync mail handling 3. Improved email sender logic
>> Modified:
>>    
>> webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/EMailSender.java
>>
>>    
>> webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/SimpleMailListener.java
>>
>>    
>> webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/SynchronousMailListener.java
>>
>>
>> Modified:
>> webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/EMailSender.java
>>
>> URL:
>> http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/EMailSender.java?view=diff&rev=538634&r1=538633&r2=538634
>>
>> ==============================================================================
>>
>> ---
>> webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/EMailSender.java
>> (original)
>> +++
>> webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/EMailSender.java
>> Wed May 16 08:58:34 2007
>> @@ -17,6 +17,7 @@
>>  
>>  package org.apache.axis2.transport.mail;
>>  
>> +import
>> edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue;
>>  import org.apache.axiom.attachments.ByteArrayDataSource;
>>  import org.apache.axiom.om.OMOutputFormat;
>>  import org.apache.axiom.soap.SOAP11Constants;
>> @@ -24,7 +25,9 @@
>>  import org.apache.axis2.AxisFault;
>>  import org.apache.axis2.addressing.EndpointReference;
>>  import org.apache.axis2.client.Options;
>> +import org.apache.axis2.context.ConfigurationContext;
>>  import org.apache.axis2.context.MessageContext;
>> +import org.apache.axis2.description.TransportInDescription;
>>  import org.apache.commons.logging.Log;
>>  import org.apache.commons.logging.LogFactory;
>>  
>> @@ -98,7 +101,7 @@
>>  
>>  
>>              EndpointReference epr = null;
>> -            MailToInfo mailToInfo = null;
>> +            MailToInfo mailToInfo;
>>  
>>              if (messageContext.getTo() != null &&
>> !messageContext.getTo().hasAnonymousAddress()) {
>>                  epr = messageContext.getTo();
>> @@ -151,6 +154,8 @@
>>              createMailMimeMessage(msg, mailToInfo, format);
>>              Transport.send(msg);
>>  
>> +            log.info("Message being send. [Action = ]" +
>> messageContext.getOptions().getAction());
>> +
>>              sendReceive(messageContext, msg.getMessageID());
>>          } catch (AddressException e) {
>>              throw new AxisFault(e);
>> @@ -223,11 +228,44 @@
>>  
>>      private void sendReceive(MessageContext msgContext, String
>> msgId) throws AxisFault {
>>          storeMessageContext(msgContext, msgId);
>> +
>> +        ConfigurationContext cc = msgContext.getConfigurationContext();
>> +
>> +        SimpleMailListener simpleMailListener;
>> +
>>          Options options = msgContext.getOptions();
>> -        if (!options.isUseSeparateListener()) {
>> -            SynchronousMailListener listener =
>> -                    new
>> SynchronousMailListener(options.getTimeOutInMilliSeconds());
>> -            listener.sendReceive(msgContext, msgId);
>> +        if (!options.isUseSeparateListener() &&
>> !msgContext.isServerSide()) {
>> +            Object obj = cc.getProperty(Constants.MAIL_SYNC);
>> +
>> +            if (obj == null) {
>> +                SynchronousMailListener synchronousMailListener =
>> +                        new
>> SynchronousMailListener(options.getTimeOutInMilliSeconds(), new
>> LinkedBlockingQueue());
>> +                cc.setProperty(Constants.MAIL_SYNC,
>> synchronousMailListener);
>> +
>> +                simpleMailListener =
>> synchronousMailListener.sendReceive(msgContext, msgId);
>> +
>> +                TransportInDescription transportIn =
>> msgContext.getConfigurationContext()
>> +                       
>> .getAxisConfiguration().getTransportIn(org.apache.axis2.Constants.TRANSPORT_MAIL);
>>
>> +
>> +                Object mailPOP3Obj=
>> msgContext.getProperty(Constants.MAIL_POP3);
>> +                if (mailPOP3Obj != null) {
>> +                    simpleMailListener.initFromRuntime((Properties)
>> obj, msgContext);
>> +                } else {
>> +                   
>> simpleMailListener.init(msgContext.getConfigurationContext(),
>> transportIn);
>> +                }
>> +               
>> msgContext.getConfigurationContext().getThreadPool().execute(simpleMailListener);
>>
>> +
>> +                simpleMailListener.start();
>> +                log.info("Simple Mail Listener started for the first
>> time and response received");
>> +
>> +
>> +            } else {
>> +               SynchronousMailListener synchronousMailListener =
>> (SynchronousMailListener)obj;
>> +              
>> synchronousMailListener.sendReceive(msgContext,msgId).start();
>> +                log.info("Simple mail listener started and response
>> received");
>> +
>> +            }
>> +
>>          }
>>  
>>      }
>> @@ -240,7 +278,9 @@
>>              mappingTable = new Hashtable();
>>              msgContext.setProperty(Constants.MAPPING_TABLE,
>> mappingTable);
>>          }
>> -        mappingTable.put(msgId, msgContext.getMessageID());
>> +        if (msgContext.getMessageID() != null) {
>> +            mappingTable.put(msgId, msgContext.getMessageID());
>> +        }
>>  
>>      }
>>  }
>>
>> Modified:
>> webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/SimpleMailListener.java
>>
>> URL:
>> http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/SimpleMailListener.java?view=diff&rev=538634&r1=538633&r2=538634
>>
>> ==============================================================================
>>
>> ---
>> webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/SimpleMailListener.java
>> (original)
>> +++
>> webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/SimpleMailListener.java
>> Wed May 16 08:58:34 2007
>> @@ -278,13 +278,14 @@
>>          }
>>  
>>          while (running) {
>> +            log.info("Info started polling");
>>              try {
>>                  receiver.connect();
>>  
>>                  Message[] msgs = receiver.receiveMessages();
>>  
>>                  if ((msgs != null) && (msgs.length > 0)) {
>> -                    log.info(msgs.length + " Message Found");
>> +                    log.info(msgs.length + " Message(s) Found");
>>  
>>                      for (int i = 0; i < msgs.length; i++) {
>>                          MimeMessage msg = (MimeMessage) msgs[i];
>> @@ -294,7 +295,8 @@
>>                                  messageQueue.add(mc);
>>                              }
>>                          } catch (Exception e) {
>> -                            log.error("Error in SimpleMailListener -
>> processing mail " + e);
>> +                            e.printStackTrace();
>> +                            log.error("Error in SimpleMailListener -
>> processing mail",e);
>>                          } finally {
>>                              // delete mail in any case
>>                              msg.setFlag(Flags.Flag.DELETED, true);
>> @@ -305,7 +307,7 @@
>>                  receiver.disconnect();
>>  
>>              } catch (Exception e) {
>> -                log.error("Error in SimpleMailListener" + e);
>> +                log.error("Error in SimpleMailListener", e);
>>              } finally {
>>                  try {
>>                      Thread.sleep(listenerWaitInterval);
>>
>> Modified:
>> webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/SynchronousMailListener.java
>>
>> URL:
>> http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/SynchronousMailListener.java?view=diff&rev=538634&r1=538633&r2=538634
>>
>> ==============================================================================
>>
>> ---
>> webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/SynchronousMailListener.java
>> (original)
>> +++
>> webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/SynchronousMailListener.java
>> Wed May 16 08:58:34 2007
>> @@ -18,6 +18,7 @@
>>  import
>> edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue;
>>  import org.apache.axis2.AxisFault;
>>  import org.apache.axis2.context.MessageContext;
>> +import org.apache.axis2.context.ContextFactory;
>>  import org.apache.axis2.description.TransportInDescription;
>>  import org.apache.axis2.wsdl.WSDLConstants;
>>  import org.apache.commons.logging.Log;
>> @@ -33,24 +34,25 @@
>>      private static Log log =
>> LogFactory.getLog(SynchronousMailListener.class);
>>  
>>      private long timeoutInMilliseconds = -1;
>> +    private LinkedBlockingQueue queue;
>>  
>> -    public SynchronousMailListener(long timeoutInMilliseconds) {
>> +    public SynchronousMailListener(long
>> timeoutInMilliseconds,LinkedBlockingQueue queue) {
>>          this.timeoutInMilliseconds = timeoutInMilliseconds;
>> +        this.queue = queue;
>>      }
>>  
>>  
>> -    public void sendReceive(final MessageContext msgContext, final
>> String msgId) throws AxisFault {
>> +    public SimpleMailListener sendReceive(final MessageContext
>> msgContext, final String msgId) throws AxisFault {
>>          /**
>>           * This will be bloked invocation
>>           */
>> -        SimpleMailListener listener = new SimpleMailListener(new
>> LinkedBlockingQueue()) {
>> +        return new SimpleMailListener(queue) {
>>              public void start() throws AxisFault {
>>                  long timeStatus;
>> -                LinkedBlockingQueue queue = getLinkedBlockingQueue();
>>                  while (true) {
>>                      long startTime = System.currentTimeMillis();
>>                      try {
>> -                        MessageContext msgCtx = (MessageContext)
>> queue.take();
>> +                        MessageContext msgCtx = (MessageContext)
>> getLinkedBlockingQueue().take();
>>                          MailBasedOutTransportInfo transportInfo =
>> (MailBasedOutTransportInfo) msgCtx
>>                                 
>> .getProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO);
>>                          if (transportInfo.getInReplyTo() == null) {
>> @@ -59,13 +61,21 @@
>>                              throw new AxisFault(error);
>>                          }
>>                          if
>> (transportInfo.getInReplyTo().equals(msgId)) {
>> -                            //TODO do the correct operation
>> dispatching here
>> -                            msgContext.getOperationContext()
>> -                                   
>> .getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE)
>> +                            MessageContext messageContext =
>> msgContext.getOperationContext()
>> +                                   
>> .getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
>> +                            if (messageContext == null) {
>> +                                messageContext =
>> ContextFactory.createMessageContext(msgContext.getConfigurationContext());
>>
>> +                               
>> messageContext.setOperationContext(msgContext.getOperationContext());
>> +                               
>> messageContext.setServiceContext(msgContext.getServiceContext());
>> +                               
>> msgContext.getOperationContext().addMessageContext(messageContext);
>> +                            }
>> +                            messageContext
>>                                      .setEnvelope(msgCtx.getEnvelope());
>> +                            log.info("SOAP Message :: " +
>> messageContext.getEnvelope());
>>                             
>> log.info(SynchronousMailListener.class.getName() + " found the
>> required message.");
>>                              break;
>>                          }
>> +                        getLinkedBlockingQueue().put(msgCtx);
>>  
>>                      } catch (InterruptedException e) {
>>                          log.warn(e);
>> @@ -85,17 +95,6 @@
>>              }
>>          };
>>  
>> -        TransportInDescription transportIn =
>> msgContext.getConfigurationContext()
>> -               
>> .getAxisConfiguration().getTransportIn(org.apache.axis2.Constants.TRANSPORT_MAIL);
>>
>> -
>> -        Object obj = msgContext.getProperty(Constants.MAIL_POP3);
>> -        if (obj != null) {
>> -            listener.initFromRuntime((Properties)obj,msgContext);
>> -        } else {
>> -            listener.init(msgContext.getConfigurationContext(),
>> transportIn);
>> -        }
>> -       
>> msgContext.getConfigurationContext().getThreadPool().execute(listener);
>> -        listener.start();
>>  
>>      }
>>  
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-cvs-help@ws.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>
>

-- 
Thanks,
Deepal
................................................................
"The highest tower is built one brick at a time"



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Mime
View raw message