public class JmsManager extends AbstractManager
JMS connection and session manager. Can be used to access MessageProducer, MessageConsumer, and Message objects involving a configured ConnectionFactory and Destination.
Modifier and Type | Class and Description |
---|---|
static class |
JmsManager.JmsManagerConfiguration |
count, LOGGER
Modifier and Type | Method and Description |
---|---|
Message |
createMessage(Serializable object)
Creates a TextMessage, MapMessage, or ObjectMessage from a Serializable object.
|
MessageConsumer |
createMessageConsumer()
Creates a MessageConsumer on this Destination using the current Session.
|
MessageProducer |
createMessageProducer(Session session,
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.
|
close, getContentFormat, getCount, getLoggerContext, getManager, getName, hasManager, log, logDebug, logError, logger, logWarn, narrow, release, stop, updateData
public static JmsManager getJmsManager(String name, Properties jndiProperties, String connectionFactoryName, String destinationName, String userName, char[] password, boolean immediateFail, long reconnectIntervalMillis)
name
- The name to use for this JmsManager.connectionFactoryName
- The binding name for the ConnectionFactory
.destinationName
- The binding name for the Destination
.userName
- The userName to connect with or null
for no authentication.password
- The password to use with the given userName or null
for no authentication.immediateFail
- Whether or not to fail immediately with a AppenderLoggingException
when connecting to JMS
fails.reconnectIntervalMillis
- How to log sleep in milliseconds before trying to reconnect to JMS.jndiProperties
- JNDI properties.public Message createMessage(Serializable object) throws JMSException
For instance, when using a text-based Layout
such as
PatternLayout
, the LogEvent
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.
object
- The LogEvent or String message to wrap.JMSException
- if the JMS provider fails to create a message due to some internal error.public MessageConsumer createMessageConsumer() throws JMSException
JMSException
- if the session fails to create a consumer due to some internal error.public MessageProducer createMessageProducer(Session session, Destination destination) throws JMSException
session
- The JMS Session to use to create the MessageProducerdestination
- The JMS Destination for the MessageProducerJMSException
- if the session fails to create a MessageProducer due to some internal error.public JmsManager.JmsManagerConfiguration getJmsManagerConfiguration()
protected boolean releaseSub(long timeout, TimeUnit timeUnit)
AbstractManager
releaseSub
in class AbstractManager
timeout
- timeouttimeUnit
- timeout time unitCopyright © 1999-2021 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.