Message filters must implement both the MessageSource and the MessageSink interface. A message filter typically implements receiveMessage by manipulating the message in some way, then sending a new message, like this:

import atg.dms.patchbay.*;
import javax.jms.*;


MessageSourceContext mContext;
boolean mStarted = false;

// These methods implement the MessageSource interface
public void setMessageSourceContext (MessageSourceContext pContext)
{ mContext = pContext; }
public void startMessageSource ()
{ mStarted = true; }
public void stopMessageSource ()
{ mStarted = false; }

public void receiveMessage (String pPortName, Message pMessage)
  throws JMSException
  if (pMessage instanceof TextMessage) {
    String text = ((TextMessage).getText ());
    String newText = text.replace ('.', '/');
    TextMessage msg = mContext.createTextMessage ();
    msg.setJMSType (pMessage.getJMSType ());
    msg.setText (newText);
    mContext.sendMessage (msg);

This filter takes in TextMessages, then sends them out again with period (.) replaced by forward slash (/) in the text. Notice that the mStarted flag is not consulted, because a message filter is allowed to send out messages in response to incoming messages regardless of whether it has been started or stopped.