%3CLINGO-SUB%20id%3D%22lingo-sub-1500679%22%20slang%3D%22en-US%22%3EHDInsight%20Managed%20Kafka%20with%20Confluent%20Kafka%20Schema%20Registry%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1500679%22%20slang%3D%22en-US%22%3E%3CP%3EKafka%20Schema%20Registry%20provides%20serializers%20that%20plug%20into%20Kafka%20clients%20that%20handle%20message%20schema%20storage%20and%20retrieval%20for%20Kafka%20messages%20that%20are%20sent%20in%20the%20Avro%20format.%20Its%20used%20to%20be%20a%20OSS%20project%20by%20Confluent%20%2C%20but%20is%20now%20under%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fwww.confluent.io%2Fblog%2Flicense-changes-confluent-platform%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EConfluent%20community%20license%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E.%20The%20Schema%20Registry%20additionally%20serves%20the%20below%20purposes%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EStore%20and%20retrieve%20schemas%20for%20producers%20and%20consumers%3C%2FLI%3E%0A%3CLI%3EEnforce%20backward%2Fforward%20%2Ffull%20compatibility%20on%20Topics%3C%2FLI%3E%0A%3CLI%3EDecrease%20the%20size%20of%20the%20payload%20sent%20to%20Kafka%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EIn%20an%20HDInsight%20Managed%20Kafka%20cluster%20the%20Schema%20Registry%20is%20typically%20deployed%20on%20an%20Edge%20node%20to%20allow%20compute%20separation%20from%20Head%20Nodes.%3C%2FP%3E%0A%3CP%3EBelow%20is%20a%20representative%20architecture%20of%20how%20the%20Schema%20Registry%20is%20deployed%20on%20an%20HDInsight%20cluster.%20Note%20that%20Schema%20Registry%20natively%20exposes%20a%20REST%20API%20for%20operations%20on%20it.%20Producers%20and%20consumers%20can%20interact%20with%20the%20Schema%20Registry%20from%20within%20the%20VNet%20or%20using%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fhdinsight%2Fkafka%2Frest-proxy%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EKafka%20REST%20Proxy%3C%2FA%3E.%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1298163344%22%20id%3D%22toc-hId--1298163344%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Pic1.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F207632iE43FC215ACCBC108%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Pic1.png%22%20alt%3D%22Pic1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-1189349489%22%20id%3D%22toc-hId-1189349489%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId--618104974%22%20id%3D%22toc-hId--618104974%22%3E%3CBR%20%2F%3E%3CBR%20%2F%3EDeploy%20a%20HDInsight%20Managed%20Kafka%20with%20Confluent%20Schema%20Registry%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FH2%3E%0A%3CP%3EIn%20this%20section%20we%20would%20deploy%20an%20HDInsight%20Managed%20Kafka%20cluster%20with%20an%20Edge%20Node%20inside%20a%20Virtual%20Network%20and%20then%20install%20the%20Confluent%20Schema%20Registry%20on%20the%20Edge%20Node.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EClick%20on%20the%20Deploy%20to%20Azure%20Link%20to%20start%20the%20deployment%20process%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%20color%3D%22%23993300%22%3E%3CU%3E%3CSTRONG%3E%3CA%20title%3D%22Deploy%20to%20Azure%22%20href%3D%22https%3A%2F%2Fportal.azure.com%2F%23create%2FMicrosoft.Template%2Furi%2Fhttps%253A%252F%252Fraw.githubusercontent.com%252Farnabganguly%252FKafkaschemaregistry%252Fmaster%252Fazuredeploy.json%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDeploy%20to%3C%2FA%3E%3C%2FSTRONG%3E%3C%2FU%3E%3CSTRONG%3E%3CA%20title%3D%22Deploy%20to%20Azure%22%20href%3D%22https%3A%2F%2Fportal.azure.com%2F%23create%2FMicrosoft.Template%2Furi%2Fhttps%253A%252F%252Fraw.githubusercontent.com%252Farnabganguly%252FKafkaschemaregistry%252Fmaster%252Fazuredeploy.json%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Azure%3C%2FA%3E%3C%2FSTRONG%3E%3CSTRONG%3E%26nbsp%3B%26nbsp%3B%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorArnabGanguly_2%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CUL%3E%0A%3CLI%3E%3CP%3EOn%20the%20Custom%20deployment%20template%20populate%20the%20fields%20as%20described%20below.%20Leave%20the%20rest%20of%20their%20fields%20at%20their%20default%20entries%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EResource%20Group%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3A%20Choose%20a%20previously%20created%20resource%20group%20from%20the%20dropdown%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ELocation%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3A%20Automatically%20populated%20based%20on%20the%20Resource%20Group%20location%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ECluster%20Name%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3A%20Enter%20a%20cluster%20name(%20or%20one%20is%20created%20by%20default)%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ECluster%20Login%20Name%3C%2FSTRONG%3E%3A%20Create%20a%20administrator%20name%20for%20the%20Kafka%20Cluster(%20example%20%3A%20admin)%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ECluster%20Login%20Password%3C%2FSTRONG%3E%3A%20Create%20a%20administrator%20login%20password%20for%20the%20username%20chosen%20above%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ESSH%20User%20Name%3C%2FSTRONG%3E%3A%20Create%20an%20SSH%20username%20for%20the%20cluster%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ESSH%20Password%3C%2FSTRONG%3E%3A%20Create%20an%20SSH%20password%20for%20the%20username%20chosen%20above%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3ECheck%20he%20box%20titled%20%22%3CEM%3EI%20agree%20to%20the%20terms%20and%20conditions%20stated%20above%3C%2FEM%3E%22%20and%20click%20on%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EPurchase%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Pic2.png%22%20style%3D%22width%3A%20813px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F202455i5785B1A49697F16B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Pic2.png%22%20alt%3D%22Pic2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EWait%20till%20the%20deployment%20completes%20and%20you%20get%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CEM%3EYour%20Deployment%20is%20Complete%3C%2FEM%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Emessage%20and%20then%20click%20on%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EGo%20to%20resource%3C%2FSTRONG%3E.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Pic3.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F202456iA381640DAB4BBF19%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Pic3.png%22%20alt%3D%22Pic3.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSPAN%3EOn%20the%20Resource%20group%20explore%20the%20various%20components%20created%20as%20part%20of%20the%20Deployment%20.%20Click%20on%20the%20HDInsight%20Cluster%20to%20open%20the%20cluster%20page.%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3EOn%20the%20HDInsight%20cluster%20page%20click%20on%20the%20SSH%2BCluster%20login%20blade%20on%20the%20left%20and%20get%20the%20hostname%20of%20the%20edge%20node%20that%20was%20deployed.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Pic5.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F202459i44223C6E4CB33F8D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Pic5.png%22%20alt%3D%22Pic5.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CP%3EUsing%20an%20SSH%20client%20of%20your%20choice%20ssh%20into%20the%20edge%20node%20using%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Esshuser%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eand%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Epassword%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ethat%20you%20set%20in%20the%20custom%20ARM%20script.%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EIn%20the%20next%20section%20we%20would%20configure%20the%20Confluent%20Kafka%20Schema%20Registry%20that%20we%20installed%20on%20the%20edge%20node%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1869407859%22%20id%3D%22toc-hId-1869407859%22%3EConfigure%20the%20Confluent%20Schema%20Registry%3C%2FH2%3E%0A%3CP%3EThe%20confluent%20schema%20registry%20is%20located%20at%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3E%2Fetc%2Fschema-registry%2Fschema-registry.properties%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eand%20the%20mechanisms%20to%20start%20and%20stop%20service%20executables%20are%20located%20at%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3E%2Fusr%2Fbin%2F%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Efolder.%3C%2FP%3E%0A%3CP%3EThe%20Schema%20Register%20needs%20to%20know%20the%20Zookeeper%20service%20to%20be%20able%20to%20interact%20with%20HDInsight%20Kafka%20cluster.%20Follow%20the%20below%20steps%20to%20get%20the%20details%20of%20the%20Zookeeper%20Quorum.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ESet%20up%20password%20variable.%20Replace%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3EPASSWORD%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ewith%20the%20cluster%20login%20password%2C%20then%20enter%20the%20command%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3Eexport%20password%3D'PASSWORD'%20%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3EExtract%20the%20correctly%20cased%20cluster%20name%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3Eexport%20clusterName%3D%24(curl%20-u%20admin%3A%24password%20-sS%20-G%20%22http%3A%2F%2Fheadnodehost%3A8080%2Fapi%2Fv1%2Fclusters%22%20%7C%20jq%20-r%20'.items%5B%5D.Clusters.cluster_name')%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3EExtract%20the%20Kafka%20Zookeeper%20hosts%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3Eexport%20KAFKAZKHOSTS%3D%24(curl%20-sS%20-u%20admin%3A%24password%20-G%20https%3A%2F%2F%24clusterName.azurehdinsight.net%2Fapi%2Fv1%2Fclusters%2F%24clusterName%2Fservices%2FZOOKEEPER%2Fcomponents%2FZOOKEEPER_SERVER%20%7C%20jq%20-r%20'%5B%22%5C(.host_components%5B%5D.HostRoles.host_name)%3A2181%22%5D%20%7C%20join(%22%2C%22)'%20%7C%20cut%20-d'%2C'%20-f1%2C2)%3B%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3EValidate%20the%20content%20of%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3EKAFKAZKHOSTS%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Evariable%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3Eecho%20%20%24KAFKAZKHOSTS%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3EZookeeper%20values%20appear%20in%20the%20below%20format%20.%20Make%20a%20note%20of%20these%20values%20as%20they%20will%20be%20used%20later%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3Ezk1-ag4kaf.q2hwzr1xkxjuvobkaagmjjkhta.gx.internal.cloudapp.net%3A2181%2Czk2-ag4kaf.q2hwzr1xkxjuvobkaagmjjkhta.gx.internal.cloudapp.net%3A2181%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3ETo%20extract%20Kafka%20Broker%20information%20into%20the%20variable%20KAFKABROKERS%20use%20the%20below%20command.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3Eexport%20KAFKABROKERS%3D%24(curl%20-sS%20-u%20admin%3A%24password%20-G%20https%3A%2F%2F%24clusterName.azurehdinsight.net%2Fapi%2Fv1%2Fclusters%2F%24clusterName%2Fservices%2FKAFKA%2Fcomponents%2FKAFKA_BROKER%20%7C%20jq%20-r%20'%5B%22%5C(.host_components%5B%5D.HostRoles.host_name)%3A9092%22%5D%20%7C%20join(%22%2C%22)'%20%7C%20cut%20-d'%2C'%20-f1%2C2)%3B%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ECheck%20to%20see%20if%20the%20Kafka%20Broker%20information%20is%20available%3C%2FP%3E%0A%3CPRE%3E%3CCODE%3Eecho%20%24KAFKABROKERS%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3EKafka%20Broker%20host%20information%20appears%20in%20the%20below%20format%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3Ewn1-kafka.eahjefyeyyeyeyygqj5y1ud.cx.internal.cloudapp.net%3A9092%2Cwn0-kafka.eaeyhdseyy1netdbyklgqj5y1ud.cx.internal.cloudapp.net%3A9092%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3EOpen%20the%20Schema%20Registry%20properties%20files%20in%20edit%20mode%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3Esudo%20vi%20%2Fetc%2Fschema-registry%2Fschema-registry.properties%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3EBy%20default%20the%20file%20would%20contain%20the%20below%20parameters%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3Elisteners%3Dhttp%3A%2F%2F0.0.0.0%3A8081%0Akafkastore.connection.url%3Dzk0-ohkl-h%3A2181%2Czk1-ohkl-h%3A2181%2Czk2-ohkl-h%3A2181%0Akafkastore.topic%3D_schemas%0Adebug%3Dfalse%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3EReplace%20the%20kafastore.connection.url%20variable%20with%20the%20Zookeeper%20string%20that%20you%20noted%20earlier.%20Also%20replace%20the%20debug%20variable%20to%20true%20.%20If%20set%20to%20true%20true%2C%20API%20requests%20that%20fail%20will%20include%20extra%20debugging%20information%2C%20including%20stack%20traces.%20The%20properties%20files%20now%20looks%20like%20this.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3Elisteners%3Dhttp%3A%2F%2F0.0.0.0%3A8081%0Akafkastore.connection.url%3Dzk1-ag4kaf.q2hwzr1xkxjuvobkaagmjjkhta.gx.internal.cloudapp.net%3A2181%2Czk2-ag4kaf.q2hwzr1xkxjuvobkaagmjjkhta.gx.internal.cloudapp.net%3A2181%0Akafkastore.topic%3D_schemas%0Adebug%3Dtrue%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3E%0A%3CP%3ESave%20and%20exit%20the%20properties%20file%20using%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3E%3Awq%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecommand%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%0A%3CP%3EUse%20the%20below%20commands%20to%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EStart%20the%20Schema%20Registry%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eand%20point%20it%20to%20use%20the%20updated%20Schema%20Registry%20properties%20file%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3Ecd%20%2Fbin%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CPRE%3E%3CCODE%3E%24%20sudo%20schema-registry-start%20%2Fetc%2Fschema-registry%2Fschema-registry.properties%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3ESchema%20Registry%20Starts%20and%20starts%20listening%20for%20requests.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3E...%0A...%0A%5B2020-03-22%2013%3A24%3A49%2C089%5D%20INFO%20Adding%20listener%3A%20http%3A%2F%2F0.0.0.0%3A8081%20(io.confluent.rest.Application%3A190)%0A%5B2020-03-22%2013%3A24%3A49%2C154%5D%20INFO%20jetty-9.2.24.v20180105%20(org.eclipse.jetty.server.Server%3A327)%0A%5B2020-03-22%2013%3A24%3A49%2C753%5D%20INFO%20HV000001%3A%20Hibernate%20Validator%205.1.3.Final%20(org.hibernate.validator.internal.util.Version%3A27)%0A%5B2020-03-22%2013%3A24%3A49%2C902%5D%20INFO%20Started%20o.e.j.s.ServletContextHandler%4040844aab%7B%2F%2Cnull%2CAVAILABLE%7D%20(org.eclipse.jetty.server.handler.ContextHandler%3A744)%0A%5B2020-03-22%2013%3A24%3A49%2C914%5D%20INFO%20Started%20NetworkTrafficServerConnector%4033fe57a9%7BHTTP%2F1.1%7D%7B0.0.0.0%3A8081%7D%20(org.eclipse.jetty.server.NetworkTrafficServerConnector%3A266)%0A%5B2020-03-22%2013%3A24%3A49%2C915%5D%20INFO%20Started%20%402780ms%20(org.eclipse.jetty.server.Server%3A379)%0A%5B2020-03-22%2013%3A24%3A49%2C915%5D%20INFO%20Server%20started%2C%20listening%20for%20requests...%20(io.confluent.kafka.schemaregistry.rest.SchemaRegistryMain%3A45)%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3E%0A%3CP%3EWith%20the%20Schema%20Registry%20running%20in%20one%20SSH%20session%20%2C%20launch%20another%20SSH%20window%20and%20try%20out%20some%20basic%20commands%20to%20ensure%20that%20Schema%20Registry%20is%20working%20as%20expected.%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%0A%3CP%3ERegister%20a%20new%20version%20of%20a%20schema%20under%20the%20subject%20%22Kafka-key%22%20and%20note%20the%20output%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3E%24%20curl%20-X%20POST%20-i%20-H%20%22Content-Type%3A%20application%2Fvnd.schemaregistry.v1%2Bjson%22%20%5C%0A%20%20%20%20--data%20'%7B%22schema%22%3A%20%22%7B%5C%22type%5C%22%3A%20%5C%22string%5C%22%7D%22%7D'%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CPRE%3E%3CCODE%3E%20%20%20HTTP%2F1.1%20200%20OK%0ADate%3A%20Sun%2C%2022%20Mar%202020%2016%3A33%3A04%20GMT%0AContent-Type%3A%20application%2Fvnd.schemaregistry.v1%2Bjson%0AContent-Length%3A%209%0AServer%3A%20Jetty(9.2.24.v20180105)%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3ERegister%20a%20new%20version%20of%20a%20schema%20under%20the%20subject%20%22Kafka-value%22%20and%20note%20the%20output%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3Ecurl%20-X%20POST%20-i%20-H%20%22Content-Type%3A%20application%2Fvnd.schemaregistry.v1%2Bjson%22%20%5C%0A%20%20%20%20--data%20'%7B%22schema%22%3A%20%22%7B%5C%22type%5C%22%3A%20%5C%22string%5C%22%7D%22%7D'%20%5C%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CPRE%3E%3CCODE%3EHTTP%2F1.1%20200%20OK%0ADate%3A%20Sun%2C%2022%20Mar%202020%2016%3A34%3A18%20GMT%0AContent-Type%3A%20application%2Fvnd.schemaregistry.v1%2Bjson%0AContent-Length%3A%209%0AServer%3A%20Jetty(9.2.24.v20180105)%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3EList%20all%20subjects%20and%20check%20the%20output%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3Ecurl%20-X%20GET%20-i%20-H%20%22Content-Type%3A%20application%2Fvnd.schemaregistry.v1%2Bjson%22%20%5C%0A%20%20%20%20http%3A%2F%2Flocalhost%3A8081%2Fsubjects%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CPRE%3E%3CCODE%3EHTTP%2F1.1%20200%20OK%0ADate%3A%20Sun%2C%2022%20Mar%202020%2016%3A34%3A39%20GMT%0AContent-Type%3A%20application%2Fvnd.schemaregistry.v1%2Bjson%0AContent-Length%3A%2027%0AServer%3A%20Jetty(9.2.24.v20180105)%0A%0A%5B%22Kafka-value%22%2C%22Kafka-key%22%5D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-61953396%22%20id%3D%22toc-hId-61953396%22%3ESend%20and%20consume%20Avro%20data%20from%20Kafka%20using%20schema%20registry%3C%2FH2%3E%0A%3CUL%3E%0A%3CLI%3ECreate%20a%20fresh%20Kafka%20Topic%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3Eagkafkaschemareg%3C%2FCODE%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3E%2Fusr%2Fhdp%2Fcurrent%2Fkafka-broker%2Fbin%2Fkafka-topics.sh%20--create%20--replication-factor%203%20--partitions%208%20--topic%20agkafkaschemareg%20--zookeeper%20%24KAFKAZKHOSTS%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3E%0A%3CP%3EUse%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EKafka%20Avro%20Console%20Producer%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20create%20a%20schema%20%2C%20assign%20the%20schema%20to%20the%20Topic%20and%20start%20sending%20data%20to%20the%20topic%20in%20Avro%20format.%20Ensure%20that%20the%20Kafka%20Topic%20in%20the%20previous%20step%20is%20successfully%20created%20and%20that%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E%24KAFKABROKERS%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ehas%20a%20value%20in%20it.%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%0A%3CP%3EThe%20schema%20we%20are%20sending%20is%20a%20Key%3A%20Value%20Pair%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3EKey%20%3A%20Int%20%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CPRE%3E%3CCODE%3EValue%0A%7B%0A%20%20%22type%22%3A%20%22record%22%2C%0A%20%20%22name%22%3A%20%22example_schema%22%2C%0A%20%20%22namespace%22%3A%20%22com.example%22%2C%0A%20%20%22fields%22%3A%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22name%22%3A%20%22cust_id%22%2C%0A%20%20%20%20%20%20%22type%22%3A%20%22int%22%2C%0A%20%20%20%20%20%20%22doc%22%3A%20%22Id%20of%20the%20customer%20account%22%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22name%22%3A%20%22year%22%2C%0A%20%20%20%20%20%20%22type%22%3A%20%22int%22%2C%0A%20%20%20%20%20%20%22doc%22%3A%20%22year%20of%20expense%22%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22name%22%3A%20%22expenses%22%2C%0A%20%20%20%20%20%20%22type%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22type%22%3A%20%22array%22%2C%0A%20%20%20%20%20%20%20%20%22items%22%3A%20%22float%22%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%22doc%22%3A%20%22Expenses%20for%20the%20year%22%0A%20%20%20%20%7D%0A%20%20%5D%2C%0A%20%20%22doc%3A%22%3A%20%22A%20basic%20schema%20for%20storing%20messages%22%0A%7D%20%0A%0A%20%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3EUse%20the%20below%20command%20to%20start%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EKafka%20Avro%20Console%20Producer%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3E%2Fusr%2Fbin%2Fkafka-avro-console-producer%20%20%20%20%20--broker-list%20%24KAFKABROKERS%20%20%20%20%20--topic%20agkafkaschemareg%20%20%20%20%20--property%20parse.key%3Dtrue%20--property%20key.schema%3D'%7B%22type%22%20%3A%20%22int%22%2C%20%22name%22%20%3A%20%22id%22%7D'%20%20%20%20%20--property%20value.schema%3D'%7B%20%22type%22%20%3A%20%22record%22%2C%20%22name%22%20%3A%20%22example_schema%22%2C%20%22namespace%22%20%3A%20%22com.example%22%2C%20%22fields%22%20%3A%20%5B%20%7B%20%22name%22%20%3A%20%22cust_id%22%2C%20%22type%22%20%3A%20%22int%22%2C%20%22doc%22%20%3A%20%22Id%20of%20the%20customer%20account%22%20%7D%2C%20%7B%20%22name%22%20%3A%20%22year%22%2C%20%22type%22%20%3A%20%22int%22%2C%20%22doc%22%20%3A%20%22year%20of%20expense%22%20%7D%2C%20%7B%20%22name%22%20%3A%20%22expenses%22%2C%20%22type%22%20%3A%20%7B%22type%22%3A%20%22array%22%2C%20%22items%22%3A%20%22float%22%7D%2C%20%22doc%22%20%3A%20%22Expenses%20for%20the%20year%22%20%7D%20%5D%2C%20%22doc%3A%22%20%3A%20%22A%20basic%20schema%20for%20storing%20messages%22%20%7D'%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3EWhen%20the%20producer%20is%20ready%20to%20accept%20messages%20start%20sending%20the%20messages%20in%20the%20predefined%20Avro%20schema%20format.%20Use%20the%20Tab%20key%20to%20create%20spacing%20between%20the%20Key%20and%20Value.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3E1%20TAB%20%7B%22cust_id%22%3A1313131%2C%20%22year%22%3A2012%2C%20%22expenses%22%3A%5B1313.13%2C%202424.24%5D%7D%0A2%20TAB%20%7B%22cust_id%22%3A3535353%2C%20%22year%22%3A2011%2C%20%22expenses%22%3A%5B761.35%2C%2092.18%2C%2014.41%5D%7D%0A3%20TAB%20%7B%22cust_id%22%3A7979797%2C%20%22year%22%3A2011%2C%20%22expenses%22%3A%5B4489.00%5D%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Pic7.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F202458iFE0D4BE7648C4145%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Pic7.png%22%20alt%3D%22Pic7.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ETry%20entering%20random%20non%20schema%20data%20into%20the%20console%20producer%20to%20see%20how%20the%20producer%20does%20now%20allow%20any%20data%20that%20does%20not%20conform%20to%20predefined%20Avro%20schema.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3E1%20%20%20%20%20%20%20%7B%22cust_id%22%3A1313131%2C%20%22year%22%3A2012%2C%20%22expenses%22%3A%5B1313.13%2C%202424.24%5D%7D%0A2%20%20%20%20%20%20%20%7B%22cust_id%22%3A1313131%2C%22cust_age%22%3A34%20%22year%22%3A2012%2C%20%22expenses%22%3A%5B1313.13%2C%202424.24%2C34.212%5D%7D%0Aorg.apache.kafka.common.errors.SerializationException%3A%20Error%20deserializing%20json%20%7B%22cust_id%22%3A1313131%2C%22cust_age%22%3A34%20%22year%22%3A2012%2C%20%22expenses%22%3A%5B1313.13%2C%202424.24%2C34.212%5D%7D%20to%20Avro%20of%20schema%20%7B%22type%22%3A%22record%22%2C%22name%22%3A%22example_schema%22%2C%22namespace%22%3A%22com.example%22%2C%22fields%22%3A%5B%7B%22name%22%3A%22cust_id%22%2C%22type%22%3A%22int%22%2C%22doc%22%3A%22Id%20of%20the%20customer%20account%22%7D%2C%7B%22name%22%3A%22year%22%2C%22type%22%3A%22int%22%2C%22doc%22%3A%22year%20of%20expense%22%7D%2C%7B%22name%22%3A%22expenses%22%2C%22type%22%3A%7B%22type%22%3A%22array%22%2C%22items%22%3A%22float%22%7D%2C%22doc%22%3A%22Expenses%20for%20the%20year%22%7D%5D%2C%22doc%3A%22%3A%22A%20basic%20schema%20for%20storing%20messages%22%7D%0ACaused%20by%3A%20org.codehaus.jackson.JsonParseException%3A%20Unexpected%20character%20('%22'%20(code%2034))%3A%20was%20expecting%20comma%20to%20separate%20OBJECT%20entries%0A%20at%20%5BSource%3A%20java.io.StringReader%403561c410%3B%20line%3A%201%2C%20column%3A%2035%5D%0A%20%20%20%20%20%20%20%20at%20org.codehaus.jackson.JsonParser._constructError(JsonParser.java%3A1433)%0A%20%20%20%20%20%20%20%20at%20org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java%3A521)%0A%20%20%20%20%20%20%20%20at%20org.codehaus.jackson.impl.JsonParserMinimalBase._reportUnexpectedChar(JsonParserMinimalBase.java%3A442)%0A%20%20%20%20%20%20%20%20at%20org.codehaus.jackson.impl.ReaderBasedParser.nextToken(ReaderBasedParser.java%3A406)%0A%20%20%20%20%20%20%20%20at%20org.apache.avro.io.JsonDecoder.getVaueAsTree(JsonDecoder.java%3A549)%0A%20%20%20%20%20%20%20%20at%20org.apache.avro.io.JsonDecoder.doAction(JsonDecoder.java%3A474)%0A%20%20%20%20%20%20%20%20at%20org.apache.avro.io.parsing.Parser.advance(Parser.java%3A88)%0A%20%20%20%20%20%20%20%20at%20org.apache.avro.io.JsonDecoder.advance(JsonDecoder.java%3A139)%0A%20%20%20%20%20%20%20%20at%20org.apache.avro.io.JsonDecoder.readInt(JsonDecoder.java%3A166)%0A%20%20%20%20%20%20%20%20at%20org.apache.avro.io.ValidatingDecoder.readInt(ValidatingDecoder.java%3A83)%0A%20%20%20%20%20%20%20%20at%20org.apache.avro.generic.GenericDatumReader.readInt(GenericDatumReader.java%3A511)%0A%20%20%20%20%20%20%20%20at%20org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java%3A182)%0A%20%20%20%20%20%20%20%20at%20org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java%3A152)%0A%20%20%20%20%20%20%20%20at%20org.apache.avro.generic.GenericDatumReader.readField(GenericDatumReader.java%3A240)%0A%20%20%20%20%20%20%20%20at%20org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java%3A230)%0A%20%20%20%20%20%20%20%20at%20org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java%3A174)%0A%20%20%20%20%20%20%20%20at%20org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java%3A152)%0A%20%20%20%20%20%20%20%20at%20org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java%3A144)%0A%20%20%20%20%20%20%20%20at%20io.confluent.kafka.formatter.AvroMessageReader.jsonToAvro(AvroMessageReader.java%3A213)%0A%20%20%20%20%20%20%20%20at%20io.confluent.kafka.formatter.AvroMessageReader.readMessage(AvroMessageReader.java%3A200)%0A%20%20%20%20%20%20%20%20at%20kafka.tools.ConsoleProducer%24.main(ConsoleProducer.scala%3A59)%0A%20%20%20%20%20%20%20%20at%20kafka.tools.ConsoleProducer.main(ConsoleProducer.scala)%0A%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3EIn%20a%20different%20screen%20start%20the%20Kafka%20Avro%20Console%20Consumer%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3Esudo%20%2Fusr%2Fbin%2Fkafka-avro-console-consumer%20--bootstrap-server%20%24KAFKABROKERS%20--topic%20agkafkaschemareg%20--from-beginning%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3EYou%20should%20start%20seeing%20the%20below%20output%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%3E%7B%22cust_id%22%3A1313131%2C%22year%22%3A2012%2C%22expenses%22%3A%5B1313.13%2C2424.24%5D%7D%0A%7B%22cust_id%22%3A7979797%2C%22year%22%3A2011%2C%22expenses%22%3A%5B4489.0%5D%7D%0A%7B%22cust_id%22%3A3535353%2C%22year%22%3A2011%2C%22expenses%22%3A%5B761.35%2C92.18%2C14.41%5D%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Pic8.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F202457iA621A4A43D68619C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Pic8.png%22%20alt%3D%22Pic8.png%22%20%2F%3E%3C%2FSPAN%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1500679%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3E%26nbsp%3BKafka%20Schema%20Registry%20provides%20serializers%20that%20plug%20into%20Kafka%20clients%20that%20handle%20message%20schema%20storage%20and%20retrieval%20for%20Kafka%20messages%20.%20In%20this%20lab%20we%20build%20a%20build%20and%20test%20Confluent%20Kafka%20Schema%20Registry%20alongside%20an%20HDInsight%20cluster.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1500679%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EHDInsight%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Kafka Schema Registry provides serializers that plug into Kafka clients that handle message schema storage and retrieval for Kafka messages that are sent in the Avro format. Its used to be a OSS project by Confluent , but is now under the Confluent community license . The Schema Registry additionally serves the below purposes

  • Store and retrieve schemas for producers and consumers
  • Enforce backward/forward /full compatibility on Topics
  • Decrease the size of the payload sent to Kafka

In an HDInsight Managed Kafka cluster the Schema Registry is typically deployed on an Edge node to allow compute separation from Head Nodes.

Below is a representative architecture of how the Schema Registry is deployed on an HDInsight cluster. Note that Schema Registry natively exposes a REST API for operations on it. Producers and consumers can interact with the Schema Registry from within the VNet or using the Kafka REST Proxy.

Pic1.png

 



Deploy a HDInsight Managed Kafka with Confluent Schema Registry

In this section we would deploy an HDInsight Managed Kafka cluster with an Edge Node inside a Virtual Network and then install the Confluent Schema Registry on the Edge Node.

  • Click on the Deploy to Azure Link to start the deployment process

Deploy to Azure  

 
  • On the Custom deployment template populate the fields as described below. Leave the rest of their fields at their default entries

    • Resource Group : Choose a previously created resource group from the dropdown
    • Location : Automatically populated based on the Resource Group location
    • Cluster Name : Enter a cluster name( or one is created by default)
    • Cluster Login Name: Create a administrator name for the Kafka Cluster( example : admin)
    • Cluster Login Password: Create a administrator login password for the username chosen above
    • SSH User Name: Create an SSH username for the cluster
    • SSH Password: Create an SSH password for the username chosen above
  • Check he box titled "I agree to the terms and conditions stated above" and click on Purchase.

Pic2.png

 

  • Wait till the deployment completes and you get the Your Deployment is Complete message and then click on Go to resource.

Pic3.png

  • On the Resource group explore the various components created as part of the Deployment . Click on the HDInsight Cluster to open the cluster page.
  • On the HDInsight cluster page click on the SSH+Cluster login blade on the left and get the hostname of the edge node that was deployed.

Pic5.png

  • Using an SSH client of your choice ssh into the edge node using the sshuser and password that you set in the custom ARM script.

  • In the next section we would configure the Confluent Kafka Schema Registry that we installed on the edge node


    Configure the Confluent Schema Registry

    The confluent schema registry is located at /etc/schema-registry/schema-registry.properties and the mechanisms to start and stop service executables are located at the /usr/bin/ folder.

    The Schema Register needs to know the Zookeeper service to be able to interact with HDInsight Kafka cluster. Follow the below steps to get the details of the Zookeeper Quorum.

    • Set up password variable. Replace PASSWORD with the cluster login password, then enter the command
    export password='PASSWORD' 
    
    • Extract the correctly cased cluster name
    export clusterName=$(curl -u admin:$password -sS -G "http://headnodehost:8080/api/v1/clusters" | jq -r '.items[].Clusters.cluster_name')
    
    • Extract the Kafka Zookeeper hosts
    export KAFKAZKHOSTS=$(curl -sS -u admin:$password -G https://$clusterName.azurehdinsight.net/api/v1/clusters/$clusterName/services/ZOOKEEPER/components/ZOOKEEPER_SERVER | jq -r '["\(.host_components[].HostRoles.host_name):2181"] | join(",")' | cut -d',' -f1,2);
    
    • Validate the content of the KAFKAZKHOSTS variable
    echo  $KAFKAZKHOSTS
    
    • Zookeeper values appear in the below format . Make a note of these values as they will be used later
    zk1-ag4kaf.q2hwzr1xkxjuvobkaagmjjkhta.gx.internal.cloudapp.net:2181,zk2-ag4kaf.q2hwzr1xkxjuvobkaagmjjkhta.gx.internal.cloudapp.net:2181
    
    • To extract Kafka Broker information into the variable KAFKABROKERS use the below command.
    export KAFKABROKERS=$(curl -sS -u admin:$password -G https://$clusterName.azurehdinsight.net/api/v1/clusters/$clusterName/services/KAFKA/components/KAFKA_BROKER | jq -r '["\(.host_components[].HostRoles.host_name):9092"] | join(",")' | cut -d',' -f1,2);
    

    Check to see if the Kafka Broker information is available

    echo $KAFKABROKERS
    
    • Kafka Broker host information appears in the below format
    wn1-kafka.eahjefyeyyeyeyygqj5y1ud.cx.internal.cloudapp.net:9092,wn0-kafka.eaeyhdseyy1netdbyklgqj5y1ud.cx.internal.cloudapp.net:9092
    
    • Open the Schema Registry properties files in edit mode
    sudo vi /etc/schema-registry/schema-registry.properties
    
    • By default the file would contain the below parameters
    listeners=http://0.0.0.0:8081
    kafkastore.connection.url=zk0-ohkl-h:2181,zk1-ohkl-h:2181,zk2-ohkl-h:2181
    kafkastore.topic=_schemas
    debug=false
    
    • Replace the kafastore.connection.url variable with the Zookeeper string that you noted earlier. Also replace the debug variable to true . If set to true true, API requests that fail will include extra debugging information, including stack traces. The properties files now looks like this.
    listeners=http://0.0.0.0:8081
    kafkastore.connection.url=zk1-ag4kaf.q2hwzr1xkxjuvobkaagmjjkhta.gx.internal.cloudapp.net:2181,zk2-ag4kaf.q2hwzr1xkxjuvobkaagmjjkhta.gx.internal.cloudapp.net:2181
    kafkastore.topic=_schemas
    debug=true
    
    • Save and exit the properties file using :wq command

    • Use the below commands to Start the Schema Registry and point it to use the updated Schema Registry properties file

    cd /bin
    
    $ sudo schema-registry-start /etc/schema-registry/schema-registry.properties
    
    • Schema Registry Starts and starts listening for requests.
    ...
    ...
    [2020-03-22 13:24:49,089] INFO Adding listener: http://0.0.0.0:8081 (io.confluent.rest.Application:190)
    [2020-03-22 13:24:49,154] INFO jetty-9.2.24.v20180105 (org.eclipse.jetty.server.Server:327)
    [2020-03-22 13:24:49,753] INFO HV000001: Hibernate Validator 5.1.3.Final (org.hibernate.validator.internal.util.Version:27)
    [2020-03-22 13:24:49,902] INFO Started o.e.j.s.ServletContextHandler@40844aab{/,null,AVAILABLE} (org.eclipse.jetty.server.handler.ContextHandler:744)
    [2020-03-22 13:24:49,914] INFO Started NetworkTrafficServerConnector@33fe57a9{HTTP/1.1}{0.0.0.0:8081} (org.eclipse.jetty.server.NetworkTrafficServerConnector:266)
    [2020-03-22 13:24:49,915] INFO Started @2780ms (org.eclipse.jetty.server.Server:379)
    [2020-03-22 13:24:49,915] INFO Server started, listening for requests... (io.confluent.kafka.schemaregistry.rest.SchemaRegistryMain:45)
    
    • With the Schema Registry running in one SSH session , launch another SSH window and try out some basic commands to ensure that Schema Registry is working as expected.

    • Register a new version of a schema under the subject "Kafka-key" and note the output

    $ curl -X POST -i -H "Content-Type: application/vnd.schemaregistry.v1+json" \
        --data '{"schema": "{\"type\": \"string\"}"}'
    
       HTTP/1.1 200 OK
    Date: Sun, 22 Mar 2020 16:33:04 GMT
    Content-Type: application/vnd.schemaregistry.v1+json
    Content-Length: 9
    Server: Jetty(9.2.24.v20180105)
    
    • Register a new version of a schema under the subject "Kafka-value" and note the output
    curl -X POST -i -H "Content-Type: application/vnd.schemaregistry.v1+json" \
        --data '{"schema": "{\"type\": \"string\"}"}' \
    
    HTTP/1.1 200 OK
    Date: Sun, 22 Mar 2020 16:34:18 GMT
    Content-Type: application/vnd.schemaregistry.v1+json
    Content-Length: 9
    Server: Jetty(9.2.24.v20180105)
    
    • List all subjects and check the output
    curl -X GET -i -H "Content-Type: application/vnd.schemaregistry.v1+json" \
        http://localhost:8081/subjects
    
    HTTP/1.1 200 OK
    Date: Sun, 22 Mar 2020 16:34:39 GMT
    Content-Type: application/vnd.schemaregistry.v1+json
    Content-Length: 27
    Server: Jetty(9.2.24.v20180105)
    
    ["Kafka-value","Kafka-key"]



    Send and consume Avro data from Kafka using schema registry

    • Create a fresh Kafka Topic agkafkaschemareg
    /usr/hdp/current/kafka-broker/bin/kafka-topics.sh --create --replication-factor 3 --partitions 8 --topic agkafkaschemareg --zookeeper $KAFKAZKHOSTS
    
    • Use the Kafka Avro Console Producer to create a schema , assign the schema to the Topic and start sending data to the topic in Avro format. Ensure that the Kafka Topic in the previous step is successfully created and that $KAFKABROKERS has a value in it.

    • The schema we are sending is a Key: Value Pair

    Key : Int 
    
    Value
    {
      "type": "record",
      "name": "example_schema",
      "namespace": "com.example",
      "fields": [
        {
          "name": "cust_id",
          "type": "int",
          "doc": "Id of the customer account"
        },
        {
          "name": "year",
          "type": "int",
          "doc": "year of expense"
        },
        {
          "name": "expenses",
          "type": {
            "type": "array",
            "items": "float"
          },
          "doc": "Expenses for the year"
        }
      ],
      "doc:": "A basic schema for storing messages"
    } 
    
     
    
    • Use the below command to start the Kafka Avro Console Producer
    /usr/bin/kafka-avro-console-producer     --broker-list $KAFKABROKERS     --topic agkafkaschemareg     --property parse.key=true --property key.schema='{"type" : "int", "name" : "id"}'     --property value.schema='{ "type" : "record", "name" : "example_schema", "namespace" : "com.example", "fields" : [ { "name" : "cust_id", "type" : "int", "doc" : "Id of the customer account" }, { "name" : "year", "type" : "int", "doc" : "year of expense" }, { "name" : "expenses", "type" : {"type": "array", "items": "float"}, "doc" : "Expenses for the year" } ], "doc:" : "A basic schema for storing messages" }'
    
    • When the producer is ready to accept messages start sending the messages in the predefined Avro schema format. Use the Tab key to create spacing between the Key and Value.
    1 TAB {"cust_id":1313131, "year":2012, "expenses":[1313.13, 2424.24]}
    2 TAB {"cust_id":3535353, "year":2011, "expenses":[761.35, 92.18, 14.41]}
    3 TAB {"cust_id":7979797, "year":2011, "expenses":[4489.00]}

Pic7.png

 

  • Try entering random non schema data into the console producer to see how the producer does now allow any data that does not conform to predefined Avro schema.
1       {"cust_id":1313131, "year":2012, "expenses":[1313.13, 2424.24]}
2       {"cust_id":1313131,"cust_age":34 "year":2012, "expenses":[1313.13, 2424.24,34.212]}
org.apache.kafka.common.errors.SerializationException: Error deserializing json {"cust_id":1313131,"cust_age":34 "year":2012, "expenses":[1313.13, 2424.24,34.212]} to Avro of schema {"type":"record","name":"example_schema","namespace":"com.example","fields":[{"name":"cust_id","type":"int","doc":"Id of the customer account"},{"name":"year","type":"int","doc":"year of expense"},{"name":"expenses","type":{"type":"array","items":"float"},"doc":"Expenses for the year"}],"doc:":"A basic schema for storing messages"}
Caused by: org.codehaus.jackson.JsonParseException: Unexpected character ('"' (code 34)): was expecting comma to separate OBJECT entries
 at [Source: java.io.StringReader@3561c410; line: 1, column: 35]
        at org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1433)
        at org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:521)
        at org.codehaus.jackson.impl.JsonParserMinimalBase._reportUnexpectedChar(JsonParserMinimalBase.java:442)
        at org.codehaus.jackson.impl.ReaderBasedParser.nextToken(ReaderBasedParser.java:406)
        at org.apache.avro.io.JsonDecoder.getVaueAsTree(JsonDecoder.java:549)
        at org.apache.avro.io.JsonDecoder.doAction(JsonDecoder.java:474)
        at org.apache.avro.io.parsing.Parser.advance(Parser.java:88)
        at org.apache.avro.io.JsonDecoder.advance(JsonDecoder.java:139)
        at org.apache.avro.io.JsonDecoder.readInt(JsonDecoder.java:166)
        at org.apache.avro.io.ValidatingDecoder.readInt(ValidatingDecoder.java:83)
        at org.apache.avro.generic.GenericDatumReader.readInt(GenericDatumReader.java:511)
        at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:182)
        at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:152)
        at org.apache.avro.generic.GenericDatumReader.readField(GenericDatumReader.java:240)
        at org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:230)
        at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:174)
        at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:152)
        at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:144)
        at io.confluent.kafka.formatter.AvroMessageReader.jsonToAvro(AvroMessageReader.java:213)
        at io.confluent.kafka.formatter.AvroMessageReader.readMessage(AvroMessageReader.java:200)
        at kafka.tools.ConsoleProducer$.main(ConsoleProducer.scala:59)
        at kafka.tools.ConsoleProducer.main(ConsoleProducer.scala)

  • In a different screen start the Kafka Avro Console Consumer
sudo /usr/bin/kafka-avro-console-consumer --bootstrap-server $KAFKABROKERS --topic agkafkaschemareg --from-beginning
  • You should start seeing the below output
{"cust_id":1313131,"year":2012,"expenses":[1313.13,2424.24]}
{"cust_id":7979797,"year":2011,"expenses":[4489.0]}
{"cust_id":3535353,"year":2011,"expenses":[761.35,92.18,14.41]}

 

Pic8.png