Chapter 42. Intercepting Operations

JBoss Messaging supports interceptors to intercept packets entering and leaving the server. Any supplied interceptors would be called for any packet entering or leaving the server, this allows custom code to be executed, e.g. for auditing packets, filtering or other reasons. Interceptors can change the packets they intercept.

42.1. Implementing The Interceptors

A interceptor must implement the Interceptor interface:

package org.jboss.messaging.core.remoting;

public interface Interceptor
   boolean intercept(Packet packet, RemotingConnection connection) 
                throws MessagingException;

The returned boolean value is important:

  • if true is returned, the process continues normally

  • if false is returned, the process is aborted, no other interceptors will be called and the packet will not be handled by the server at all.

42.2. Configuring The Interceptors

The interceptors are configured in jbm-configuration.xml:


The interceptors classes (and their dependencies) must be added to the server classpath to be properly instantiated and called.

42.3. Example

See Section 9.1.16, “Interceptor” for an example which shows how to use interceptors to add properties to a message on the server.