Skip to content

Repository files navigation

yopenedi

OpenTrans 2.1/EDIFACT D.96A File converter

  1. Convert order Files to and from OpenTrans 2.1/EDIFACT D.96A
    Focus on the opening UNH/UNT Tags. They contain the order information like Buyer, Seller, Contact Address and itmes list. UNB is just the message header. Each order file will only contain one combination of UNH/UNT that needs be converted into Opentrans 2.1 XML (Sample Order XML Files from OpenTrans 2.1)
  2. Send order files as attachment in EDIFACT D.96A format to an IMAP Email address and convert them to the OpenTrans 2.1 format.
  3. Send order files to a domain i.e. https://test.yopenedi.ch/as2 using the AS2 standard according to MIME-Based Secure Peer-to-Peer Business Data Interchange Using HTTP, Applicability Statement 2 (AS2)
  4. Import OpenTrans 2.1 files from FTP and convert them to EDIFACT D.96A and send the converted file as Email-Attachment from an IMAP Email address to a dedicated Email address.
  5. Send Opentrans 2.1 XML files to this URL
  6. Receive Opentrans 2.1 XML files at this URL

FAQ

EDIFACT D.96A

Useful Windows Tools

Opentrans 2.1

AS2 Gateway

Send AS2 message with Curl

Certbot for Ubuntu 20.04

Digital Ocean deployment

Input and Output files

  • Input files: yopenedi/edifact_orders
  • Output files: yopenedi/opentrans_orders

Keeping the server from hanging

The Play server is supervised by daemontools (/etc/service/prod.yopenedi.ch/run, controlled with svc -d / svc -u), which restarts a service that exits but never one that is merely wedged. Three things guard against a stuck partner taking the server down:

  • Every outbound call is bounded. HTTP, SMTP, IMAP and SFTP all have connect and read timeouts (com.ywesee.java.yopenedi.common.Timeouts). Override any of them per-process without a rebuild:
    -Dyopenedi.connectTimeout=30   -Dyopenedi.readTimeout=120
    -Dyopenedi.writeTimeout=120    -Dyopenedi.http.readTimeout=120
    -Dyopenedi.maxRuntime=1800     # email-fetcher run limit, 0 disables
    
  • The AS2 MDN is returned before the order is forwarded downstream. Conversion and result dispatch run on a dedicated pool (contexts.blocking-io-dispatcher) so they cannot starve the threads that answer requests. Holding the MDN behind the downstream forward is what made senders report SocketTimeoutException: Read timed out.
  • A health check covers the supervisor gap. Add java/scripts/yopenedi-healthcheck.sh to /etc/crontab; after three consecutive non-responses it takes a thread dump and restarts the service. Note the user column -- /etc/crontab requires it and user crontabs do not, and the job needs root to control the service:
    */2 * * * * root /home/zdavatz/software/yopenedi/java/scripts/yopenedi-healthcheck.sh
    

Recommended additions to JAVA_OPTS in the run script, so an out-of-memory stall also turns into a restart instead of a wedge:

export JAVA_OPTS="$JAVA_OPTS -XX:+ExitOnOutOfMemoryError -XX:+HeapDumpOnOutOfMemoryError"

The email-fetcher has a watchdog of its own: if a run exceeds maxRuntime it dumps all thread stacks and exits with code 3, so a hang leaves an explanation in the log.

Apache setup

<VirtualHost *:80>
  ServerName test.yopenedi.ch
  Redirect permanent / https://test.yopenedi.ch
</VirtualHost>

<VirtualHost 104.248.255.2:443>
  ServerName test.yopenedi.ch
  ProxyPreserveHost On
  ProxyPass  /excluded !
  ProxyPass / http://127.0.0.1:3000/
  ProxyPassReverse / http://127.0.0.1:3000/
  SSLEngine on
  SSLCertificateFile /etc/letsencrypt/live/test.yopenedi.ch/cert.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/test.yopenedi.ch/privkey.pem
  SSLCertificateChainFile /etc/letsencrypt/live/test.yopenedi.ch/chain.pem
</VirtualHost>

About

OpenTrans 2.1/EDIFACT D.96A File converter

Topics

Resources

Stars

4 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages