Using custom client message store property attributes

Client message store properties can have attributes that you define. An attribute is defined by appending a dot after the property name followed by the attribute name. The main use of this feature is to be able to use information about your network in your transmission rules.

Limited support is provided for property attributes when using UltraLite as a client message store. UltraLite message stores only support the predefined ias_Network property.

Example (SQL Anywhere only)

Following is a simple example of how to set custom client message store property attributes. In this example, the Object property has two attributes: Shape and Color. The value of the Shape attribute is Round and the value of the Color attribute is Blue.

// C++ example.
mgr->setStringStoreProperty( “Object.Shape”, “Round” );
mgr->setStringStoreProperty( “Object.Color”, “Blue” );
// C# example.
mgr.SetStoreStringProperty( “Object.Shape”, “Round” );
mgr.SetStringStoreProperty( “Object.Color”, “Blue” );
// Java example
mgr.setStringStoreProperty( "Object.Shape", "Round" );
mgr.setStringStoreProperty( "Object.Color", "Blue" );
-- SQL example
BEGIN
    CALL ml_qa_setstoreproperty( 'Object.Shape', 'Round' );
    CALL ml_qa_setstoreproperty( 'Object.Color', 'Blue' );
    COMMIT;
END

All client message store properties have a Type attribute that initially has no value. The value of the Type attribute must be the name of another property. When setting the Type attribute of a property, the property inherits the attributes of the property being assigned to it. In the following example, the Object property inherits the attributes of the Circle property. Therefore, the value of Object.Shape is Round and the value of Object.Color is Blue.

// C++ example
QAManager qa_manager;
qa_manager->setStoreStringProperty( “Circle.Shape”, “Round” );
qa_manager->setStoreStringProperty( “Circle.Color”, “Blue” );
qa_manager->setStoreStringProperty( “Object.Type”, “Circle” );
// C# example
QAManager qa_manager;
qa_manager.SetStringStoreProperty( “Circle.Shape”, “Round” );
qa_manager.SetStringStoreProperty( “Circle.Color”, “Blue” );
qa_manager.SetStringStoreProperty( “Object.Type”, “Circle” );
// Java example
QAManager qa_manager;
qa_manager.setStringStoreProperty( "Circle.Shape", "Round" );
qa_manager.setStringStoreProperty( "Circle.Color", "Blue" );
qa_manager.setStringStoreProperty( "Object.Type", "Circle" );
-- SQL example
BEGIN
    CALL ml_qa_setstoreproperty( 'Circle.Shape', 'Round' );
    CALL ml_qa_setstoreproperty( 'Circle.Color', 'Blue' );
    CALL ml_qa_setstoreproperty( 'Object.Type', 'Circle');
    COMMIT;
END
Example

The following C# example shows how you can use message store properties to provide information about your network to your transmission rules.

Assume you have a Windows laptop that has the following network connectivity options: LAN, Wireless LAN, and Wireless WAN. Access to the network via LAN is provided by a network card named My LAN Card. Access to the network via Wireless LAN is provided by a network card named My Wireless LAN Card. Access to the network via Wireless WAN is provided by a network card named My Wireless WAN Card.

Assume you want to develop a messaging application that sends all messages to the server when connected using LAN or Wireless LAN and only high priority messages when connected using Wireless WAN. You define high priority messages as those whose priority is greater than or equal to 7.

First, find the names of your network adapters. The names of network adapters are fixed when the card is plugged in and the driver is installed. To find the name of a particular network card, connect to the network through that adapter, and then run qaagent with the -vn option. The QAnywhere Agent displays the network adapter name, as follows:

"Listener thread received message '[netstat] network-adapter-name !...'

Next, define three client message store properties for each of the network types: LAN, WLAN, and WWAN. Each of these properties are assigned a Cost attribute. The Cost attribute is a value between 1 and 3 and represents the cost incurred when using the network. A value of 1 represents the lowest cost.

QAManager qa_manager;
qa_manager.SetStoreProperty( “LAN.Cost”, “1” );
qa_manager.SetStoreProperty( “WLAN.Cost”, “2” );
qa_manager.SetStoreProperty( “WWAN.Cost”, “3” );

Next, define three client message store properties, one for each network card that is used. The property name must match the network card name. Assign the appropriate network classification to each property by assigning the network type to the Type attribute. Each property therefore inherits the attributes of the network types assigned to them.

QAManager qa_manager;
qa_manager.SetStoreProperty( “My LAN Card.Type”, “LAN” );
qa_manager.SetStoreProperty( “My Wireless LAN Card.Type”, “WLAN” );
qa_manager.SetStoreProperty( “My Wireless WAN Card.Type”, “WWAN” );

When network connectivity is established, QAnywhere automatically defines the Adapter attribute of the ias_Network property to one of My LAN Card, My Wireless LAN Card or My Wireless WAN Card, depending on the network in use. Similarly, it automatically sets the Type attribute of the ias_Network property to one of My LAN Card, My Wireless LAN Card, or My Wireless WAN Card so that the ias_Network property inherits the attributes of the network being used.

Finally, create the following transmission rule.

automatic=ias_Network.Cost < 3 or ias_Priority >= 7

For more information about transmission rules, see QAnywhere transmission and delete rules.