Package org.rribbit.dispatching
Class RmiRequestDispatcher
java.lang.Object
org.rribbit.dispatching.RmiRequestDispatcher
- All Implemented Interfaces:
RequestDispatcher
This
RequestDispatcher
dispatches a Request
to an RmiRequestProcessor
via RMI. It offers automatic loadbalancing and failover.
Note that the RMI connection is NOT maintained between requests, meaning that a new connection is set up each time a request is made to this RmiRequestDispatcher
.
This also means that, if you choose to use SSL, an SSL handshake is done on each request.- Author:
- G.J. Schouten
-
Field Summary
-
Constructor Summary
ConstructorDescriptionRmiRequestDispatcher
(int portnumber, String... hosts) Connects toRmiRequestProcessor
s that run on the specified port and on the specified hosts.RmiRequestDispatcher
(String truststoreLocation, int portnumber, String... hosts) Connects toRmiRequestProcessor
s that run on the specified port and on the specified hosts. -
Method Summary
Modifier and TypeMethodDescription<T> Response
<T> dispatchRequest
(Request request) int
Gets the number of times thisRmiRequestDispatcher
retries when it cannot connect to theRmiRequestProcessor
.void
setRetryAttempts
(int retryAttempts) Sets the number of times thisRmiRequestDispatcher
retries when it cannot connect to theRmiRequestProcessor
.
-
Field Details
-
retryAttempts
protected int retryAttempts -
portnumber
protected int portnumber -
hosts
-
truststoreLocation
-
-
Constructor Details
-
RmiRequestDispatcher
Connects toRmiRequestProcessor
s that run on the specified port and on the specified hosts. If multiple hosts are specified, one is randomly chosen at runtime, creating automatic load-balancing. If a connection to a host fails, another one is chosen. The default number of retries is 10 and can be set with the corresponding setter. Use this constructor if you do NOT want to use SSL.- Parameters:
portnumber
- The portnumber to usehosts
- The hosts to connect to, you can specify one host multiple times, to give it a proportionally larger chance of being chosen
-
RmiRequestDispatcher
Connects toRmiRequestProcessor
s that run on the specified port and on the specified hosts. If multiple hosts are specified, one is randomly chosen at runtime, creating automatic load-balancing. If a connection to a host fails, another one is chosen. The default number of retries is 10 and can be set with the corresponding setters. Use this constructor if you DO want to use SSL. The "javax.net.ssl.trustStore" system property will be set.- Parameters:
truststoreLocation
- The filepath that contains the SSL truststore, without file://portnumber
- The portnumber to usehosts
- The hosts to connect to, you can specify one host multiple times, to give it a proportionally larger chance of being chosen
-
-
Method Details
-
dispatchRequest
Description copied from interface:RequestDispatcher
- Specified by:
dispatchRequest
in interfaceRequestDispatcher
- Parameters:
request
- TheRequest
to be dispatched to aRequestProcessor
- Returns:
- The
Response
to be returned from theRequestProcessor
-
getRetryAttempts
public int getRetryAttempts()Gets the number of times thisRmiRequestDispatcher
retries when it cannot connect to theRmiRequestProcessor
. The default is 10. -
setRetryAttempts
public void setRetryAttempts(int retryAttempts) Sets the number of times thisRmiRequestDispatcher
retries when it cannot connect to theRmiRequestProcessor
. The default is 10.- Parameters:
retryAttempts
-
-