How to compress remote EJB communication in JBoss EAP 7 / 6
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 7.x
- 6.x
Issue
-
We currently are using remote EJBs, some of the methods return a large data set, and we would like to have that data compressed. JBoss EAP 5 had a org.jboss.remoting.marshal.compress.CompressingMarshaller in the org.jboss.remoting.transport.Connector Mbean, Is there an equivalent in EAP 6 to compress remote EJB communication?
-
Transparent compression of remote EJB calls was developed in EJBCLIENT-76 and WFLY-1332. Will this be available in EAP 6 too ?
Resolution
JBoss EAP 7.x / 6.3+
In JBoss EAP 6.3.0 and later, data compression hints can be speciifed via the JBoss annotation org.jboss.ejb.client.annotation.CompressionHint
There is a bug resolved in JBoss EAP 6.3 CP2 needed to use the compression functionality, This content is not included.bz-1149023
The hint values specify whether to compress the request, response or request & response. Adding @CompressionHint defaults to compressResponse=true & compressRequest=true. compressionLevel defaults to Deflater.DEFAULT_COMPRESSION.
Note: compression hints currently can only be specified by annotations on the EJB interface which should be on the client & server side. There is not currently an xml equivalent to specify compression hints.
compressionLevel can have the following values:
- BEST_COMPRESSION - Compression level for best compression.
- BEST_SPEED - Compression level for fastest compression.
- DEFAULT_COMPRESSION - Default compression level.
- NO_COMPRESSION - Compression level for no compression.
The annotation can be specified at the interface level to apply to all methods in the EJB's interface such as:
import org.jboss.ejb.client.annotation.CompressionHint;
@CompressionHint(compressResponse = false)
public interface ClassLevelRequestCompressionRemoteView {
String echo(String msg);
}
Or the annotation can be applied to specific methods in the EJB's interface such as:
import org.jboss.ejb.client.annotation.CompressionHint;
public interface CompressableDataRemoteView {
@CompressionHint(compressResponse = false, compressionLevel = Deflater.BEST_COMPRESSION)
String echoWithRequestCompress(String msg);
@CompressionHint(compressRequest = false)
String echoWithResponseCompress(String msg);
@CompressionHint
String echoWithRequestAndResponseCompress(String msg);
String echoWithNoCompress(String msg);
}
Class level with method level overrides:
@CompressionHint
public interface MethodOverrideDataCompressionRemoteView {
@CompressionHint(compressRequest = false)
String echoWithResponseCompress(final String msg);
@CompressionHint(compressResponse = false)
String echoWithRequestCompress(final String msg);
String echoWithNoExplicitDataCompressionHintOnMethod(String msg);
}
On the client side make sure this system property is set to true: org.jboss.ejb.client.view.annotation.scan.enabled
This property tells JBoss EJB Client to scan for annotations.
JBoss EAP 6.0.x and 6.1.x
JBoss Remoting3 does not have any compression options, compression would need to be done at the protocol level which would be at the EJB level. There is a feature request opened for JBoss EAP 6, if approved it will be included in a future version of JBoss EAP.
Related Solutions:
[How to compress data send over RMI via remoting in JBoss EAP 4 / 5](https://access.redhat.com/knowledge/solutions/65024)
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.