The demo shows how to write web services to work with very large amounts of data. This demo uses either MIME multipart/related encoding or DIME which can handle large amounts of data efficiently.
Applications that have to process very large amounts of data tend to suffer from performance problems. You can partially avoid this by using concurrent reading and writing of input and output. In SESJ, you can do this using the org.idoox.wasp.types.MessageAttachment class. This class is supported directly by SESJ.
This demo is a simple service which receives and sends a large amount of data and compresses/decompresses it using a zip algorithm. For this purpose a new thread is created and connected to PipedInputStream and PipedOutputStream. While concurrent threads manage the data processing, the main service thread exits from the service method and returns control to SESJ.
There are three service endpoints created, they are using different attachment encapsulation. The "demo/advanced/AttachmentService" endpoint uses the default attachment encapsulation (MIME or DIME) chosen during SESJ installation. The "demo/advanced/MIMEService" and "demo/advanced/DIMEService" endpoints use explicitly chosen MIME/DIME encapsulation.
To start, the client creates a chunk of data approx. 10MB in size and then sends it to the server where is it compressed. When data is returned, it is then decompressed in the same manner. The results are saved in the following files:
demoDataDefault.pack demoDataMIME.pack demoDataDIME.pack - compressed data sent to server demoDataDefault.unpack demoDataMIME.unpack demoDataDIME.unpack - decompressed data received from server
![]() | Note |
---|---|
This demo might not work correctly on some application servers due to their inability to communicate using chunked HTTP messages (sending the message by parts). If you want to run this demo over JMS transport, increase the memory limits for JVM on both the server and the client side to at least 256MB (-Xmx256m) |
In addition to the files described in Files and Directories, this demo contains:
File or directory | Description |
---|---|
src/demo/advanced/attachments/server/ | Server source code |
src/demo/advanced/attachments/client/ | Client source code |
You can run the demo using the "run.sh" (for UNIX) or "run.bat" (for Windows) scripts. Running the script without arguments prints out a help screen.
The demo can be run in two different ways:
To use Runtime Publishing, follow these steps:
Be sure that you have not started SESJ.
Compile the server classes.
Windows: run.bat make_server Linux: ./run.sh make_server
Run AttachmentsServer (it starts SESJ and publishes the AttachmentsService class).
Windows: run.bat run_server Linux: ./run.sh run_server (use a new terminal)
You can look at service WSDL descriptions on 'http://localhost:6060/demo/advanced/AttachmentsService/wsdl', 'http://localhost:6060/demo/advanced/MIMEService/wsdl' and 'http://localhost:6060/demo/advanced/DIMEService/wsdl' from your browser.
Make the client classes.
Windows: run.bat make_client Linux: ./run.sh make_client
Run AttachmentsClient (it calls AttachmentsService).
Windows: run.bat run_client Linux: ./run.sh run_client
Be sure that you've started SESJ.
Compile AttachmentsService.
Windows: run.bat make_service Linux: ./run.sh make_service
Deploy AttachmentsService on the SESJ.
Windows: run.bat deploy_service Linux: ./run.sh deploy_service
Make the client classes.
Windows: run.bat make_client Linux: ./run.sh make_client
Run AttachmentsClient (it calls AttachmentsService).
Windows: run.bat run_client Linux: ./run.sh run_client
Undeploy AttachmentsService from the SESJ.
Windows: run.bat undeploy_service Linux: ./run.sh undeploy_service