{"id":15735,"date":"2014-10-13T16:17:32","date_gmt":"2014-10-13T10:47:32","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=15735"},"modified":"2014-10-13T16:17:32","modified_gmt":"2014-10-13T10:47:32","slug":"custom-transport-handler-in-cq5aem","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/custom-transport-handler-in-cq5aem\/","title":{"rendered":"Custom Transport Handler in CQ5\/AEM"},"content":{"rendered":"<p>While integrating ElasticSearch with AEM, I used\u00a0custom replication agent, for indexing data to \u00a0ElasticSearch server, as replication agent manages a queue in case replication is not successful and tries it again(after specified time).<\/p>\n<p>But the problem I faced was that on successful indexing(insertion\/updation), ElasticSearch return &#8220;201 OK&#8221; response but the replication agent considers only &#8220;200&#8221; response code as success and even 201 is considered as &#8220;fail&#8221; . So the replication content was never removed from the queue\u00a0even though data was indexed.<\/p>\n<p>The solution I came up with was to use my own transport handler that handles replication for &#8220;Elastic Server Replication Agent&#8221;. Following are the steps to do it:<\/p>\n<ul>\n<li>Create a <a href=\"https:\/\/github.com\/viveksachdeva\/elasticsearch-cq\/blob\/master\/bundle\/src\/main\/java\/com\/vivek\/CustomTransportHandler.groovy\">class<\/a> that implements\u00a0TransportHandler interface<\/li>\n<\/ul>\n<p>[java]<\/p>\n<p>@Service(TransportHandler.class)<br \/>\n@Component(label = &#8220;My Transport Handler&#8221;, immediate = true, enabled = true)<br \/>\nclass CustomTransportHandler implements TransportHandler {<\/p>\n<p>}<\/p>\n<p>[\/java]<\/p>\n<ul>\n<li>Following 2 methods need to be implemented:<\/li>\n<\/ul>\n<p>[java]<\/p>\n<p>@Override<br \/>\nboolean canHandle(AgentConfig agentConfig) {<br \/>\n\/\/ return true in case\u00a0agentConfig.getTransportURI() matches the one for our own replication agent<br \/>\n}<\/p>\n<p>@Override<br \/>\nReplicationResult deliver(TransportContext transportContext, ReplicationTransaction replicationTransaction) throws ReplicationException {<br \/>\n\/\/ return\u00a0ReplicationResult.OK in case of successful indexing. In this case content is deleted from the queue.<br \/>\n}<\/p>\n<p>[\/java]<\/p>\n<p>This way you can customize and manage your own transport handler and have full control over it.<\/p>\n<p>Hope this helps!!<\/p>\n<p>Vivek Sachdeva<br \/>\n@vivek_sach<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While integrating ElasticSearch with AEM, I used\u00a0custom replication agent, for indexing data to \u00a0ElasticSearch server, as replication agent manages a queue in case replication is not successful and tries it again(after specified time). But the problem I faced was that on successful indexing(insertion\/updation), ElasticSearch return &#8220;201 OK&#8221; response but the replication agent considers only &#8220;200&#8221; [&hellip;]<\/p>\n","protected":false},"author":48,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":33,"footnotes":""},"categories":[1],"tags":[4847,1207,1531],"class_list":["post-15735","post","type-post","status-publish","format-standard","hentry","category-technology","tag-aem","tag-cq5","tag-transport-handler"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"While integrating ElasticSearch with AEM, I used custom replication agent, for indexing data to ElasticSearch server, as replication agent manages a queue in case replication is not successful and tries it again(after specified time). But the problem I faced was that on successful indexing(insertion\/updation), ElasticSearch return &quot;201 OK&quot; response but the replication agent considers only &quot;200&quot;\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Vivek Sachdeva\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.tothenew.com\/blog\/custom-transport-handler-in-cq5aem\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"TO THE NEW BLOG\" \/>\n\t\t<meta property=\"og:type\" content=\"blog\" \/>\n\t\t<meta property=\"og:title\" content=\"Custom Transport Handler in CQ5\/AEM | TO THE NEW Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"While integrating ElasticSearch with AEM, I used custom replication agent, for indexing data to ElasticSearch server, as replication agent manages a queue in case replication is not successful and tries it again(after specified time). But the problem I faced was that on successful indexing(insertion\/updation), ElasticSearch return &quot;201 OK&quot; response but the replication agent considers only &quot;200&quot;\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.tothenew.com\/blog\/custom-transport-handler-in-cq5aem\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@tothenew\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Custom Transport Handler in CQ5\/AEM | TO THE NEW Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"While integrating ElasticSearch with AEM, I used custom replication agent, for indexing data to ElasticSearch server, as replication agent manages a queue in case replication is not successful and tries it again(after specified time). But the problem I faced was that on successful indexing(insertion\/updation), ElasticSearch return &quot;201 OK&quot; response but the replication agent considers only &quot;200&quot;\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/custom-transport-handler-in-cq5aem\\\/#article\",\"name\":\"Custom Transport Handler in CQ5\\\/AEM | TO THE NEW Blog\",\"headline\":\"Custom Transport Handler in CQ5\\\/AEM\",\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/vivek-sachdeva\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"},\"datePublished\":\"2014-10-13T16:17:32+05:30\",\"dateModified\":\"2014-10-13T16:17:32+05:30\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/custom-transport-handler-in-cq5aem\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/custom-transport-handler-in-cq5aem\\\/#webpage\"},\"articleSection\":\"Technology, AEM, CQ5, transport handler\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/custom-transport-handler-in-cq5aem\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"name\":\"Technology\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"position\":2,\"name\":\"Technology\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/custom-transport-handler-in-cq5aem\\\/#listItem\",\"name\":\"Custom Transport Handler in CQ5\\\/AEM\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/custom-transport-handler-in-cq5aem\\\/#listItem\",\"position\":3,\"name\":\"Custom Transport Handler in CQ5\\\/AEM\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"name\":\"Technology\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\",\"name\":\"TO THE NEW Blog\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/vivek-sachdeva\\\/#author\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/vivek-sachdeva\\\/\",\"name\":\"Vivek Sachdeva\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/custom-transport-handler-in-cq5aem\\\/#authorImage\",\"url\":\"https:\\\/\\\/newersworld-sf-static.tothenew.net\\\/prod\\\/profilePicFolder\\\/e4057f7b-4721-48dd-a0f9-df1b70a274c4_vivek.sachdeva@tothenew.com.jpg\",\"width\":96,\"height\":96,\"caption\":\"Vivek Sachdeva\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/custom-transport-handler-in-cq5aem\\\/#webpage\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/custom-transport-handler-in-cq5aem\\\/\",\"name\":\"Custom Transport Handler in CQ5\\\/AEM | TO THE NEW Blog\",\"description\":\"While integrating ElasticSearch with AEM, I used custom replication agent, for indexing data to ElasticSearch server, as replication agent manages a queue in case replication is not successful and tries it again(after specified time). But the problem I faced was that on successful indexing(insertion\\\/updation), ElasticSearch return \\\"201 OK\\\" response but the replication agent considers only \\\"200\\\"\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/custom-transport-handler-in-cq5aem\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/vivek-sachdeva\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/vivek-sachdeva\\\/#author\"},\"datePublished\":\"2014-10-13T16:17:32+05:30\",\"dateModified\":\"2014-10-13T16:17:32+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\",\"name\":\"TO THE NEW Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Custom Transport Handler in CQ5\/AEM | TO THE NEW Blog","description":"While integrating ElasticSearch with AEM, I used custom replication agent, for indexing data to ElasticSearch server, as replication agent manages a queue in case replication is not successful and tries it again(after specified time). But the problem I faced was that on successful indexing(insertion\/updation), ElasticSearch return \"201 OK\" response but the replication agent considers only \"200\"","canonical_url":"https:\/\/www.tothenew.com\/blog\/custom-transport-handler-in-cq5aem\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.tothenew.com\/blog\/custom-transport-handler-in-cq5aem\/#article","name":"Custom Transport Handler in CQ5\/AEM | TO THE NEW Blog","headline":"Custom Transport Handler in CQ5\/AEM","author":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/vivek-sachdeva\/#author"},"publisher":{"@id":"https:\/\/www.tothenew.com\/blog\/#organization"},"datePublished":"2014-10-13T16:17:32+05:30","dateModified":"2014-10-13T16:17:32+05:30","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/www.tothenew.com\/blog\/custom-transport-handler-in-cq5aem\/#webpage"},"isPartOf":{"@id":"https:\/\/www.tothenew.com\/blog\/custom-transport-handler-in-cq5aem\/#webpage"},"articleSection":"Technology, AEM, CQ5, transport handler"},{"@type":"BreadcrumbList","@id":"https:\/\/www.tothenew.com\/blog\/custom-transport-handler-in-cq5aem\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/www.tothenew.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/technology\/#listItem","name":"Technology"}},{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/technology\/#listItem","position":2,"name":"Technology","item":"https:\/\/www.tothenew.com\/blog\/category\/technology\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/custom-transport-handler-in-cq5aem\/#listItem","name":"Custom Transport Handler in CQ5\/AEM"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/custom-transport-handler-in-cq5aem\/#listItem","position":3,"name":"Custom Transport Handler in CQ5\/AEM","previousItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/technology\/#listItem","name":"Technology"}}]},{"@type":"Organization","@id":"https:\/\/www.tothenew.com\/blog\/#organization","name":"TO THE NEW Blog","url":"https:\/\/www.tothenew.com\/blog\/"},{"@type":"Person","@id":"https:\/\/www.tothenew.com\/blog\/author\/vivek-sachdeva\/#author","url":"https:\/\/www.tothenew.com\/blog\/author\/vivek-sachdeva\/","name":"Vivek Sachdeva","image":{"@type":"ImageObject","@id":"https:\/\/www.tothenew.com\/blog\/custom-transport-handler-in-cq5aem\/#authorImage","url":"https:\/\/newersworld-sf-static.tothenew.net\/prod\/profilePicFolder\/e4057f7b-4721-48dd-a0f9-df1b70a274c4_vivek.sachdeva@tothenew.com.jpg","width":96,"height":96,"caption":"Vivek Sachdeva"}},{"@type":"WebPage","@id":"https:\/\/www.tothenew.com\/blog\/custom-transport-handler-in-cq5aem\/#webpage","url":"https:\/\/www.tothenew.com\/blog\/custom-transport-handler-in-cq5aem\/","name":"Custom Transport Handler in CQ5\/AEM | TO THE NEW Blog","description":"While integrating ElasticSearch with AEM, I used custom replication agent, for indexing data to ElasticSearch server, as replication agent manages a queue in case replication is not successful and tries it again(after specified time). But the problem I faced was that on successful indexing(insertion\/updation), ElasticSearch return \"201 OK\" response but the replication agent considers only \"200\"","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.tothenew.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.tothenew.com\/blog\/custom-transport-handler-in-cq5aem\/#breadcrumblist"},"author":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/vivek-sachdeva\/#author"},"creator":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/vivek-sachdeva\/#author"},"datePublished":"2014-10-13T16:17:32+05:30","dateModified":"2014-10-13T16:17:32+05:30"},{"@type":"WebSite","@id":"https:\/\/www.tothenew.com\/blog\/#website","url":"https:\/\/www.tothenew.com\/blog\/","name":"TO THE NEW Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.tothenew.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"TO THE NEW BLOG","og:type":"blog","og:title":"Custom Transport Handler in CQ5\/AEM | TO THE NEW Blog","og:description":"While integrating ElasticSearch with AEM, I used custom replication agent, for indexing data to ElasticSearch server, as replication agent manages a queue in case replication is not successful and tries it again(after specified time). But the problem I faced was that on successful indexing(insertion\/updation), ElasticSearch return &quot;201 OK&quot; response but the replication agent considers only &quot;200&quot;","og:url":"https:\/\/www.tothenew.com\/blog\/custom-transport-handler-in-cq5aem\/","og:image":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","og:image:secure_url":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","twitter:card":"summary","twitter:site":"@tothenew","twitter:title":"Custom Transport Handler in CQ5\/AEM | TO THE NEW Blog","twitter:description":"While integrating ElasticSearch with AEM, I used custom replication agent, for indexing data to ElasticSearch server, as replication agent manages a queue in case replication is not successful and tries it again(after specified time). But the problem I faced was that on successful indexing(insertion\/updation), ElasticSearch return &quot;201 OK&quot; response but the replication agent considers only &quot;200&quot;","twitter:image":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png"},"aioseo_meta_data":{"post_id":"15735","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2021-04-29 20:07:01","updated":"2024-02-29 08:52:36","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.tothenew.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.tothenew.com\/blog\/category\/technology\/\" title=\"Technology\">Technology<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tCustom Transport Handler in CQ5\/AEM\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.tothenew.com\/blog"},{"label":"Technology","link":"https:\/\/www.tothenew.com\/blog\/category\/technology\/"},{"label":"Custom Transport Handler in CQ5\/AEM","link":"https:\/\/www.tothenew.com\/blog\/custom-transport-handler-in-cq5aem\/"}],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/15735","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/48"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=15735"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/15735\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=15735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=15735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=15735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}