Lesson 3.2: Start a client and insert data into the grid

Complete this lesson to start a non-OSGi client and run a client application.

About this task

The Java™ client application is com.ibm.websphere.samples.xs.proto.client.Client. The Eclipse project, wxs.sample.osgi.protobuf.client, contains the Java client application. The main class file is com.ibm.websphere.samples.xs.proto.client.Client.
This client uses a client override, ObjectGrid descriptor XML file to override the OSGi configuration, so that the client can run in a non-OSGi environment. See the following content of the file with comments and headers removed.
<objectGridConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://ibm.com/ws/objectgrid/config ../objectGrid.xsd"
    xmlns="http://ibm.com/ws/objectgrid/config">

    <objectGrids>
        <objectGrid name="Grid" txTimeout="15">
            <bean id="ObjectGridEventListener" className="" osgiService=""/>
            <backingMap name="Map" readOnly="false"
                lockStrategy="PESSIMISTIC" lockTimeout="5" 
                copyMode="COPY_TO_BYTES" pluginCollectionRef="serializer"/>
                
        </objectGrid>
    </objectGrids>

    <backingMapPluginCollections>
        <backingMapPluginCollection id="serializer">
                 
			<bean id="MapSerializer"			
			className="com.ibm.websphere.samples.xs.serializer.proto.ProtoMapSerializer" 
       osgiService="">
				<property name="keyType" type="java.lang.String" 
				    value="com.ibm.websphere.samples.xs.serializer.proto.DataObjects2$OrderKey" />
		        <property name="valueType" type="java.lang.String" 
		            value="com.ibm.websphere.samples.xs.serializer.proto.DataObjects2$Order" />
			</bean>
		</backingMapPluginCollection>
    </backingMapPluginCollections>
</objectGridConfig>

Procedure

Click Run As > Java Application to run the client application.

Results

When you run the application, the following message is displayed. The message indicates that an order was inserted:
order
com.ibm.websphere.samples.xs.serializer.proto.DataObjects1$Order$Builder@5d165d16(5000000) inserted

Lesson checkpoint

In this lesson, you started the com.ibm.websphere.samples.xs.proto.client.Client application, which produced an order.