Class JMSReceiver

All Implemented Interfaces:
javax.jms.MessageListener, Plugin, Component, org.apache.log4j.spi.OptionHandler, Thresholdable

public class JMSReceiver extends Receiver implements javax.jms.MessageListener
JMSReceiver receives a remote logging event on a configured JSM topic and "posts" it to a LoggerRepository as if the event was generated locally. This class is designed to receive events from the JMSAppender class (or classes that send compatible events).

Once the event has been "posted", it will be handled by the appenders currently configured in the LoggerRespository.

This implementation borrows heavily from the JMSSink implementation.

  • Field Details

    • active

      private boolean active
    • topicFactoryName

      protected String topicFactoryName
    • topicName

      protected String topicName
    • userId

      protected String userId
    • password

      protected String password
    • topicConnection

      protected javax.jms.TopicConnection topicConnection
    • jndiPath

      protected String jndiPath
    • remoteInfo

      private String remoteInfo
    • providerUrl

      private String providerUrl
  • Constructor Details

    • JMSReceiver

      public JMSReceiver()
    • JMSReceiver

      public JMSReceiver(String _topicFactoryName, String _topicName, String _userId, String _password, String _jndiPath)
  • Method Details

    • setJndiPath

      public void setJndiPath(String _jndiPath)
      Sets the path to a properties file containing the initial context and jndi provider url
    • getJndiPath

      public String getJndiPath()
      Gets the path to a properties file containing the initial context and jndi provider url
    • setTopicFactoryName

      public void setTopicFactoryName(String _topicFactoryName)
      Sets the JMS topic factory name to use when creating the JMS connection.
    • getTopicFactoryName

      public String getTopicFactoryName()
      Gets the curernt JMS topic factory name property.
    • setTopicName

      public void setTopicName(String _topicName)
      Sets the JMS topic name to use when creating the JMS connection.
    • getTopicName

      public String getTopicName()
      Gets the curernt JMS topic name property.
    • setUserId

      public void setUserId(String _userId)
      Sets the user id to use when creating the JMS connection.
    • getUserId

      public String getUserId()
      Gets the current user id property.
    • setPassword

      public void setPassword(String _password)
      Sets the password to use when creating the JMS connection.
    • getPassword

      public String getPassword()
      Gets the curernt password property.
    • isEquivalent

      public boolean isEquivalent(Plugin testPlugin)
      Returns true if the receiver is the same class and they are configured for the same properties, and super class also considers them to be equivalent. This is used by PluginRegistry when determining if the a similarly configured receiver is being started.
      Specified by:
      isEquivalent in interface Plugin
      Overrides:
      isEquivalent in class PluginSkeleton
      Parameters:
      testPlugin - The plugin to test equivalency against.
      Returns:
      boolean True if the testPlugin is equivalent to this plugin.
    • isActive

      public boolean isActive()
      Returns true if this receiver is active.
      Specified by:
      isActive in interface Plugin
      Overrides:
      isActive in class PluginSkeleton
      Returns:
      true/false
    • setActive

      protected void setActive(boolean _active)
      Sets the flag to indicate if receiver is active or not.
    • activateOptions

      public void activateOptions()
      Starts the JMSReceiver with the current options.
      Specified by:
      activateOptions in interface org.apache.log4j.spi.OptionHandler
    • shutdown

      public void shutdown()
      Called when the receiver should be stopped.
      Specified by:
      shutdown in interface Plugin
    • onMessage

      public void onMessage(javax.jms.Message message)
      Specified by:
      onMessage in interface javax.jms.MessageListener
    • lookup

      protected Object lookup(Context ctx, String name) throws NamingException
      Throws:
      NamingException