Creating a New Custom TIBCO BusinessEvents Channel
You can use the custom channel API to create a custom channel according to your requirement for your project.
The Java API for custom channel (com.tibco.be.custom.channel package) is bundled with TIBCO BusinessEvents. For more information about the classes in the
com.tibco.be.custom.channel package see
Java API Reference.
- Procedure
- Create a XML file and save it with the name drivers.xml.
- In the XML file, define the drivers for the channel in the following format.
<?xml version="1.0" encoding="UTF-8"?> <drivers> <driver> <type>CHANNEL_TYPE</type> <label>CHANNEL_LABEL</label> <class>DRIVER_CLASS </class> <description>CHANNEL_DESCRIPTION</description> <version>CHANNEL_VERSION</version> <properties> <!--Channel Properties --> </properties> <destinations> <!--Destination Properties --> </destinations> <serializers userdefined="true"> <serializer type="SERIALIZER_TYPE" class="SERIALIZER_CLASS"/> <!--Additional Serializers --> </serializers> </driver> </drivers>
Where,
- CHANNEL_TYPE - The channel type that you have defined. This is displayed in the BusinessEvents Studio under the Driver Type field in the New Channel Wizard.
- CHANNEL_LABEL - Display name of the channel.
- DRIVER_CLASS - The URI of the BaseDriver class that you have implemented.
- CHANNEL_DESCRIPTION - Short description of the channel.
- CHANNEL_VERSION - Version number of the channel.
- <!--Channel Properties --> - Define the configuration properties for the channel. Specify the name, type, and default value of the properties. These properties are displayed as channel properties in BusinessEvents Studio.
- <!--Destination Properties --> - Define the configuration properties for the destination of the custom channel. Specify the name, type, and default value of the properties. These properties are displayed as destination properties in BusinessEvents Studio.
- SERIALIZER_TYPE - Type of the serializer for the channel. You can define multiple serializers.
- SERIALIZER_CLASS - Class of the serializer that you have defined. Specify at least one serializer for the channel. The class is listed in the BusinessEvents Studio under the Serializer/Deserializer field while adding destination for the custom channel.
- Create all the required Java class files using the Java API for custom channel. Archive all the Java class files for the custom channel with the
drivers.xml file as a JAR file.
Refer to the Kafka channel example and its source code for the custom channel Java API usage. The Kafka channel example is located at BE_HOME\api\channel-api\examples\StudioProjKafka and the source code is located at BE_HOME\api\channel-api\examples\kafka\src. See the following topics for more understanding on how the custom channel API can be implemented to create the required Java files:
- Custom Channel Lifecycle
- Channel Messages to Event Conversion
- Catalog Function Implementation for Custom Channel
Refer to the Java API Reference for complete details about Java API for custom channel (com.tibco.be.custom.channel package).
- Copy this JAR file at
BE_HOME\lib\ext\tpcl\contrib and restart BusinessEvents Studio.
New custom channel is displayed under the Driver Type in the New Channel Wizard.
Define the drivers.xml file
Create a JAR file
Include the JAR file in BusinessEvents classpath
Sample Kafka Channel Drivers.xml File
The following sample code is of the drivers.xml file for the Kafka channel example:
<?xml version="1.0" encoding="UTF-8"?> <drivers> <driver> <type>Kafka(API Example)</type> <label>Kafka(API Example)</label> <class>com.tibco.be.custom.channel.kafka.KafkaDriver</class> <description>Apache Kafka is an open-source message broker project developed by the Apache Software Foundation written in Scala. The project aims to provide a unified, high-throughput, low-latency platform for handling real-time data feeds.</description> <version>1.0.0.0</version> <properties> <property name="kafka.broker.urls" displayName="Kafka Broker Urls" type="String" default="localhost:9092"/> </properties> <destinations> <property name="group.id" displayName="GroupID" type="String" default="kafka_group"/> <property name="client.id" displayName="ClientID" type="String" default="BEClient"/> <property name="topic" displayName="Topic" type="String" default="ktopic"/> <property name="consumer.threads" displayName="Consumer Threads" type="Integer" default="1"/> <property name="poll.interval" displayName="Poll Interval" type="Integer" default="100"/> <property name="compression.type" displayName="Compression Type" type="String" default="none"/> </destinations> <serializers userdefined="true"> <serializer type="Map" class="com.tibco.be.custom.channel.kafka.serializer.KafkaMapSerializer"/> </serializers> <!-- Define combo-boxes that are referred to in destination properties. --> <configuration> <property> <name>compression.type</name> <parent>destination</parent> <type>combo-box</type> <choices> <choice value="none" displayed="none"/> <choice value="gzip" displayed="gzip"/> <choice value="snappy" displayed="snappy"/> <choice value="lz4" displayed="lz4"/> </choices> </property> </configuration> </driver> </drivers>