This demo shows how to use different connections (transports) for request and response. This feature is called "transport coupling" and is useful when it is not possible to block the same connection for request and response. A typical use case is asynchronous invocation, when a new service can respond at any time over a period of days. A new connection to the client is created once the response is ready. Note that the same transport can be used (e.g. "http"). In this demo http-http and mailto-http couplings are shown.
In addition to the files described in Files and Directories, this demo contains:
File or directory | Description |
---|---|
src/demo/advanced/async/coupling/server/ | Server source code |
src/demo/advanced/async/coupling/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 message on screen.
The demo can be run in several ways:
Compile the server classes.
Windows: run.bat make_server Linux: ./run.sh make_server
Run server
Windows: run.bat run_server Linux: ./run.sh run_server
Compile the client classes.
Windows: run.bat make_client Linux: ./run.sh make_client
Run client
Windows: run.bat run_client Linux: ./run.sh run_client
Be sure that you've started SESJ.
Compile OrdersMgmtService.
Windows: run.bat make_service Linux: ./run.sh make_service
Deploy OrdersMgtmService 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 the client.
Windows: run.bat run_client Linux: ./run.sh run_client
Received messages should be stored in the server's startup log.
Undeploy OrdersMgmtService from the SESJ.
Windows: run.bat undeploy_service Linux: ./run.sh undeploy_service
This demo shows the offline messaging feature e.g. client sends requests to a non-running server and waits for responses sent back once the server is running.
Compile the client classes.
Windows: run.bat make_client Linux: ./run.sh make_client
Run client
Windows: run.bat run_client SERVICE_URI SMTP_SERVER [USER_EMAIL] Linux: ./run.sh run_client SERVICE_URI SMTP_SERVER [USER_EMAIL]
Examples:
Windows: run.bat run_client "mailto:test@hotmail.com?x-wasp-path= /demo/advanced/async/coupling/OrdersMgmtService" "smtp://my.smtp.com" Linux: ./run.sh run_client "mailto:test@hotmail.com?x-wasp-path= /demo/advanced/async/coupling/OrdersMgmtService" "smtp://my.smtp.com"
Please see Interoperability note below if your SESJ ran into problems with locating the proper service after successfully fetching the message from the pop3 server.
Run server
Windows: run.bat run_server POP3_SERVER USER_PASSWORD USER_EMAIL Linux: ./run.sh run_server POP3_SERVER USER_PASSWORD USER_EMAIL
Examples:
Windows: run.bat run_server pop://test@pop3.hotmail.com myPass test@hotmail.com Linux: ./run.sh run_server pop://test@pop3.hotmail.com myPass test@hotmail.com
Be sure that you've started SESJ.
Compile OrdersMgmtService.
Windows: run.bat make_service Linux: ./run.sh make_service
Deploy OrdersMgtmService 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
Stop the server.
Run the client.
Windows: run.bat run_client SERVICE_URI SMTP_SERVER [USER_EMAIL] Linux: ./run.sh run_client SERVICE_URI SMTP_SERVER [USER_EMAIL]
Examples:
Windows: run.bat run_client "mailto:test@hotmail.com?x-wasp-path= /demo/advanced/async/transport-coupling/OrdersMgmtService" "smtp://my.smtp.com" Linux: ./run.sh run_client "mailto:test@hotmail.com?x-wasp-path= /demo/advanced/async/transport-coupling/OrdersMgmtService" "smtp://my.smtp.com"
Please see Interoperability note below if your SESJ ran into problems with locating the proper service after successfully fetching the message from the pop3 server.
Start the server.
Received messages should be stored in the startup log.
Undeploy OrdersMgmtService from the SESJ.
Windows: run.bat undeploy_service Linux: ./run.sh undeploy_service
If you have a non-SESJ client that doesn't support sending parameters as headers (x-wasp-path) or your POP3 is not indulgent to them, you have to add the service-endpoint for the email address directly, either by using runtime publishing or persistent deployment. These are the steps you must take:
Runtime API
1. OrdersMgmtServer.java set "servicePath" to used mail account (e.g. test@hotmail.com)
Persistent deployment
2. run.bat find label ":make_service" there is call to WaspPackagerTool to create deployment package change its command option "-u /demo/advanced/async/coupling/OrdersMgmtService" to -u "test@hotmail.com"
Ant task
3. build.xml find target "make_service" in subelement <WaspPackager><ServiceName> change attribute path to "test@hotmail.com"
After these changes you can run the demo as usual.
You will need to set up mail transport first if you didn't do it during SESJ installation. You can do it by hand or with the MailSetupTool utility. You need to know the address of your SMTP server and have a POP3 account.
From the SESJ bin directory do the following (substitute you SMTP server wherever you see "smtp.mycompany.com". You should also substiture your POP3 email account wherever you see the "test@pop3.hotmail.com"):
The following command will modify a server config. You don't need to do this for runtime use cases from this demo,since in these cases mailto transport is configured on server side during runtime:
Windows: MailSetupTool --file ..\conf\serverconf.xml --iserver "pop://test@pop3.hotmail.com" --ipassword changeit --ofrom test@hotmail.com --preload Linux: ./MailSetupTool --file ../conf/serverconf.xml --iserver "pop://test@pop3.hotmail.com" \ --ipassword changeit --ofrom test@hotmail.com --preload
The following command will modify the client config. You don't need to perform this step for this demo at all, since mailto transport is configured on client side during runtime:
Windows: MailSetupTool.bat --file ../conf/clientconf.xml --oserver "smtp://smtp.mycompany.com" Linux: ./MailSetupTool.sh --file ../conf/clientconf.xml --oserver "smtp://smtp.mycompany.com"
![]() | Warning |
---|---|
Don't use a mail account for SESJ if you are using it for other mail communication. Your mails will be lost! |