What is Dispatcher?
Before knowing about dispatcher let us understand how AEM works in live environment and what are the modules in any live environment of AEM.
- We can have one or more than one AEM Author Instances.
- We can have one or more than one AEM Publisher Instances.
- We can have one or more than one Dispatcher.
- We will have web server(Tomcat or IIS).
Dispatcher is responsible for:-
- Caching.
- Security.
- Access.
- Load balancing and many more.
Why do we need of web server?
We have AEM server which is a complete server. Which have
- Servlet Container.
- Create the content.
- publish the content.
- Hold the Assets.
- Can run complete website.
Means we can run complete website using AEM only. "If we can run complete website using AEM only than why we need any other server?"
The reason of pulling the web server is because suppose we are exposing the publisher to the end user so there are numbers of requests(in millions) will directly go to the publisher and at a moment the publisher will not be able to respond to the end user. This is one reason and there are many more like caching, security and access etc.
Need Of Dispatcher?
But in actual environment we never expose directly our AEM server mean publisher to the end user. We will place a web server between AEM publisher and End user. The problem here is these two applications(AEM Dispatcher and Apache Web Server) don't know each other. Because these are two different-2 application.
The Apache server and AEM server are two different applications and can run individually. And Apache can host/run the static websites(For example simple java websites). Apache doesn't need AEM to process the content.
How the Apache and AEM will interact with each other?
We need a module who can interact with both Apache and AEM. So that Apache can do
- Caching.
- Load Balancing.
- Access Security.
Apache can do these things without AEM these are the basic features of Apache. As we mentioned these two servers don't know how they will interact with each other. A module made available by Adobe called Dispatcher which sits in the Apache web server. Dispatcher is a module not a server.
Dispatcher says I am module I will sit with the Apache and there are some configuration provided and i will tell you how to interpret those configuration. Dispatcher doesn't perform any task it basically tell the Apache server how to it. Basically Dispatcher will give the instructions to the Apache web server and web server will follow the instructions and perform the task based on the provided configurations. Dispatcher basically tell the server what to perform and when to perform.
How cycle works in live environment?
- First of all request will come to the Apache. But Apache don't know how to process the request .
- Apache will interact with the Dispatcher and based on the configuration provided the dispatcher will ask Apache to forward the request to AEM Server/Publisher.
- AEM Publisher will respond back to Apache with the Apache.
- Apache will do the caching etc and send response to the client/browser/end user.
How to Setup Dispatcher in Windows OS?
- You need to setup a publisher.
- You need to download the Apache Web Server here
- You need to download the dispatcher module from the here
We will use Apache 2.2 32 bit(apache 2.2-windows-x86).Now current version of Apache is 2.4 and we are using 2.2 because Adobe discontinued Dispatcher module for Apache 2.4 64 bit for windows machine.
Click here to download the dispatcher and search for dispatcher-apache2.2-windows-x86-4.2.1 you will be able to download the dispatcher-apache2.2-windows-x86-4.2.1.zip file.
Extract the dispatcher-apache2.2-windows-x86-4.2.1.zip file and you will be able to see disp_apache2.2.dll and dispatcher.any file. We will use these two files in the Dispatcher Setup.
Click here to download the Apache Server. You will get number for download options like.
You have to search for apache_2.2.2-win32-x86-no_ssl.msi
To install the Apache web server double click on the driver and click on next,next and finish. You will be able to see a folder named Apache2 in C:\Program Files (x86).
In C:\Program Files (x86)\Apache2 you will be able to see these folders.
After double click on ApacheMonitor we will be able to see a interface like
Click on start and if you will be able to see the message like Apache 2.2 service has started means your Apache web server has been installed correctly.
Type localhost in the browser and you will be able to see this interface.
How to Configure Apache Server With Dispatcher and Publisher ?
To configure Apache Web Server with Dispatcher and AEM we need to perform following steps.
- Install the publisher in your machine on any odd port number( like 4503,4505 and 4507 etc).
- Go to the extracted dispatcher-apache2.2-windows-x86-4.2.1.zip file and you will be able to see the following files.
- Copy the disp_apache2.2.dll file from dispatcher-apache2.2-windows-x86-4.2.1 folder and paste it in the module folder in Apache Web Server for example (C:\Apache2\modules).It looks like
- Now we have to go to the httpd.cond file present in the conf folder in Apache installation directory for example(C:\Apache2\conf).
- We have paste the disp_apache2.2.dll file from dispatcher folder to the Apache's modules directory(C:\Apache2\modules).
- Restart your web server if your web server has restarted successfully it means the web server is accepting the dispatcher module.
- Restart your Web Server. Again if your web server has restarted successfully it means the dispatcher module has been loaded by the Apache Web Server successfully.
- And we have to made the following changes in the httpd.conf file. Before made any changes let us understand what is the httpd.conf file and what it is doing. The httpd.conf file is the entry point of the web server when the request will come to the Web server it means the httpd.conf file is loading It is the file where the web server will be able to know what it should do. When request will come from the client the web httpd.conf file will load the dispatcher module by using LoadModule dispatcher_module modules/disp_apache2.2.dll. And the dispatcher.any file will be having your configuration for the dispatcer and the httpd.conf file means the web server will load dispatcher.any file and read the configuration and will perform accordingly. And to provide information where the configurations file are you have to add a if module and it is specific to the server. You have to provide the following information in the httpd.conf file
DispatcherConfig conf/dispatcher.any means where to read the dispatcher configuration and we have dispatcher.any file in the conf so we gave this configuration.
Second is the DispatcherLog logs/dispatcher.log it means where the dispatcher logs will be created. In our case the dispatcher logs will be created in the logs folder of Apache's installation directory.
Third is DispatcherLogLevel 3 it means we have log level like as log level present in AEM like info,trace and debug so DispatcherLogLevel 3 means the log level is debug.
These configurations are for the dispatcher module
But we need to tell dispatcher say these are the configuration file and you should look the configuration file here and we have to add a Directory tag.
Directory Tag:-The directory tag is used for the Apache It is used to enclosed a group of directive that will be apply to the named directory(Whatever we have loaded using the ifmodule), any sub directory and files under this directory.
The named directory IfModule under Directory tag has same name as we have in the ifModule.
SetHandler is a dispatcher handler It forces all the matching file to be processed by this handler ultimately it means the all the configuration that we have in ifModule will be processed by disp_apache2.2.dll file ultimately disp_apache2.2.dll is the dispatcher handler.
We are saying to the Web Server whatever you are getting in the Directory Tag(Inside directory tag we are loading the ifmodule) means the ifmodule should be process by the dispatcher handler means by disp_apache2.2.dll .
These are the we need to add in the httpd.conf file
LoadModule dispatcher_module modules/disp_apache2.2.dll
<IfModule disp_apache2.c>
# location of the configuration file. eg: 'conf/dispatcher.any'
DispatcherConfig conf/dispatcher.any
# location of the dispatcher log file. eg: 'logs/dispatcher.log'
DispatcherLog logs/dispatcher.logDispatcherLogLevel 3# if turned to 1, request to / are not handled by the dispatcher# use the mod_alias then for the correct mappingDispatcherDeclineRoot 0# if turned to 1, the dispatcher uses the URL already processed# by handlers preceeding the dispatcher (i.e. mod_rewrite)# instead of the original one passed to the web server.DispatcherUseProcessedURL 1</IfModule><Directory /><IfModule disp_apache2.c>ModMimeUsePathInfo On# enable dispatcher for ALL request. if this is too restrictive,# move it to another locationSetHandler dispatcher-handler</IfModule>Options FollowSymLinksAllowOverride None</Directory>
- Now go to the conf folder of Apache's installation directory and edit the dispatcher.any file and you will be able to see the farm files.
- Go to the cache section of dispatcher.any file and change to docroot and give the folder path of Apache's installation directory. By using this docroot's path you will decide in which directoty you want to create the apache for the application.
- Now Restart your web server and if your webserver has started web server has accepted all the configurations.
- Start your publisher in my case it's running on port 4503 and you will be able to see this page(we will use the we-retail sample website) My URL is http://localhost:4503/content/we-retail/us/en.html
- Now try to access it with the help of Web server like http://localhost/content/we-retail/us/en.html and you will be able to see the same page but via Web server not via publisher
- Now your web server is able to pull and content with the help of publisher. Means the publisher, dispatcher and web server(Apache) has been integrated successfully.
No comments:
Post a Comment