-1

Following is the requirement for our application -

  1. User makes modifications to content on page for a purchase item. There could be a max of 6 purchase items like that, which he can navigate through with back and forward buttons.
  2. Once he finishes his edit, he can click on generate PDF.

On clicking generate PDF, the following needs to happen -

  • Request gets forwarded to application and application needs to persist data for all 6 items in around 4 relational DB tables. Each table has between 5-15 columns at max.
  • The request should then get forwarded from application to Jasper server to prepare PDF from data that is persisted.
    • Once PDF is ready, Jasper server needs to send the response back as a byte-stream to application which should in turn forward it back to browser.
    • Generated PDF should start downloading on the browser.

Questions

While the above defines the requirement, having the PDF document downloadable on the browser with the above sequence of events as a synchronous request will make the user wait indefinitely.

My thoughts to address this will be fire the first request as an asynchronous request to generate PDF. Have a poll set up from browser to application to verify if PDF is available for download, if yes, then display the 'Download' button to have the user simply fetch the PDF.

Any other suggestions on how to approach design?

Alex K
  • 22,315
  • 19
  • 108
  • 236
Karthik Shivkumar
  • 121
  • 1
  • 2
  • 14

1 Answers1

1

The design that you have mentioned is based on polling. The other solution for this is PUSH. Whenever server is ready it should be able to PUSH the content to client. This can be achieved by reverse-ajax or web-sockets.

However, there is trade-off between both (POLL and PUSH) approaches. You will have to analyze your environment and will have to decide which suits best for your requirements. Please refer: AJAX/Reverse AJAX: Polling or Push? for more details on POLL-vs-PUSH issue.

Community
  • 1
  • 1
Vijay Pande
  • 276
  • 2
  • 8