Open topic with navigation

TIBCO BusinessEvents® Enterprise Edition 6.3.1

# 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 a 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
Define the drivers.xml file
1. Create an XML file and save it with the name drivers.xml.
2. 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 the 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 a destination for the custom channel.
Create a JAR file
3. Create all the required Java class files using the Java API for a 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 at BE_HOME\api\channel-api\examples\StudioProjKafka and the source code is 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 the Java API for a custom channel (com.tibco.be.custom.channel package).

Include the JAR file in BusinessEvents classpath
4. Copy this JAR file at BE_HOME\lib\ext\tpcl\contrib and restart BusinessEvents Studio.
   A new custom channel is displayed under the Driver Type in the New Channel Wizard.

## 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>

## Sample Kafka Channel BusinessEvents Studio UI

The following screen shows the fields of the Kafka channel using a custom API in BusinessEvents Studio, according to the drivers.xml file.

Figure 56: Kafka Channel BusinessEvents Studio UI

Did you find this helpful?

YesNo
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO BusinessEvents® Enterprise Edition

Copyright © 2004-2024. Cloud Software Group, Inc. All Rights Reserved.