Package org.apache.openjpa.event
Class JMSRemoteCommitProvider
- java.lang.Object
-
- org.apache.openjpa.event.AbstractRemoteCommitProvider
-
- org.apache.openjpa.event.JMSRemoteCommitProvider
-
- All Implemented Interfaces:
jakarta.jms.ExceptionListener,RemoteCommitProvider,Configurable,GenericConfigurable,Closeable
public class JMSRemoteCommitProvider extends AbstractRemoteCommitProvider implements Configurable, GenericConfigurable, jakarta.jms.ExceptionListener
JMS-based implementation ofRemoteCommitProviderthat listens for object modifications and propagates those changes to other RemoteCommitProviders over a JMS topic.- Since:
- 0.2.5.0
- Author:
- Patrick Linskey
-
-
Field Summary
-
Fields inherited from class org.apache.openjpa.event.AbstractRemoteCommitProvider
eventManager, log
-
-
Constructor Summary
Constructors Constructor Description JMSRemoteCommitProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbroadcast(RemoteCommitEvent event)Notifies other remote event managers in this JVM and on other machines of changes to the cache.voidclose()Free the resources used by this provider.protected voidconnect()protected jakarta.jms.MessagecreateMessage(RemoteCommitEvent event)Returns a newMessageto send to the topic.voidendConfiguration()Subclasses that need to perform actions inConfigurable.endConfiguration()must invoke this method.protected jakarta.jms.MessageListenergetMessageListener()protected ContextnewContext()Returns a newContextobject for use by this provider.voidonException(jakarta.jms.JMSException ex)voidsetExceptionReconnectAttempts(int attempts)The number of times to attempt to reconnect after a JMS send exception is detected.voidsetInto(Options opts)Set a map of properties to pass to theInitialContextconstructor for JNDI lookups.voidsetTopic(String name)Sets the JMS Topic name.voidsetTopicConnectionFactory(String name)Sets the JMS TopicConnectionFactory name.-
Methods inherited from class org.apache.openjpa.event.AbstractRemoteCommitProvider
fireEvent, setConfiguration, setRemoteCommitEventManager, startConfiguration
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.openjpa.lib.conf.Configurable
setConfiguration, startConfiguration
-
-
-
-
Method Detail
-
setTopic
public void setTopic(String name)
Sets the JMS Topic name. Defaults totopic/OpenJPACommitProviderTopic.
-
setTopicConnectionFactory
public void setTopicConnectionFactory(String name)
Sets the JMS TopicConnectionFactory name. Defaults tojava:/ConnectionFactory.
-
setExceptionReconnectAttempts
public void setExceptionReconnectAttempts(int attempts)
The number of times to attempt to reconnect after a JMS send exception is detected. Defaults to 0, meaning no attempt to reconnect is made; the exception is logged and ignored.
-
setInto
public void setInto(Options opts)
Set a map of properties to pass to theInitialContextconstructor for JNDI lookups. Implementation ofGenericConfigurable.- Specified by:
setIntoin interfaceGenericConfigurable
-
newContext
protected Context newContext() throws NamingException
Returns a newContextobject for use by this provider.- Throws:
NamingException
-
broadcast
public void broadcast(RemoteCommitEvent event)
Description copied from interface:RemoteCommitProviderNotifies other remote event managers in this JVM and on other machines of changes to the cache. This method must not notify the event manager associated with the broker that originated this commit.- Specified by:
broadcastin interfaceRemoteCommitProvider
-
close
public void close()
Description copied from interface:RemoteCommitProviderFree the resources used by this provider.- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceRemoteCommitProvider
-
endConfiguration
public void endConfiguration()
Subclasses that need to perform actions inConfigurable.endConfiguration()must invoke this method.- Specified by:
endConfigurationin interfaceConfigurable- Overrides:
endConfigurationin classAbstractRemoteCommitProvider
-
connect
protected void connect()
-
getMessageListener
protected jakarta.jms.MessageListener getMessageListener()
-
createMessage
protected jakarta.jms.Message createMessage(RemoteCommitEvent event) throws jakarta.jms.JMSException
Returns a newMessageto send to the topic. This implementation creates anObjectMessage.- Throws:
jakarta.jms.JMSException
-
onException
public void onException(jakarta.jms.JMSException ex)
- Specified by:
onExceptionin interfacejakarta.jms.ExceptionListener
-
-