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 project to be able to use it:
Add a reference to the QAnywhere .NET DLL. Adding a reference tells Visual Studio .NET which DLL to include to find the code for the QAnywhere .NET API.
Add a line to your source code to reference the QAnywhere .NET API classes. To use the QAnywhere .NET API, you must add a line to your source code to reference the data provider. You must add a different line for C# than for Visual Basic .NET.
In addition, you must initialize the QAnywhere .NET API.
Start Visual Studio and open your project.
In the Solution Explorer window, right-click the References folder and choose Add Reference.
On the .NET tab, click Browse to locate iAnywhere.QAnywhere.Client.dll. The default locations are:
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.
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" ); |
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 when 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.
Discuss this page in DocCommentXchange. Send feedback about this page using email. |
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |