Class JmsManager
- java.lang.Object
-
- org.apache.logging.log4j.core.appender.AbstractManager
-
- org.apache.logging.log4j.core.appender.mom.JmsManager
-
- All Implemented Interfaces:
AutoCloseable
public class JmsManager extends AbstractManager
Consider this class private; it is only public for access by integration tests.JMS connection and session manager. Can be used to access MessageProducer, MessageConsumer, and Message objects involving a configured ConnectionFactory and Destination.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JmsManager.JmsManagerConfiguration
-
Field Summary
-
Fields inherited from class org.apache.logging.log4j.core.appender.AbstractManager
count
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.jms.Message
createMessage(Serializable object)
Creates a TextMessage, MapMessage, or ObjectMessage from a Serializable object.javax.jms.MessageConsumer
createMessageConsumer()
Creates a MessageConsumer on this Destination using the current Session.javax.jms.MessageProducer
createMessageProducer(javax.jms.Session session, javax.jms.Destination destination)
Creates a MessageProducer on this Destination using the current Session.static JmsManager
getJmsManager(String name, Properties jndiProperties, String connectionFactoryName, String destinationName, String userName, char[] password, boolean immediateFail, long reconnectIntervalMillis)
Gets a JmsManager using the specified configuration parameters.JmsManager.JmsManagerConfiguration
getJmsManagerConfiguration()
protected boolean
releaseSub(long timeout, TimeUnit timeUnit)
May be overridden by managers to perform processing while the manager is being released and the lock is held.-
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractManager
close, getContentFormat, getCount, getLoggerContext, getManager, getName, hasManager, log, logDebug, logError, logWarn, narrow, release, stop, updateData
-
-
-
-
Method Detail
-
getJmsManager
public static JmsManager getJmsManager(String name, Properties jndiProperties, String connectionFactoryName, String destinationName, String userName, char[] password, boolean immediateFail, long reconnectIntervalMillis)
Gets a JmsManager using the specified configuration parameters.- Parameters:
name
- The name to use for this JmsManager.connectionFactoryName
- The binding name for theConnectionFactory
.destinationName
- The binding name for theDestination
.userName
- The userName to connect with ornull
for no authentication.password
- The password to use with the given userName ornull
for no authentication.immediateFail
- Whether or not to fail immediately with aAppenderLoggingException
when connecting to JMS fails.reconnectIntervalMillis
- How to log sleep in milliseconds before trying to reconnect to JMS.jndiManager
- The JndiManager to look up JMS information through.- Returns:
- The JmsManager as configured.
-
createMessage
public javax.jms.Message createMessage(Serializable object) throws javax.jms.JMSException
Creates a TextMessage, MapMessage, or ObjectMessage from a Serializable object.For instance, when using a text-based
Layout
such asPatternLayout
, theLogEvent
message will be serialized to a String.When using a layout such as
SerializedLayout
, the LogEvent message will be serialized as a Java object.When using a layout such as
MessageLayout
and the LogEvent message is a Log4j MapMessage, the message will be serialized as a JMS MapMessage.- Parameters:
object
- The LogEvent or String message to wrap.- Returns:
- A new JMS message containing the provided object.
- Throws:
javax.jms.JMSException
-
createMessageConsumer
public javax.jms.MessageConsumer createMessageConsumer() throws javax.jms.JMSException
Creates a MessageConsumer on this Destination using the current Session.- Returns:
- A MessageConsumer on this Destination.
- Throws:
javax.jms.JMSException
-
createMessageProducer
public javax.jms.MessageProducer createMessageProducer(javax.jms.Session session, javax.jms.Destination destination) throws javax.jms.JMSException
Creates a MessageProducer on this Destination using the current Session.- Parameters:
session
- The JMS Session to use to create the MessageProducerdestination
- The JMS Destination for the MessageProducer- Returns:
- A MessageProducer on this Destination.
- Throws:
javax.jms.JMSException
-
getJmsManagerConfiguration
public JmsManager.JmsManagerConfiguration getJmsManagerConfiguration()
-
releaseSub
protected boolean releaseSub(long timeout, TimeUnit timeUnit)
Description copied from class:AbstractManager
May be overridden by managers to perform processing while the manager is being released and the lock is held. A timeout is passed for implementors to use as they see fit.- Overrides:
releaseSub
in classAbstractManager
- Parameters:
timeout
- timeouttimeUnit
- timeout time unit- Returns:
- true if all resources were closed normally, false otherwise.
-
-