Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » QAnywhere » Writing QAnywhere Client Applications » Initializing a QAnywhere API

Initializing a QAnywhere API Next Page

Setting up .NET applications

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 .NET project
  1. Start Visual Studio .NET and open your project.

  2. In the Solution Explorer window, right-click the References folder and choose Add Reference from the popup menu.

    The Add Reference dialog appears.

  3. 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.

  4. You can verify that the DLL is added to your project. Open the Add Reference dialog and then click the .NET tab. iAnywhere.QAnywhere.Client.dll appears in the Selected Components list. Click OK to close the dialog.

Referencing the data provider classes in your source code
To reference the QAnywhere .NET API classes in your code
  1. Start Visual Studio .NET and open your project.

  2. 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;
  3. If you are using Visual Basic .NET, 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:

    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
  1. Include the iAnywhere.QAnywhere.Client namespace, as described in the previous procedure.

    using iAnywhere.QAnywhere.Client;
  2. 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-threaded QAManager.

    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.

  3. Initialize the QAManager object. For example:


    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.

See also