Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 5 Using the Example Code : ASRequestReplyServer and ASRequestReplyClient

ASRequestReplyServer and ASRequestReplyClient
These examples show how two spaces can work together as a reply server and reply client.
Overview
The ASRequestReplyClient and ASRequestReplyServer examples work together to demonstrate how two spaces can be used by applications to communicate in a request and reply manner. The two spaces are named request and reply.
In this example, ASRequestReplyServer defines the spaces and ASRequestReplyClient joins the already defined spaces. This is different from most of the other examples where the space is always defined.
Another interesting thing to note about how ASRequestReplyServer is implemented is that it uses the Admin interface to define the 'request' and 'reply' spaces. Most of the other examples define a space using the SpaceDef interface.
ASRequestReplyClient loops, putting messages into the 'request' space. When it is notified of messages in the 'reply' space, ASRequestReplyClient takes the replies from the 'reply' space.
For every 100 replies received, ASRequestReplyClient prints a message indicating the number of requests that have been sent and the number of replies received.
ASRequestReplyServer periodically polls for messages on the 'request' space. When a message is put into the 'request' space, ASRequestReplyServer takes it from the space. The name of the ASRequestReplyServer is added to the original message as the responder to the request. This slightly modified message is then put into the 'reply' space. For every 100 requests received, ASRequestReplyServer prints a message indicating the number of requests it has processed.
The request space has a definition consisting of two fields:
A mandatory key field called id of type 'integer'
A mandatory key field called requester of type 'string'
The reply space has a definition consisting of three fields:
A mandatory key field called id of type 'integer'
A mandatory key field called requester of type 'string'
A mandatory field called responder of type 'string'
ASRequestReplyServer is a seeder for the request space and a leech for the reply space.
ASRequestReplyClient is a leech for the request space and a seeder for the reply space.
Starting ASRequestReplyServer
You should start ASRequestReplyServer first. The following examples indicate how to invoke ASRequestReplyServer for each of the APIs.
Java Invocation
java ASRequestReplyServer -metaspace examplems -member_name rrserver
C Invocation
ASRequestReplyServer -metaspace examplems -member_name rrserver
.NET Invocation
ASRequestReplyServer -metaspace examplems -member_name rrserver
You should start ASRequestReplyClient second. The following examples indicate how to invoke ASRequestReplyClient for each of the APIs.
Starting ASRequestReplyClient
The following examples indicate how to invoke ASRequestReplyClient for each of the APIs.
Java Invocation
java ASRequestReplyClient -metaspace examplems -member_name rrclient
C Invocation
ASRequestReplyClient -metaspace examplems -member_name rrclient
.NET Invocation
ASRequestReplyClient -metaspace examplems -member_name rrclient
Starting ASRequestReplyServer and ASRequestReplyClient with Security
The following example shows the command line options that you can use when starting ASRequestReplyServer to have it join the security domain exdomain:
-discovery tcp://127.0.0.1:50000 -member_name rrserver -security_token exdomain_token.txt
To invoke ASRequestReplyClient to work in conjunction with the ASRequestReplyServer example when it has been started with security, use the following command line options:
-discovery tcp://127.0.0.1:50000 -member_name rrclient -security_token exdomain_token.txt
These command line options start ASRequestReplyServer and ASRequestReplyClient using the default metaspace name ms and allow them to connect to a security domain controller that has been starting using the example security policy file example_policy.txt.

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved