16.20 - Java Sample Application - Teradata Ecosystem Manager

Teradata® Ecosystem Manager API Reference

prodname
Teradata Ecosystem Manager
vrm_release
16.20
created_date
December 2020
category
Programming Reference
featnum
B035-3204-107K

The following is a sample of the Java API. The complete Java API documentation is part of the software development kit (SDK) and is located at …/teradata/client/tmsm/sdk/docs/javadoc.

package com.teradata.commons.sample;
import javax.xml.bind.JAXBException;
import org.xml.sax.SAXException;
import com.teradata.commons.messaging.ResilientSender;
import com.teradata.commons.messaging.XSDNamespace;
import com.teradata.commons.messaging.XSDSchema;
import com.teradata.commons.messaging.schemas.message.tmsm.TMSMUnitOfWork;
public class TestSender {
	public static void main(String[] args) {
		// define the XSD schema namespace of the message and the payload
		XSDNamespace tmsmNamespace = new XSDNamespace(
				"http://schemas.teradata.com/tmsm/v2009");
		// define the XSD schema file for the message
		XSDSchema messageSchema = new XSDSchema("resilientmessage.xsd");
		// define the XSD schema file specifying the payload
		XSDSchema tmsmSchema = new XSDSchema("tmsm.xsd");
		// create a resilient sender specifying the message type name
		TMSMUnitOfWork uow = ResilientSender.createUnitOfWork("test",
				"test class", "localhost", null, null);
		// create a resilient sender specifying the message type name
		ResilientSender rsender = new ResilientSender("TMSM");
		// set the namespace and schema files for the message and payload
		rsender.setMessageNamespace(tmsmNamespace);
		rsender.setMessageSchema(messageSchema);
		rsender.setPayloadNamespace(tmsmNamespace);
		rsender.setPayloadSchema(tmsmSchema);
		try {
			// initialize the resilient sender by reading the configuration file
			rsender.initialize("apiconfig.xml");
			// send a start event
			rsender.sendStartEvent(null, null, "test start message", "test",
					"test res", "test", uow, null, null, null, null,
					"TestSender.java", null, "test job", "test step",
                               null);
			// send a step event
			rsender.sendStepEvent(null, null, "test step message", "test",
					"test res", "test", uow, null, null, null, null,
					"TestSender.java", null, null, "test step", (List)
					null, null, (List) null, (List) null, (List) null,
					null);
			// send an end event
			rsender.sendEndEvent(null, null, "test end message", "test",
					"test res", "test", uow, null, null, null, null,
					"TestSender.java", null, "test job", "test step",
					null, null, null, null, null, null);
		} catch (JAXBException e) {
			e.printStackTrace();
		} catch (SAXException e) {
			e.printStackTrace();
		} finally {
			 // cleanup code
			if (rsender != null){
				rsender.cleanup();
			}
		}
	}
}