phax / as2-lib

A generic Java AS2 library, servlet and server
107 stars 43 forks source link

Can AS2DirectoryPollingModule run with as2-lib-spring-demo #129

Closed GeeinHub closed 2 years ago

GeeinHub commented 2 years ago

Hi Philip, I started the as2-lib-spring-boot, and it can receive msg from openas2 server, can also send msg using the AS2Client, then I tried to send via polling , added polling module config as below:

    <module enabled="true"
            classname="com.helger.as2lib.processor.receiver.AS2DirectoryPollingModule"
            outboxdir="D:/gitrepo/as2-lib-spring-demo/data/toopenas2a/"
            errordir="D:/gitrepo/as2-lib-spring-demo/data/toopenas2a/error/$date.YYYY$/$date.MM$"
            stored_error_filename="$msg.attributes.filename$-$date.YYYY$-$date.MM$-$msg.headers.message-id$"
            sentdir="data/$msg.sender.as2_id$-$msg.receiver.as2_id$/sent/$date.YYYY$/$date.MM$"
            stored_sent_filename="$msg.attributes.filename$-$msg.headers.message-id$"
            interval="5"
            defaults="sender.as2_id=openas2b, receiver.as2_id=openas2a"
            sendfilename="true"
            mimetype="application/EDI-X12"/>

but seems the module not running, although loaded.

[10:21 13:53:08.497] [DEBUG] [com.helger.as2lib.util.AS2XMLHelper] - Finished initializing [[com.helger.as2lib.processor.receiver.AS2DirectoryPollingModule@2c60ce47]; Running=false] [10:21 13:53:08.497] [INFO] [com.helger.as2servlet.util.AS2ServletXMLSession] - Loaded processor module AS2DirectoryPollingModule

could you please advise how can I do? Thanks

phax commented 2 years ago

I looked at your configuration and it seems to be okay. I am however not sure if D:/gitrepo/as2-lib-spring-demo/data/toopenas2a/ works, or whether it would be better to use D:\gitrepo\as2-lib-spring-demo\data\toopenas2a\.

For enhanced debugging I recommend to turn up the log level of Log4J from info to debug and see, if some polling takes place.

GeeinHub commented 2 years ago

Hi Philip, It seems All instances of AbstractActiveModule are started by AS2ServerXMLSession in the main method of MainOpenAS2Server, it's not included in as2-lib or as2-servlet, so the AS2DirectoryPollingModule will not start in currnet as2-servlet apps, the AS2ServletXMLSession loads the MessageProcessor, but it doesn't start all active modules, so far, I haven't found a way to acquire the AS2ServletXMLSession in my app code and I guess it's designed for internal use?

phax commented 2 years ago

Okay, I think I got it. There are imho 2 things in the current version:

  1. The AS2 configuration only gets read when accessing /as2 or /as2mdn for the first time and
  2. The active modules are never started (hence they are also not shut down)

I made the necessary adjustments in the as2-demo-spring-boot application and pushed a new version of 4.8.0-SNAPSHOT to Maven Central for Snapshots. Please verify if that works for you too.

phax commented 2 years ago

A few more things relevant to your configuration example:

phax commented 2 years ago

It's your lucky day ;-) Both parameters stored_error_filename and stored_sent_filename are now supported (with msg and date parameters available). The latest SNAPSHOT is pushed...

GeeinHub commented 2 years ago

Hi Philip, Thank you so much for such quick upgrade, yes, following the latest sample, the polling module can start successfully, and with AS2SenderModule, message can be sent to my OpenAs2Server successfully. Regarding stored_error_filename and stored_sent_filename, I just copied the config from OpenAs2Server, didn't realize the problem, thanks again. :-D 👍

phax commented 2 years ago

Okay cool. so this issue can be closed. Release 4.8.0 coming soon