title: Using AWS Lambda Java function to read data from Self Managed Kafka Cluster
body: <p>I have successfully implemented
  <a href="https://aws.amazon.com/blogs/compute/using-self-hosted-apache-kafka-as-an-event-source-for-aws-lambda/" rel="nofollow noreferrer">https://aws.amazon.com/blogs/compute/using-self-hosted-apache-kafka-as-an-event-source-for-aws-lambda/</a></p>
  <p>But my issue is I want to write the code in Java instead of NodeJs.
  The payload returned is shown below. How do I extract the value which is Base64 encoded ?</p>
  <p>Thanks,
  Anirban</p>
  <pre><code>{
      &quot;eventSource&quot;: &quot;SelfManagedKafka&quot;,
      &quot;bootstrapServers&quot;: &quot;sp-dev-broker-0.stre.nsawsdev.mycompany.com:9093&quot;,
      &quot;records&quot;: {
          &quot;lambda_test-0&quot;: [
              {
                  &quot;topic&quot;: &quot;lambda_test&quot;,
                  &quot;partition&quot;: 0,
                  &quot;offset&quot;: 0,
                  &quot;timestamp&quot;: 1660073644797,
                  &quot;timestampType&quot;: &quot;CREATE_TIME&quot;,
                  &quot;value&quot;: &quot;eyJOYW1lIjogIkFuaXJiYW4gQmlzd2FzIn0=&quot;,
                  &quot;headers&quot;: []
              }
          ]
      }
  }
  </code></pre>
  <p>My class looks like this and I see the the Lambda getting invoked when I publish data on topic.</p>
  <pre><code>public class App implements RequestHandler&lt;KafkaEvent, String&gt; {
  
      private static final Logger log = LoggerFactory.getLogger(App.class);
  
      @Override
      public String handleRequest(KafkaEvent event, Context context) {
  
          log.info(&quot;Lambda function is invoked:&quot; +event.getRecords().values().toString());
          return null;
  
  
      }
  }
  </code></pre>
  <p>AWS Lambda Cloudatch log shows this</p>
  <pre><code>Lambda function is invoked:[[KafkaEvent.KafkaEventRecord(topic=lambda_test, partition=0, offset=0, timestamp=1660073644797, timestampType=CREATE_TIME, key=null, value=eyJOYW1lIjogIkFuaXJiYW4gQmlzd2FzIn0=)]]
  </code></pre>