Apache web-server (also known as Apache Hyper Text Transfer Protocol server) and Apache Tomcat both are SERVERS( servers are software that works on network or on internet) and are both developed by APACHE.
Apache is a server designed to serve HTTP, or we can also call it as a web-server, which serves the requests from browsers for web-pages. But an Apache server is not limited to this only. It can effectively serve the HTTP requests for the static contents but can be also configured to handle requests for dynamic contents generated through a wide range of languages and technologies like PHP, J2EE or whatever.
Next comes is Apache Tomcat, which itself is a server and compliments Apache web-server. It is also developed by Apache and usually CONFUSES us with the Apache web-server developed by Apache itself. Although they are both servers that are meant for use in the Internet, but they have separate and distinct roles to play.
Apache Tomcat is a server specifically meant to run applications that were written in Java and JSP (Java Server Pages). It is open source software just like Apache web-server created by Apache, and is free to use. It's primary purpose is to implement the Java Servlet API and execute Java servlets for dynamic websites. Tomcat can also be used as a regular HTTP web-server that serves static pages, but that is not its primary purpose.
If we are putting up a Apache web-server and we want to have Java or JSP support, then we should go for offering that Apache Tomcat has as both are made by Apache. And, hence reduces the chances of encountering problem while configuring them to work together.
In short we can say "Apache Tomcat server is a SPECIALIZED web server called a "servlet container." And it features a BASIC web server CUSTOMIZED to execute Java servlets and JSP pages. BUT at the same time it can also be configured to serve other technologies as well."
Now, as the individuality of Apache web-server and Apache Tomcat is quite clear to us, we can say that "Apache web-server is usually configured to use the Tomcat server as a back-end handler for servlets and JSPs".
Total Pageviews
Tuesday, 15 January 2013
Friday, 4 January 2013
Spring : Configuring failover in Spring
WebClients
can
be
configured
in
Spring
to
handle
the
failover
in
case
any
of
the
webservice
connection
fails
to
respond
due
to
network
or
server
failure
or
due
to
any
other
reason.
In
order
to
handle
such
issues
Apache
CXF
provides
Sequential
and
Random
strategies,
which
are
supported
and
implementers
can
develop
more
sophisticated
failover
features
by
retrieving
alternate
addresses.
The
above
could
be
achieved
by
doing
the
following
configurations
in
spring-servlet.xml
(Spring
Web
Context
Configuration
file)
or
whatever
else
you
call
it.
Spring-servlet.xml(
failover
configurations
only)
____________________________________________________________________________
<?xml
version="1.0"
encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://cxf.apache.org/core
http://cxf.apache.org/schemas/core.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.0.xsd
"
>
<!--
begin: Fail over configurations -->
<util:list
id="alternateSerAddresses"
list-class="java.util.concurrent.CopyOnWriteArrayList">
<value>http://hostname:port/servie-location-1</value>
<value>http://hostname:port/servie-location-2</value>
<value>http://hostname:port/servie-location-3</value>
</util:list>
<bean
id="serviceClientFactory"
class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property
name="serviceClass"
value="com.soaptopupsuite.EndPointInterface"/>
<property
name="address"
value="http://hostname:port/service-default-loc"/>
<property
name="username"
value="service-username"/>
<property
name="password"
value="service-password"/>
<property
name="features">
<util:list>
<bean
class="org.apache.cxf.clustering.FailoverFeature">
<property
name="strategy">
<bean
class="org.apache.cxf.clustering.SequentialStrategy">
<property
name="alternateAddresses"
ref="alternateSerAddresses"/>
</bean>
</property>
</bean>
</util:list>
</property>
</bean>
<bean
id="serviceClient"
class="com.soaptopupsuite.EndPointInterface"
factory- bean="serviceClientFactory"
factory-method="create"/>
<bean
id="servicePort"
class="com.swaraj.client.WsClient">
<property
name="port"
ref="serviceClient"
/>
</bean>
<!--
end: Fail over configurations -->
</beans>
Here,
the
client
factory
does
not
itself
defines
the
address
attribute.
It
uses
that
alternateSerAddresses
list
exclusively
throughout
all
the
invocations
and
primary
address
exists
as
default
location.
SequentialStrategy
will
use
one
endpoint
after
another
providing
nice
round
robin
implementation
(RandomStrategy
is
available
as
well,
where
an
end
point
is
picked
up
randomly).
Also
in
this
configuration
we
will
get
failover
– if
any
endpoint
fails,
all
endpoints
starting
from
the
default
one
will
be
examined
(except
the
one
that
has
just
failed).
Reference
Java
Code (Spring 3.1) :
package
com.swaraj.client;
@Service
public
class
WsClient
{
/*
list of
instance variable*/
//
web
service
location
private
EndPointInterface
port;
//
setter
injection
for
EndPointInterface
public
void
setPort(EndPointInterface
port)
{
this.port
=
port;
}
//
Invoking
web
service
method
on
EndPointInterface
port.
public
String
webSerMethodCall(){
return
port.testCall();
}
}
Subscribe to:
Posts (Atom)