Class DirectoryResenderModule
java.lang.Object
com.helger.as2lib.AbstractDynamicComponent
com.helger.as2lib.processor.module.AbstractProcessorModule
com.helger.as2lib.processor.module.AbstractActiveModule
com.helger.as2lib.processor.resender.AbstractActiveResenderModule
com.helger.as2lib.processor.resender.DirectoryResenderModule
- All Implemented Interfaces:
IDynamicComponent
,IProcessorActiveModule
,IProcessorModule
,IProcessorResenderModule
An asynchronous, persisting, file based, polling resender module. Upon
handle(String, IMessage, Map)
it writes the document into a file and
there is a background poller task that checks for resending (see
resend()
). If re-sending fails, the document is moved into an error
folder.- Author:
- OpenAS2, Philip Helger
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The error directory.static final String
static final String
Optional filename for storage in the error directory.Fields inherited from class com.helger.as2lib.processor.resender.AbstractActiveResenderModule
ATTR_POLLING_INTERVAL_SECONDS, ATTR_RESEND_DELAY_SECONDS, DEFAULT_POLLING_MS, DEFAULT_RESEND_DELAY_MS
Fields inherited from class com.helger.as2lib.AbstractDynamicComponent
m_aRWLock
Fields inherited from interface com.helger.as2lib.processor.resender.IProcessorResenderModule
DEFAULT_RETRIES, DO_RESEND, DO_RESENDMDN, OPTION_CAUSE, OPTION_INITIAL_SENDER, OPTION_RESEND_ACTION, OPTION_RETRIES
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Check if this processor module can handle a certain action on the provided messageprotected String
Build the filename for re-sending.void
Main handling of the message.void
initDynamicComponent
(IAS2Session aSession, com.helger.commons.collection.attr.IStringMap aOptions) After creating a Component object, this method should be called to set any parameters used by the component.protected boolean
isTimeToSend
(File aCurrentFile) void
resend()
protected void
resendFile
(File aFile) protected com.helger.commons.collection.impl.ICommonsList<File>
Methods inherited from class com.helger.as2lib.processor.resender.AbstractActiveResenderModule
doStart, doStop, equals, getResendDelayMS, hashCode
Methods inherited from class com.helger.as2lib.processor.module.AbstractActiveModule
forceStop, isRunning, start, stop, toString
Methods inherited from class com.helger.as2lib.AbstractDynamicComponent
attrs, getAttributeAsIntRequired, getAttributeAsStringRequired, getName, getSession
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.helger.as2lib.IDynamicComponent
attrs, getName, getSession
-
Field Details
-
ATTR_RESEND_DIRECTORY
- See Also:
-
ATTR_ERROR_DIRECTORY
The error directory. May contain "date" parameters.- See Also:
-
ATTR_STORED_ERROR_FILENAME
Optional filename for storage in the error directory. May contain "date" parameters.- Since:
- 4.8.0
- See Also:
-
-
Constructor Details
-
DirectoryResenderModule
public DirectoryResenderModule()
-
-
Method Details
-
initDynamicComponent
public void initDynamicComponent(@Nonnull IAS2Session aSession, @Nullable com.helger.commons.collection.attr.IStringMap aOptions) throws AS2Exception Description copied from interface:IDynamicComponent
After creating a Component object, this method should be called to set any parameters used by the component. Component implementations typically have required parameter checking and code to start timers and threads within this method.- Specified by:
initDynamicComponent
in interfaceIDynamicComponent
- Overrides:
initDynamicComponent
in classAbstractActiveResenderModule
- Parameters:
aSession
- the component uses this object to access other componentsaOptions
- configuration values for the component. All parameters will be stored as attributes of this component. All attributes existing before this method is called will be removed!- Throws:
AS2Exception
- If an error occurs while initializing the componentAS2InvalidParameterException
- If a required parameter is null in the parameters Map- See Also:
-
canHandle
public boolean canHandle(@Nonnull String sAction, @Nonnull IMessage aMsg, @Nullable Map<String, Object> aOptions) Description copied from interface:IProcessorModule
Check if this processor module can handle a certain action on the provided message- Specified by:
canHandle
in interfaceIProcessorModule
- Overrides:
canHandle
in classAbstractActiveModule
- Parameters:
sAction
- The action to be executed. Nevernull
.aMsg
- The message in question. May be an AS2 message or an MDN message. Nevernull
.aOptions
- The options to be considered. May benull
.- Returns:
true
of this module can handle the respective message,false
if not.
-
getFilename
Build the filename for re-sending. The filename consists of the date and time when the document is to be re-send.- Returns:
- The filename and never
null
. - Throws:
AS2InvalidParameterException
- Only theoretically
-
handle
public void handle(@Nonnull String sAction, @Nonnull IMessage aMsg, @Nullable Map<String, Object> aOptions) throws AS2ExceptionDescription copied from interface:IProcessorModule
Main handling of the message. Only called, ifIProcessorModule.canHandle(String, IMessage, Map)
returnedtrue
.- Specified by:
handle
in interfaceIProcessorModule
- Overrides:
handle
in classAbstractActiveModule
- Parameters:
sAction
- The action to be executed. Nevernull
.aMsg
- The message in question. May be an AS2 message or an MDN message. Nevernull
.aOptions
- The options to be considered. May benull
.- Throws:
AS2Exception
- in case something goes wrong
-
isTimeToSend
-
resendFile
- Throws:
AS2Exception
-
scanDirectory
@Nonnull @ReturnsMutableCopy protected com.helger.commons.collection.impl.ICommonsList<File> scanDirectory() throws AS2InvalidParameterException- Returns:
- A list with all files that are ready to be resend.
- Throws:
AS2InvalidParameterException
- In case the directory listing fails
-
resend
public void resend()- Specified by:
resend
in classAbstractActiveResenderModule
-