Search in sources :

Example 1 with DispositionType

use of com.helger.as2lib.disposition.DispositionType in project as2-lib by phax.

the class AsynchMDNSenderModule method handle.

public void handle(@Nonnull final String sAction, @Nonnull final IMessage aBaseMsg, @Nullable final Map<String, Object> aOptions) throws AS2Exception {
    try (final AS2ResourceHelper aResHelper = new AS2ResourceHelper()) {
        final AS2Message aMsg = (AS2Message) aBaseMsg;
        if (LOGGER.isInfoEnabled())
            LOGGER.info("Async MDN submitted" + aMsg.getLoggingText());
        final DispositionType aDisposition = DispositionType.createSuccess();
        final int nRetries = getRetryCount(aMsg.partnership(), aOptions);
        try (final IHTTPOutgoingDumper aOutgoingDumper = getHttpOutgoingDumper(aMsg)) {
            _sendViaHTTP(aMsg, aDisposition, aOutgoingDumper, aResHelper);
        } catch (final AS2HttpResponseException ex) {
            if (LOGGER.isErrorEnabled())
                LOGGER.error("Http Response Error " + ex.getMessage());
            // Resend if the HTTP Response has an error code
            ex.terminate();
            if (!doResend(IProcessorSenderModule.DO_SEND_ASYNC_MDN, aMsg, ex, nRetries))
                throw ex;
        } catch (final IOException ex) {
            // Resend if a network error occurs during transmission
            final AS2Exception wioe = WrappedAS2Exception.wrap(ex).setSourceMsg(aMsg).terminate();
            if (!doResend(IProcessorSenderModule.DO_SEND_ASYNC_MDN, aMsg, wioe, nRetries))
                throw wioe;
        } catch (final Exception ex) {
            // Propagate error if it can't be handled by a resend
            throw WrappedAS2Exception.wrap(ex);
        }
    } finally {
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("Async MDN message sent");
    }
}
Also used : AS2ResourceHelper(com.helger.as2lib.util.AS2ResourceHelper) DispositionType(com.helger.as2lib.disposition.DispositionType) AS2Message(com.helger.as2lib.message.AS2Message) AS2Exception(com.helger.as2lib.exception.AS2Exception) WrappedAS2Exception(com.helger.as2lib.exception.WrappedAS2Exception) IHTTPOutgoingDumper(com.helger.as2lib.util.dump.IHTTPOutgoingDumper) IOException(java.io.IOException) MessagingException(javax.mail.MessagingException) AS2Exception(com.helger.as2lib.exception.AS2Exception) WrappedAS2Exception(com.helger.as2lib.exception.WrappedAS2Exception) AS2NoModuleException(com.helger.as2lib.processor.AS2NoModuleException) IOException(java.io.IOException) AS2ComponentNotFoundException(com.helger.as2lib.session.AS2ComponentNotFoundException)

Aggregations

DispositionType (com.helger.as2lib.disposition.DispositionType)1 AS2Exception (com.helger.as2lib.exception.AS2Exception)1 WrappedAS2Exception (com.helger.as2lib.exception.WrappedAS2Exception)1 AS2Message (com.helger.as2lib.message.AS2Message)1 AS2NoModuleException (com.helger.as2lib.processor.AS2NoModuleException)1 AS2ComponentNotFoundException (com.helger.as2lib.session.AS2ComponentNotFoundException)1 AS2ResourceHelper (com.helger.as2lib.util.AS2ResourceHelper)1 IHTTPOutgoingDumper (com.helger.as2lib.util.dump.IHTTPOutgoingDumper)1 IOException (java.io.IOException)1 MessagingException (javax.mail.MessagingException)1