Hi Team,
We have 4 publisher instances and some times we observed content in all publishers are not in sync, is there any way to route requests to a specific publisher instance in AEM for testing purpose from live site.
For an example :-
When i load a page in live url (www.example.com/home.html) the request should fetch content only from publisher 2.
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @Karthikachery ,
Routing requests to a specific publisher instance in Adobe Experience Manager (AEM) for testing purposes can be useful when dealing with synchronization issues or when you need to validate specific content on a particular instance. Here are some ways to achieve this:
If you are using AEM Dispatcher, you can configure a Dispatcher filter to route requests to a specific publisher instance. This can be done by modifying the dispatcher.any configuration file. Here’s how:
/dispatcher
{
/farms
{
/specific-publisher-instance
{
/clientheaders
{
"host"
"referer"
"user-agent"
"authorization"
"cookie"
}
/virtualhosts
{
"www.example.com"
}
/filters
{
# Allow all requests for testing
"/0001 { /type "allow" /glob "*" }"
}
/cache
{
/docroot "/path/to/cache/root"
/rules
{
"/0000 { /glob "*" /type "allow" }"
}
}
/stats
{
"/categories
{
"/html { /glob "*.html" }"
}
}
/renders
{
/specific-render
{
/hostname "publisher2.example.com"
/port "4503"
}
}
}
}
}
Apply Dispatcher Configuration:
Use a Custom Header or Parameter:
If your infrastructure includes a DNS service or a load balancer (e.g., F5, AWS ELB, etc.), you can temporarily configure it to route traffic to a specific publisher instance.
DNS Configuration:
Load Balancer Configuration:
For example, in AWS ELB, you could create a listener rule that checks for a specific query parameter or header and routes to a specific target group that contains Publisher 2.
For quick and manual testing, you can directly access the publisher instance via its internal URL. This does not require any configuration changes but is less ideal for testing live URLs.
http://publisher2.internal.example.com:4503/home.html
As a more advanced solution, you can implement a custom servlet filter in AEM that detects a specific query parameter or header and routes the request accordingly. This requires development effort and careful deployment.
import javax.servlet.*;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ConfigurationPolicy;
import org.osgi.framework.Constants;
@Component(
service = Filter.class,
property = {
Constants.SERVICE_DESCRIPTION + "=Custom Routing Filter",
"sling.filter.scope=request"
},
configurationPolicy = ConfigurationPolicy.OPTIONAL
)
public class CustomRoutingFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
String targetPublisher = httpRequest.getParameter("targetPublisher");
if ("publisher2".equals(targetPublisher)) {
RequestDispatcher dispatcher = request.getRequestDispatcher("http://publisher2.internal.example.com:4503" + httpRequest.getRequestURI());
dispatcher.forward(request, response);
} else {
chain.doFilter(request, response);
}
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void destroy() {
}
}
By using any of these methods, you can route requests to a specific publisher instance for testing purposes. The choice of method depends on your infrastructure setup and the level of control you have over the various components in your deployment.
Hi @Karthikachery ,
Routing requests to a specific publisher instance in Adobe Experience Manager (AEM) for testing purposes can be useful when dealing with synchronization issues or when you need to validate specific content on a particular instance. Here are some ways to achieve this:
If you are using AEM Dispatcher, you can configure a Dispatcher filter to route requests to a specific publisher instance. This can be done by modifying the dispatcher.any configuration file. Here’s how:
/dispatcher
{
/farms
{
/specific-publisher-instance
{
/clientheaders
{
"host"
"referer"
"user-agent"
"authorization"
"cookie"
}
/virtualhosts
{
"www.example.com"
}
/filters
{
# Allow all requests for testing
"/0001 { /type "allow" /glob "*" }"
}
/cache
{
/docroot "/path/to/cache/root"
/rules
{
"/0000 { /glob "*" /type "allow" }"
}
}
/stats
{
"/categories
{
"/html { /glob "*.html" }"
}
}
/renders
{
/specific-render
{
/hostname "publisher2.example.com"
/port "4503"
}
}
}
}
}
Apply Dispatcher Configuration:
Use a Custom Header or Parameter:
If your infrastructure includes a DNS service or a load balancer (e.g., F5, AWS ELB, etc.), you can temporarily configure it to route traffic to a specific publisher instance.
DNS Configuration:
Load Balancer Configuration:
For example, in AWS ELB, you could create a listener rule that checks for a specific query parameter or header and routes to a specific target group that contains Publisher 2.
For quick and manual testing, you can directly access the publisher instance via its internal URL. This does not require any configuration changes but is less ideal for testing live URLs.
http://publisher2.internal.example.com:4503/home.html
As a more advanced solution, you can implement a custom servlet filter in AEM that detects a specific query parameter or header and routes the request accordingly. This requires development effort and careful deployment.
import javax.servlet.*;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ConfigurationPolicy;
import org.osgi.framework.Constants;
@Component(
service = Filter.class,
property = {
Constants.SERVICE_DESCRIPTION + "=Custom Routing Filter",
"sling.filter.scope=request"
},
configurationPolicy = ConfigurationPolicy.OPTIONAL
)
public class CustomRoutingFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
String targetPublisher = httpRequest.getParameter("targetPublisher");
if ("publisher2".equals(targetPublisher)) {
RequestDispatcher dispatcher = request.getRequestDispatcher("http://publisher2.internal.example.com:4503" + httpRequest.getRequestURI());
dispatcher.forward(request, response);
} else {
chain.doFilter(request, response);
}
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void destroy() {
}
}
By using any of these methods, you can route requests to a specific publisher instance for testing purposes. The choice of method depends on your infrastructure setup and the level of control you have over the various components in your deployment.
Thank you for the detailed explanation @HrishikeshKa , this really helps.
Hi @Karthikachery
If you are on AMS, you can talk to your Adobe CSE,
CSE will do this from load balancer, they can create a target group and add a testing dispatcher to that group and based on some cookies , the traffic can be redirected to test dispatcher.
Views
Likes
Replies