Unlike the socket transport and its derivatives, which interact directly with Sockets and ServerSockets, the http family of transports uses java.net.HttpURLConnections. While they do not exhibit the same performance as the socket transports, they have the advantage of using the universal http protocol.
Any of JBoss Messaging, EJB2, and EJB3 can use the http transports instead of the socket family of transports. Additional configuration information may be found in the wiki articles EJB, JMS and JNDI over HTTP with Unified Invoker and EJB, JMS and JNDI over HTTP via NAT Firewall with Unified Invoker.
On the client side, an org.jboss.remoting.transport.http.HTTPClientInvoker, a subclass of RemoteClientInvoker, creates a java.net.HttpURLConnection for each invocation. The caching of HttpURLConnections and their Socket is left to the implementation. On the server side, the org.jboss.remoting.transport.coyote.CoyoteInvoker, which is a subclass of ServerInvoker and is based on the coyote module in Tomcat, processes http requests, calls on ServerInvoker to hand invocations off to the appropriate ServerInvocationHandler, and returns a result along with a response code.
The https transport is derived from the http transport and uses javax.net.ssl.SSLSockets and javax.net.ssl.SSLServerSockets instead of Sockets and ServerSockets.
The servlet and sslservlet transports share the client side code of the http and https transports, respectively. On the server side, the difference is that the servlet and sslservlet transports use a servlet, org.jboss.remoting.transport.servlet.web.ServerInvokerServlet, to hand an invocation off to an org.jboss.remoting.transport.servlet.ServletServerInvoker. In other words, the servlet and sslservlet transports share a port with all other servlets running in the Application Server, while the http and https transports use a separate port managed by a CoyoteInvoker.
When the ServerInvokerServlet is initialized, it needs to be informed of which ServletServerInvoker to use. One way of doing that is to give it the appropriate InvokerLocator. For example, the following web.xml file is used by JBoss Messaging:
<web-app> <servlet> <servlet-name>JmsServerInvokerServlet</servlet-name> <description>The JmsServerInvokerServlet receives JMS requests via HTTP protocol from within a web container and passes it onto the ServletServerInvoker for processing. </description> <servlet-class>org.jboss.remoting.transport.servlet.web.ServerInvokerServlet</servlet-class> <init-param> <param-name>locatorUrl</param-name> <param-value> <![CDATA[servlet://${jboss.bind.address}:8080/servlet-invoker/JmsServerInvokerServlet/?dataType=jms&JBM_clientMaxPoolSize=200&failureDisconnectTimeout=0&marshaller=org.jboss.jms.wireformat.JMSWireFormat&unmarshaller=org.jboss.jms.wireformat.JMSWireFormat&numberOfCallRetries=1&pingFrequency=214748364&pingWindowFactor=10&stopLeaseOnFailure=true&clientLeasePeriod=10000&validatorPingPeriod=10000&validatorPingTimeout=5000&timeout=0&blockingMode=blocking&blockingTimeout=30000&useAllParams=true&useClientConnectionIdentity=true]]> </param-value> <description>The servlet server invoker</description> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>JmsServerInvokerServlet</servlet-name> <url-pattern>/JmsServerInvokerServlet/*</url-pattern> </servlet-mapping> </web-app>
In general, parameters passed to a CoyoteInvoker are passed to the underlying Tomcat implementation. For example, the Tomcat attribute "maxThreads" can be used to set the maximum number of threads to be used to accept incoming http requests. However, the Remoting attributes "serverBindAddress" and "serverBindPort" should be used instead of the Tomcat attributes "address" and "port". For more information on the configuration attributes available for the Tomcat connectors, please refer to http://tomcat.apache.org/tomcat-6.0-doc/config/http.html.
CoyoteInvoker can also configure an instance of org.apache.catalina.Executor, an interface which extends java.util.concurrent.Executor. If the parameter "executor" is associated with a comma separated list of key=value pairs, CoyoteInvoker will parse the list, use the resulting Map to configure an instance of org.apache.catalina.core.StandardThreadExecutor, and inject it into the underlying Tomcat implementation. For example, JBoss Messaging's remoting-http-service.xml configuration file could contain
<attribute name="executor">minSpareThreads=20,maxThreads=100</attribute>
Note that if an executor is injected, the other threadpool related attributes such as "maxThreads", which would otherwise be applied to a threadpool created by Tomcat, are ignored. The configurable attributes of the StandardThreadExecutor are described in http://tomcat.apache.org/tomcat-6.0-doc/config/executor.html.
The following parameter may be used to configure an instance of ServletServerInvoker:
unwrapSingletonArrays - key indicating if, when javax.servlet.http.HttpServletRequest.getParameterMap() returns a map containing pairs of the form (key, value) where value has the form java.lang.String[] with length 1, the pair should be replaced with a pair (key, ((String[] value)[0]). The default value is "false".
The following parameters may be used to configure an instance of org.jboss.remoting.transport.http.HTTPClientInvoker:
disconnectAfterUse - key indicating if the java.net.HttpURLConnection should be disconnected after the invocation. The default value is "false".
ignoreErrorResponseMessage - key indicating if HTTPClientInvoker should try to get a response message and response code in the event of an exception. The default value is "false".
numberOfCallAttempts - This parameter is relevant only on the client side, where it determines the maximum number of attempts that will be made to complete an invocation. The default value is 1.
unmarshalNullStream - key indicating if HTTPClientInvoker should make the call to UnMarshaller.read() when the InputStream is null. The default value is "true".
The following parameters may be used to configure an instance of HTTPSClientInvoker:
org.jboss.security.ignoreHttpsHost - key indicating if HTTPSClientInvoker should ignore host name verification, i.e., it will not check for a mismatch between the URL's hostname and the server's hostname during handshaking. By default, standard hostname verification will be performed.
hostnameVerifier - key indicating the hostname verifier that should be used by HTTPSClientInvoker. The value should be the fully qualified classname of a class that implements javax.net.ssl.HostnameVerifier and has a void constructor.
Unlike the bisocket transport, which was designed especially to allow push callbacks without opening a port on the client side, a server in any of the http transports necessarily opens a ServerSocket, so push callbacks are ruled out when JBoss Messaging runs on any of the http transports. Pull callbacks are used instead, and there are some configuration parameters that can be set:
blockingMode - indicates whether to use blocking or nonblocking mode when doing pull callbacks. In nonblocking mode a poller periodically polls for waiting callbacks, and, if there are none, returns. In blocking mode, the poller periodically polls for waiting callbacks, and, if there are none, the call blocks on the server side until a callback is made available, at which point the poller immediately retrieves the callback to the client side. Blocking mode, then, is more responsive, and it is used by JBoss Messaging. By default, nonblocking mode is used.
blockingTimeout - when pull callbacks are used in blocking mode, indicates the amount of time the callback poller should block on the server side waiting for a callback. The default value is 5000 milliseconds, but JBoss Messaging uses 30000 milliseconds.