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

Setting up C++ applications Next Page

Setting up Java applications


Before you can send or receive messages using QAnywhere Java clients, you must complete the following initialization tasks.

To initialize the QAnywhere Java API
  1. Add the location of qaclient.jar to your classpath. By default, it is located in the java subdirectory of your SQL Anywhere installation.

  2. Import the ianywhere.qanywhere.client package.

    import ianywhere.qanywhere.client.*;
  3. Create a QAManager object.

    QAManager mgr;
    mgr = QAManagerFactory.getInstance().createQAManager(null);

    You can also customize a QAManager object by specifying a properties file to the createQAManager method:

    mgr = QAManagerFactory.getInstance().createQAManager("qa_mgr.props.");
    Tip

    For maximum concurrency benefits, multi-threaded applications should create a QAManager for each thread. See Multi-threaded QAManager.

  4. Initialize the QAManager object.

    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 one of the acknowledge methods on the QAManager to acknowledge the message.

    For more information about acknowledgement modes, see Interface AcknowledgementMode.

Instead of creating a QAManager, you can create a QATransactionalManager. See Implementing transactional messaging for Java clients.

You are now ready to send messages.

See also