Before you can send or receive messages using QAnywhere .NET clients, you must complete the following initialization tasks.
You must make two changes to your Visual Studio .NET project to be able to use it:
In addition, you must initialize the QAnywhere .NET API.
To add a reference to the QAnywhere .NET API in a Visual Studio project
Start Visual Studio and open your project.
In the Solution Explorer window, right-click the References folder and choose Add Reference.
The Add Reference window appears.
On the .NET tab, click Browse to locate iAnywhere.QAnywhere.Client.dll. The default locations are (relative to your SQL Anywhere installation directory):
Select the DLL and click Open.
You can verify that the DLL is added to your project. Open the Add Reference window and then click the .NET tab. iAnywhere.QAnywhere.Client.dll appears in the Selected Components list. Click OK to close the window.
To reference the QAnywhere .NET API classes in your code
Start Visual Studio and open your project.
If you are using C#, add the following line to the list of using directives at the beginning of your file:
using iAnywhere.QAnywhere.Client; |
If you are using Visual Basic, add the following line to the list of imports at the beginning of your file:
Imports iAnywhere.QAnywhere.Client |
This line is not strictly required. However, it allows you to use short forms for the QAnywhere classes. Without it, you can still use the fully qualified class name in your code. For example:
iAnywhere.QAnywhere.Client.QAManager mgr = new iAnywhere.QAnywhere.Client.QAManagerFactory.Instance.CreateQAManager( "qa_manager.props" ); |
instead of
QAManager mgr = QAManagerFactory.Instance.CreateQAManager( "qa_manager.props" ); |
To initialize the QAnywhere .NET API
Include the iAnywhere.QAnywhere.Client namespace, as described in the previous procedure.
using iAnywhere.QAnywhere.Client; |
Create a QAManager object.
For example, to create a default QAManager object, invoke CreateQAManager with null as its parameter:
QAManager mgr; mgr = QAManagerFactory.Instance.CreateQAManager( null ); |
For maximum concurrency benefits, multi-threaded applications should create a QAManager for each thread. See Multi-threading considerations.
For more information about QAManagerFactory, see QAManagerFactory class.
You can alternatively create a QAManager object that is customized using a properties file. The properties file is specified in the CreateQAManager method:
mgr = QAManagerFactory.Instance.CreateQAManager( "qa_mgr.props" ); |
where qa_mgr.props is the name of the properties file that resides on the remote device.
Initialize the QAManager object. For example:
mgr.Open( AcknowledgementMode.EXPLICIT_ACKNOWLEDGEMENT); |
The argument to the open method is an acknowledgement mode, which indicates how messages are to be acknowledged. It must be one of IMPLICIT_ACKNOWLEDGEMENT or EXPLICIT_ACKNOWLEDGEMENT. With implicit acknowledgement, messages are acknowledged as soon as they are received by the client. With explicit acknowledgement, you must call the Acknowledge method on the QAManager to acknowledge the message.
For more information about acknowledgement modes, see AcknowledgementMode enumeration.
You are now ready to send messages.
Instead of creating a QAManager, you can create a QATransactionalManager. See Implementing transactional messaging for .NET clients.
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |