Class JMSAppender
- All Implemented Interfaces:
Appender,OptionHandler
invalid reference
ObjectMessage
JMS
invalid reference
topicsinvalid reference
topic
connection factoriesContext.
There are two common methods for retrieving a JNDI Context. If a file resource named jndi.properties is
available to the JNDI API, it will use the information found
therein to retrieve an initial JNDI context. To obtain an initial
context, your code will simply call:
InitialContext jndiContext = new InitialContext();
Calling the no-argument InitialContext() method
will also work from within Enterprise Java Beans (EJBs) because it
is part of the EJB contract for application servers to provide each
bean an environment naming context (ENC).
In the second approach, several predetermined properties are set
and these properties are passed to the InitialContext
constructor to connect to the naming service provider. For example,
to connect to JBoss naming service one would write:
Properties env = new Properties( ); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); env.put(Context.PROVIDER_URL, "jnp://hostname:1099"); env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); InitialContext jndiContext = new InitialContext(env);where hostname is the host where the JBoss application server is running.
To connect to the the naming service of Weblogic application server one would write:
Properties env = new Properties( ); env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); env.put(Context.PROVIDER_URL, "t3://localhost:7001"); InitialContext jndiContext = new InitialContext(env);
Other JMS providers will obviously require different values.
The initial JNDI context can be obtained by calling the
no-argument InitialContext() method in EJBs. Only
clients running in a separate JVM need to be concerned about the
jndi.properties file and calling InitialContext() or alternatively correctly
setting the different properties before calling InitialContext(java.util.Hashtable) method.
- Author:
- Ceki Gülcü
-
Field Summary
Fields inherited from class org.apache.log4j.AppenderSkeleton
closed, errorHandler, headFilter, layout, name, tailFilter, threshold -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidOptions are activated and become effective only after calling this method.voidappend(LoggingEvent event) This method called byAppenderSkeleton.doAppend(org.apache.log4j.spi.LoggingEvent)method to do most of the real appending work.protected booleanvoidclose()Close this JMSAppender.Returns the value of the InitialContextFactoryName option.booleanReturns value of the LocationInfo property which determines whether location (stack) info is sent to the remote subscriber.Returns the value of the TopicBindingName option.protected TopicConnectionReturns the TopicConnection used for this appender.Returns the value of the TopicConnectionFactoryBindingName option.protected TopicPublisherReturns the TopicPublisher used for this appender.protected TopicSessionReturns the TopicSession used for this appender.protected ObjectbooleanThe JMSAppender sends serialized events and consequently does not require a layout.voidsetInitialContextFactoryName(String initialContextFactoryName) Setting the InitialContextFactoryName method will cause thisJMSAppenderinstance to use theInitialContext(Hashtable)method instead of the no-argument constructor.voidsetLocationInfo(boolean locationInfo) If true, the information sent to the remote subscriber will include caller's location information.voidsetPassword(String password) The paswword to use when creating a topic session.voidsetProviderURL(String providerURL) voidsetSecurityCredentials(String securityCredentials) voidsetSecurityPrincipalName(String securityPrincipalName) voidsetTopicBindingName(String topicBindingName) The TopicBindingName option takes a string value.voidsetTopicConnectionFactoryBindingName(String tcfBindingName) The TopicConnectionFactoryBindingName option takes a string value.voidsetURLPkgPrefixes(String urlPkgPrefixes) voidsetUserName(String userName) The user name to use when.invalid reference
creating a topic sessionMethods inherited from class org.apache.log4j.AppenderSkeleton
addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold
-
Constructor Details
-
JMSAppender
public JMSAppender()
-
-
Method Details
-
setTopicConnectionFactoryBindingName
The TopicConnectionFactoryBindingName option takes a string value. Its value will be used to lookup the appropriateTopicConnectionFactoryfrom the JNDI context. -
getTopicConnectionFactoryBindingName
Returns the value of the TopicConnectionFactoryBindingName option. -
setTopicBindingName
The TopicBindingName option takes a string value. Its value will be used to lookup the appropriateTopicfrom the JNDI context. -
getTopicBindingName
Returns the value of the TopicBindingName option. -
getLocationInfo
public boolean getLocationInfo()Returns value of the LocationInfo property which determines whether location (stack) info is sent to the remote subscriber. -
activateOptions
public void activateOptions()Options are activated and become effective only after calling this method.- Specified by:
activateOptionsin interfaceOptionHandler- Overrides:
activateOptionsin classAppenderSkeleton
-
lookup
- Throws:
NamingException
-
checkEntryConditions
protected boolean checkEntryConditions() -
close
public void close()Close this JMSAppender. Closing releases all resources used by the appender. A closed appender cannot be re-opened. -
append
This method called byAppenderSkeleton.doAppend(org.apache.log4j.spi.LoggingEvent)method to do most of the real appending work.- Specified by:
appendin classAppenderSkeleton
-
getInitialContextFactoryName
Returns the value of the InitialContextFactoryName option. SeesetInitialContextFactoryName(java.lang.String)for more details on the meaning of this option. -
setInitialContextFactoryName
Setting the InitialContextFactoryName method will cause thisJMSAppenderinstance to use theInitialContext(Hashtable)method instead of the no-argument constructor. If you set this option, you should also at least set the ProviderURL option.See also
setProviderURL(String). -
getProviderURL
-
setProviderURL
-
setURLPkgPrefixes
-
getSecurityCredentials
-
setSecurityCredentials
-
getSecurityPrincipalName
-
setSecurityPrincipalName
-
getUserName
-
setUserName
The user name to use when. If you set this option, you should also set the Password option. Seeinvalid reference
creating a topic sessionsetPassword(String). -
getPassword
-
setPassword
The paswword to use when creating a topic session. -
setLocationInfo
public void setLocationInfo(boolean locationInfo) If true, the information sent to the remote subscriber will include caller's location information. By default no location information is sent to the subscriber. -
getTopicConnection
protected TopicConnection getTopicConnection()Returns the TopicConnection used for this appender. Only valid after activateOptions() method has been invoked. -
getTopicSession
protected TopicSession getTopicSession()Returns the TopicSession used for this appender. Only valid after activateOptions() method has been invoked. -
getTopicPublisher
protected TopicPublisher getTopicPublisher()Returns the TopicPublisher used for this appender. Only valid after activateOptions() method has been invoked. -
requiresLayout
public boolean requiresLayout()The JMSAppender sends serialized events and consequently does not require a layout.
-