Examples

IBMStreams com.ibm.streamsx.messaging Toolkit > com.ibm.streamsx.messaging 5.4.3 > com.ibm.streamsx.messaging.xms > XMSSink > Examples

These examples demonstrate how to use the XMSSink operator.

This example demonstrates the use of multiple XMSSink operators with different parameter combinations and an optional error output port.

composite Main{
graph
stream <int32 id, rstring fname, rstring lname>
MyPersonNamesStream=Beacon()
{
	param
	iterations:10u;
}
//XMSSink Operator with connections.xml 
//defaulted to ./etc/connections.xml
() as MySink1=XMSSink(MyPersonNamesStream)
{
	param
		connection: "wbe";
		access: "OutTrading";
}

//XMSSink Operator with the fully qualified 
//name of connections.xml
() as MySink2=XMSSink(MyPersonNamesStream)
{
	param
		connectionDocument:"/home/streamsuser/connections/XMSconnections.xml";
		connection: "wbe";
		access: "OutTrading";
}

//XMSSink Operator with optional 
//output error port specified
stream <tuple<int32 id, rstring fname, 
rstring lname>inTuple, rstring errorMessage>
MySink3 = XMSSink(MyPersonNamesStream)
{
	param
		connection: "wbe";
		access: "OutTrading";
}
//XMSSink Operator with reconnectionPolicy 
//specified as NoRetry
() as  MySink4 = XMSSink( MyPersonNamesStream ) 
{
	param
		connection: "wbe";
		access: "OutTrading";
		reconnectionPolicy: NoRetry;
}

//XMSSink Operator with optional period 
//and reconnectionPolicy specified
() as MySink5 = XMSSink( MyPersonNamesStream )
{
	param
		connection: "wbe";
		access: "OutTrading";
		reconnectionPolicy: InfiniteRetry;
		period: 1.20;
}
//XMSSink Operator with reconnectionPolicy 
//specified as BoundedRetry
() as MySink6 = XMSSink( MyPersonNamesStream )
{
	param
		connection: "wbe";
		access: "OutTrading";
		reconnectionPolicy: BoundedRetry;
		reconnectionBound: 2u;
		period: 1.20;
}
}

The following is a sample connections.xml file:

<st:connections xmlns:st="http://www.ibm.com/xmlns/prod/streams/adapters"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <connection_specifications>
    <connection_specification name="wbe">
      <XMS initial_context="file:///opt/InitialContext/" 
        connection_factory="TestConFac"  />
	</connection_specification>
  </connection_specifications>

  <access_specifications>
    <access_specification name="OutTrading">
      <destination identifier="TestDestination" 
      delivery_mode="persistent" message_class="map" />
      <uses_connection connection="wbe"/>
      <native_schema>
        <attribute name="id" type="Int"/>
        <attribute name="fname" type="String"/>
        <attribute name="lname" type="String"/>
      </native_schema>
	</access_specification>
  </access_specifications>
</st:connections>