Table of Contents

Search

  1. Preface
  2. Introduction to Vibe Data Stream Custom Entity Types
  3. Managing Custom Entity Types
  4. Custom Entities from Maven Archetypes
  5. REST APIs
  6. HTTP Request and Response Parameters
  7. Sample JSON Requests and Responses
  8. Glossary

Developer Guide

Developer Guide

Implementing the VDSSource Interface

Implementing the VDSSource Interface

Implement the
VDSSource
interface to create a custom source service type.
The following sample code shows how to implement the
VDSSource
interface:
package ...; import java.io.IOException; import com.informatica.vds.api.VDSConfiguration; import com.informatica.vds.api.VDSEventList; import com.informatica.vds.api.VDSSource; public class CustomSource implements VDSSource { /* Initialize the VDSSource object. */ @Override public void open(VDSConfiguration vdsconfiguration) throws Exception { /* The internal name of the key. */ String fieldName = "SourceURLFromUI"; /* The default value of the key. */ String defaultValue = "SourceURLDefault"; /* Retrieve the value of the key SourceURLFromUI. */ String SourceURL = vdsconfiguration.optString("SourceURLFromUI", "SourceURLDefault"); /* Similarly, retrieve other keys. */ ... } /* Read the data from the data source. */ @Override public void read(VDSEventList vdsevents) throws Exception { /* Collect data into a byte array called data. */ ... /* Add the generated data to the VDSEventList object. */ vdsevents.addEvent(data, data.length); } @Override public void close() throws IOException { /* Clean up. */ ... } @Override public void setRetryPolicyHandler(IPluginRetryPolicy arg0) { // TODO Auto-generated method stub } }
The following sample code shows how to implement the
VDSSource
interface to shard events:
package ...; import java.io.IOException; import com.informatica.vds.api.VDSConfiguration; import com.informatica.vds.api.VDSEventList; import com.informatica.vds.api.VDSSource; public class CustomSource implements VDSSource { /* Initialize the VDSSource object. */ @Override public void open(VDSConfiguration vdsconfiguration) throws Exception { /* The internal name of the key. */ String fieldName = "SourceURLFromUI"; /* The default value of the key. */ String defaultValue = "SourceURLDefault"; /* Retrieve the value of the key SourceURLFromUI. */ String SourceURL = vdsconfiguration.optString("SourceURLFromUI", "SourceURLDefault"); /* Similarly, retrieve other keys. */ ... } /* Read the data from the data source. */ @Override public void read(VDSEventList arg0) throws Exception { System.out.println("Reading source..."); Thread.sleep(10); String message = (String) queue.poll(); if (message == null) { return; } count++; Map<String, String> map = new HashMap(); if (count % 2 == 0) { map.put("transportTopic", "TwoTopic"); } else if (count % 3 == 0) { map.put("transportTopic", "ThreeTopic"); } else { map.put("transportTopic", "OtherTopic"); } arg0.addEvent(message.getBytes(), message.getBytes().length, map); if (count % 2 == 0) { statValues.put((short)2, ++twos); } if (count % 3 == 0) { statValues.put((short)3, ++threes); } System.out.println("Data " + message.getBytes() + " " + message.getBytes().length); } @Override public void close() throws IOException { /* Clean up. */ ... } @Override public void setRetryPolicyHandler(IPluginRetryPolicy arg0) { // TODO Auto-generated method stub } }

0 COMMENTS

We’d like to hear from you!