This tutorial walks you through some common QAnywhere-specific tasks using the plug-in and shows how you can monitor the status of messages in an application.
For more information about QAnywhere plug-in for Sybase Central, refer to the online documentation: SQL Anywhere 10 Help | QAnywhere Help.
SQL Anywhere 10.0
You can run this sample under Windows only.
Shut down any SQL Anywhere databases that are running on your computer.
You will begin by performing some simple administration tasks, using the plug-in to create two new message stores and two agent command files.
Start Sybase Central by choosing Start | Programs | SQL Anywhere 10 | Sybase Central.
Double-click the QAnywhere plug-in on the right pane to open a group of QAnywhere tasks on the left pane.
Click Create a client message store in the Client Store Tasks section. This wizard walks you through the process of creating a client message store.
Select Create a new message store and click Next.
Type demo1 for the Client Message Store ID, and then click Browse.
Browse to the folder %SQLANYSAMP10%\QAnywhere\Client in the directory where you installed SQL Anywhere samples, and name the message store demo1.db. Click Save to dismiss the Browse dialog.
Click Finish. A new database is created and initialized for use as a client message store. Click OK when the message store is created successfully.
Repeat Step 2 to create a second message store called demo2.
Create an agent file to launch the QAnywhere agent connecting to this message store.
Press the Back button until you can see the Agent Tasks.
Select Create an Agent configuration file.
Create a file named demo1.qaa in the %SQLANYSAMP10%\QAnywhere\Client folder in the directory where you installed SQL Anywhere samples.
Enter demo1 for the Client message store ID.
On the Message Store tab, click Browse beside the Database file field, and navigate to the demo1.db file you created in the previous step.
Enter demo1 for the Database name and for the Server name.
Click Test Connection to verify the connection and then click OK. Click OK again to dismiss the properties dialog.
Launch an agent by double-clicking Agent Files in the right pane, then right-clicking the demo1.qaa agent command file, and then choosing Start Agent from the popup menu.
A QAnywhere agent starts running, and connects to the client message store you created.
Repeat Step 4 to create a second agent file called demo2.
Run two applications that connect to these message stores and that will exchange messages. The first step in this process is to start MobiLink, which acts as a messaging server.
Start MobiLink with messaging enabled by choosing Start | Programs | SQL Anywhere 10 | MobiLink | MobiLink with Messaging Sample.
Start a client application and configure it to use one of the message stores you created.
Start the first client application by choosing Start | Programs | SQL Anywhere 10 | QAnywhere | TestMessage for Client1 Sample.
On the Tools menu, click Disconnect.
On the Tools menu, click Options.
In the Message store connection string field, replace all occurrences of qaclient1 with demo1.
Click OK, and then in the Tools menu, click Connect.
This TestMessage application is now connected to the first message store you created (demo1) and is listening on a queue called testmessage.
Start a second client application and configure it to use the second message store you created.
Start the second client application by choosing Start | Programs | SQL Anywhere 10 | QAnywhere | TestMessage for Client2 Sample.
On the Tools menu, click Disconnect.
On the Tools menu, click Options.
In the Message store connection string field, replace all occurrences of qaclient2 with demo1.
Click OK, and then in the Tools menu click Connect.
This TestMessage application is now connected to the second message store you created (demo2) and listening on a queue called testmessage.
Send a message from the first client to the second.
In the TestMessage - demo1 application, choose New from the Message menu.
For the Destination ID, type demo2 and put anything you like for the Subject, Priority and Message.
Click Send. The message is first stored locally in the demo1 message store, then is synchronized to MobiLink, and then is sent to the demo2 message store. The TestMessage - demo2 application receives notification of the incoming message and displays a dialog saying "Message received". Click OK to dismiss the message box. The message appears in TestMessage - demo2.
Use the QAnywhere plug-in to examine the status of messages and message store properties.
Select Work with client message stores in the Other Tasks section.
Select demo1 in the Connected Stores section.
You can now browse all messages in this client message store, filtering by the source, destination, queue, or other conditions. You should see the message you sent from demo1 to demo2.
Double-click the message to drill down and see all of the message properties, content and message history. Click OK to close this dialog.
Click Change properties of this message store in the Client Store Tasks section. Click the Properties tab to see a list of properties (either user-defined or system) for this client store. Select Show system properties and click Apply to see the system properties, including items such as IP address and network cards being used. These properties are all synchronized up to the server and can be leveraged by server-side transmission rules.
Click OK to close the Properties dialog.
Similarly, you can use the QAnywhere plug-in to examine the status of messages and message store properties for a server message store.
Select Work with client message stores from the Other Tasks section.
The Connect dialog appears. Enter ml_server for the User ID and sql for the Password. For the ODBC Data Source name type QAnywhere 10 Demo and click OK.
You can now browse all messages in this server message store, filtering by the source, destination, queue, or other conditions. Double-click on any message to drill down and see all of the message properties, content, and message history.
Create a transmission rule to control when messages are transmitted.
Select Work with Agent files in the Other Tasks section.
Right-click the agent file demo1.qaa and choose Properties from the popup menu.
In the Policy section, select Custom and click New Rules.
Give the rules file the name demo1.qar and click Save.
Click the New button to open the Rule Editor.
Create a rule specifying that messages that will be transmitted when the priority is greater than 7. This editor assists you by presenting various message variables, status constants and schedules, which can be used in your rules. Click Message Variables and select ias_Priority. Type >= 7 in the condition field so that your rules look like ias_Priority >= 7, and then click OK.
Click OK twice more to return to the main Sybase Central window.
Restart the agent and use this transmission rule file. In the QAnywhere Agent window for demo1, click Shut down.
Return to Sybase Central and start the agent by right-clicking the agent command file (demo1.qaa) and selecting Start Agent from the popup menu. Note that the QAnywhere Agent window indicates that the agent is now using the transmission rule file you created.
Return to the TestMessage1 - demo1 application connected to the demo1 message store, send a message to demo2 by choosing New from the Message menu.
For the Destination ID, type demo2 and enter low message for the Subject and set the Priority to Low. Click Send.
Repeat this process to send another message to demo2, but this time use the Subject high message and set the Priority to High.
The TestMessage - demo2 application connected to the demo2 message store should receive the second message that was sent, but not the first, because the transmission rules we created for demo1 indicated that only messages with priority greater or equal than 7 would be transmitted.
Right-click on the message you received and select Delete from the popup menu. This acknowledges that the message has been received and notifies the sending application.
Return to Sybase Central to view the status of sent and unsent messages in the demo1 message store.
Click demo1 in the Connected Stores section.
You can now browse all messages in this client message store, filtering by the source, destination, queue, or other conditions. You should see both of the messages you had just sent from demo1 to demo2. Note the status is different for these messages since one has been delivered to demo2 and one is still pending.
You may need to press F5 to refresh your display. Once a message has reached its final state (in this case it has been successfully delivered and acknowledged), then this message can be safely deleted. You can specify deletion rules that control when this deletion will occur. The default is to delete messages one minute after they have reached a final state, so if you wait about one minute and then press F5 to refresh your display, you'll see the message with a status of "delivered" and it will automatically be deleted from this message store.
This concludes the tutorial. Shut down all the applications that were started.
Open a Command Prompt and navigate to the directory where you installed SQL Anywhere.
Change to the %SQLANYSAMP10%\QAnywhere\Client directory.
Erase the tutorial files by executing the following commands: