Class JMSReceiver
java.lang.Object
org.apache.log4j.component.spi.ComponentBase
org.apache.log4j.component.plugins.PluginSkeleton
org.apache.log4j.component.plugins.Receiver
org.apache.log4j.receivers.net.JMSReceiver
- All Implemented Interfaces:
javax.jms.MessageListener, Plugin, Component, Thresholdable, org.apache.log4j.spi.OptionHandler
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 Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprotected Stringprotected Stringprivate Stringprivate Stringprotected javax.jms.TopicConnectionprotected Stringprotected Stringprotected StringFields inherited from class Receiver
thresholdLevelFields inherited from class PluginSkeleton
nameFields inherited from class ComponentBase
repository -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidStarts the JMSReceiver with the current options.Gets the path to a properties file containing the initial context and jndi provider urlGets the curernt password property.Gets the curernt JMS topic factory name property.Gets the curernt JMS topic name property.Gets the current user id property.booleanisActive()Returns true if this receiver is active.booleanisEquivalent(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.protected ObjectvoidonMessage(javax.jms.Message message) protected voidsetActive(boolean _active) Sets the flag to indicate if receiver is active or not.voidsetJndiPath(String _jndiPath) Sets the path to a properties file containing the initial context and jndi provider urlvoidsetPassword(String _password) Sets the password to use when creating the JMS connection.voidsetTopicFactoryName(String _topicFactoryName) Sets the JMS topic factory name to use when creating the JMS connection.voidsetTopicName(String _topicName) Sets the JMS topic name to use when creating the JMS connection.voidSets the user id to use when creating the JMS connection.voidshutdown()Called when the receiver should be stopped.Methods inherited from class Receiver
doPost, getThreshold, isAsSevereAsThreshold, setThresholdMethods inherited from class PluginSkeleton
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getLoggerRepository, getName, removePropertyChangeListener, removePropertyChangeListener, setLoggerRepository, setNameMethods inherited from class ComponentBase
getLogger, getNonFloodingLogger, resetErrorCount
-
Field Details
-
active
private boolean active -
topicFactoryName
-
topicName
-
userId
-
password
-
topicConnection
protected javax.jms.TopicConnection topicConnection -
jndiPath
-
remoteInfo
-
providerUrl
-
-
Constructor Details
-
JMSReceiver
public JMSReceiver() -
JMSReceiver
-
-
Method Details
-
setJndiPath
Sets the path to a properties file containing the initial context and jndi provider url -
getJndiPath
Gets the path to a properties file containing the initial context and jndi provider url -
setTopicFactoryName
Sets the JMS topic factory name to use when creating the JMS connection. -
getTopicFactoryName
Gets the curernt JMS topic factory name property. -
setTopicName
Sets the JMS topic name to use when creating the JMS connection. -
getTopicName
Gets the curernt JMS topic name property. -
setUserId
Sets the user id to use when creating the JMS connection. -
getUserId
Gets the current user id property. -
setPassword
Sets the password to use when creating the JMS connection. -
getPassword
Gets the curernt password property. -
isEquivalent
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:
isEquivalentin interfacePlugin- Overrides:
isEquivalentin classPluginSkeleton- 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:
isActivein interfacePlugin- Overrides:
isActivein classPluginSkeleton- 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:
activateOptionsin interfaceorg.apache.log4j.spi.OptionHandler
-
shutdown
-
onMessage
public void onMessage(javax.jms.Message message) - Specified by:
onMessagein interfacejavax.jms.MessageListener
-
lookup
- Throws:
NamingException
-