org.openanzo.server.repository.publisher
Class EventPublisher

java.lang.Object
  extended by org.openanzo.server.repository.publisher.EventPublisher
All Implemented Interfaces:
javax.jms.ExceptionListener, IServerService, IServerServiceMBean, EventPublisherMBean, UpdateResultListener

public class EventPublisher
extends java.lang.Object
implements UpdateResultListener, javax.jms.ExceptionListener, IServerService, EventPublisherMBean

This class manages a connection to a publish/subscribe broker cloud. Nodes use an event publisher to handle server reconnects, message overflow, and to share a single connection across plugins.

Author:
Christopher R. Vincent

Field Summary
static int QUEUE_SIZE_DEFAULT
          The default number of events to queue for publication before discarding old messages.
 
Constructor Summary
EventPublisher(ModelServiceApi modelServiceApi, java.util.Properties properties)
          Create a new EventPublisher
 
Method Summary
 void close()
          Close the service
 void disconnect()
          Disconnect the event publisher from the JMS server
 void flushQueue()
          Flush the contents of the publish queue
 boolean getIsStarted()
          Return if the event publisher was started
 java.lang.String getJmsHost()
          Get the JMS hostname
 java.lang.String getJmsJndiConnectionFactory()
          Get the JNDI name of the Connection Factory
 java.lang.String getJmsJndiUpdateQueueName()
          Get the JNDI name of the UpdateQueue
 java.lang.String getJmsPassword()
          Get the JMS password
 int getJmsPort()
          Get the JMS port
 java.lang.String getJmsProviderClass()
          Get the name of the JmsProvider class
 java.lang.String getJmsUpdateQueueName()
          Get the name of the UpdateQueue
 java.lang.String getJmsUser()
          Get the JMS user name
 int getMaxQueueSize()
          Get the current size of the event publication queue.
 boolean getPublishUpdateEvents()
          Determine if the service is set to publish update events
 javax.jms.Destination getQueue(java.lang.String topicName)
          Get or create a Destination for given topicName
 int getQueueSize()
          Get the number of message on the publish queue
 void onException(javax.jms.JMSException exception)
           
 void publish(java.util.Map<java.lang.String,java.lang.Object> properties, byte[] bytes)
          Publish the specified properties as a new event.
 void registerMBean(javax.management.MBeanServer mbs, javax.management.ObjectName parentObjectName)
          Register the service with the server's jmx server
 void setJmsHost(java.lang.String host)
          Set the JMS host name
 void setJmsJndiConnectionFactoryName(java.lang.String jndiConnectionFactoryName)
          Set the JNDI name of the connection factory
 void setJmsJndiUpdateQueueName(java.lang.String jndiUpdateQueueName)
          Set the JNDI name of the UpdateQueue
 void setJmsPassword(java.lang.String password)
          Set the JMS password
 void setJmsPort(int port)
          Set the JMS port
 void setJmsProviderClass(java.lang.String providerClass)
          Set the class name of the JMS Provider
 void setJmsUpdateQueueName(java.lang.String updateQueue)
          Set the name of the Update Queue
 void setJmsUser(java.lang.String name)
          Set the JMS user name
 void setMaxQueueSize(int queueSize)
          Set the max size of the publish queue
 void setPublishUpdateEvents(boolean publishUpdateEvents)
          Set if the service is set to publish update events
 void setQueueSize(int size)
          Sets the size of the event publication queue.
 void start()
          Start publishing events.
 void stop()
          Stop the service
 void updateComplete(UpdateResults results, RepositoryConnection repositoryConnection)
          Handles the updateComplete event.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QUEUE_SIZE_DEFAULT

public static int QUEUE_SIZE_DEFAULT
The default number of events to queue for publication before discarding old messages.

Constructor Detail

EventPublisher

public EventPublisher(ModelServiceApi modelServiceApi,
                      java.util.Properties properties)
Create a new EventPublisher

Parameters:
modelServiceApi - ModelServiceApi to get ContainerConnectionPool
properties - Configuration properties
Method Detail

start

public void start()
Start publishing events.

Specified by:
start in interface IServerService
Specified by:
start in interface IServerServiceMBean

stop

public void stop()
          throws AnzoException
Description copied from interface: IServerService
Stop the service

Specified by:
stop in interface IServerService
Specified by:
stop in interface IServerServiceMBean
Throws:
AnzoException

close

public void close()
           throws AnzoException
Description copied from interface: IServerService
Close the service

Specified by:
close in interface IServerService
Throws:
AnzoException

getQueue

public javax.jms.Destination getQueue(java.lang.String topicName)
                               throws javax.jms.JMSException
Get or create a Destination for given topicName

Parameters:
topicName - TopicName for Destination to retrieve
Returns:
Destination from already created destinations, or new Destination created
Throws:
javax.jms.JMSException

disconnect

public void disconnect()
Disconnect the event publisher from the JMS server


getMaxQueueSize

public int getMaxQueueSize()
Get the current size of the event publication queue.

Specified by:
getMaxQueueSize in interface EventPublisherMBean
Returns:
Size of event publication queue

getIsStarted

public boolean getIsStarted()
Return if the event publisher was started

Specified by:
getIsStarted in interface IServerService
Specified by:
getIsStarted in interface IServerServiceMBean
Returns:
true if the event publisher is started.

onException

public void onException(javax.jms.JMSException exception)
Specified by:
onException in interface javax.jms.ExceptionListener

publish

public void publish(java.util.Map<java.lang.String,java.lang.Object> properties,
                    byte[] bytes)
Publish the specified properties as a new event.

Parameters:
properties - map of Stringproperty name to one of the supported JMS property value types.
bytes - byte data for message body

setQueueSize

public void setQueueSize(int size)
                  throws java.lang.IllegalArgumentException
Sets the size of the event publication queue.

Parameters:
size - new queue size.
Throws:
java.lang.IllegalArgumentException - if size is less than one.

updateComplete

public void updateComplete(UpdateResults results,
                           RepositoryConnection repositoryConnection)
                    throws AnzoException
Description copied from interface: UpdateResultListener
Handles the updateComplete event.

Specified by:
updateComplete in interface UpdateResultListener
Parameters:
results - Final state and other useful details of statements added/updated/removed during a update call.
repositoryConnection - The repository graph the update was run against.
Throws:
AnzoException

registerMBean

public void registerMBean(javax.management.MBeanServer mbs,
                          javax.management.ObjectName parentObjectName)
Description copied from interface: IServerService
Register the service with the server's jmx server

Specified by:
registerMBean in interface IServerService
Parameters:
mbs - the jmx server
parentObjectName - the name under which this object will be registered

flushQueue

public void flushQueue()
Description copied from interface: EventPublisherMBean
Flush the contents of the publish queue

Specified by:
flushQueue in interface EventPublisherMBean

getJmsJndiConnectionFactory

public java.lang.String getJmsJndiConnectionFactory()
Description copied from interface: EventPublisherMBean
Get the JNDI name of the Connection Factory

Specified by:
getJmsJndiConnectionFactory in interface EventPublisherMBean
Returns:
the JNDI name of the Connection Factory

getJmsJndiUpdateQueueName

public java.lang.String getJmsJndiUpdateQueueName()
Description copied from interface: EventPublisherMBean
Get the JNDI name of the UpdateQueue

Specified by:
getJmsJndiUpdateQueueName in interface EventPublisherMBean
Returns:
the JNDI name of the UpdateQueue

getJmsPassword

public java.lang.String getJmsPassword()
Description copied from interface: EventPublisherMBean
Get the JMS password

Specified by:
getJmsPassword in interface EventPublisherMBean
Returns:
the JMS password

getJmsProviderClass

public java.lang.String getJmsProviderClass()
Description copied from interface: EventPublisherMBean
Get the name of the JmsProvider class

Specified by:
getJmsProviderClass in interface EventPublisherMBean
Returns:
the name of the JmsProvider class

getJmsUpdateQueueName

public java.lang.String getJmsUpdateQueueName()
Description copied from interface: EventPublisherMBean
Get the name of the UpdateQueue

Specified by:
getJmsUpdateQueueName in interface EventPublisherMBean
Returns:
the name of the UpdateQueue

getJmsUser

public java.lang.String getJmsUser()
Description copied from interface: EventPublisherMBean
Get the JMS user name

Specified by:
getJmsUser in interface EventPublisherMBean
Returns:
the JMS user name

getPublishUpdateEvents

public boolean getPublishUpdateEvents()
Description copied from interface: EventPublisherMBean
Determine if the service is set to publish update events

Specified by:
getPublishUpdateEvents in interface EventPublisherMBean
Returns:
true if the service is set to publish update events

getQueueSize

public int getQueueSize()
Description copied from interface: EventPublisherMBean
Get the number of message on the publish queue

Specified by:
getQueueSize in interface EventPublisherMBean
Returns:
the number of message on the publish queueF

setJmsJndiConnectionFactoryName

public void setJmsJndiConnectionFactoryName(java.lang.String jndiConnectionFactoryName)
Description copied from interface: EventPublisherMBean
Set the JNDI name of the connection factory

Specified by:
setJmsJndiConnectionFactoryName in interface EventPublisherMBean
Parameters:
jndiConnectionFactoryName - the JNDI name of the connection factory

setJmsJndiUpdateQueueName

public void setJmsJndiUpdateQueueName(java.lang.String jndiUpdateQueueName)
Description copied from interface: EventPublisherMBean
Set the JNDI name of the UpdateQueue

Specified by:
setJmsJndiUpdateQueueName in interface EventPublisherMBean
Parameters:
jndiUpdateQueueName - the JNDI name of the UpdateQueue

setJmsPassword

public void setJmsPassword(java.lang.String password)
Description copied from interface: EventPublisherMBean
Set the JMS password

Specified by:
setJmsPassword in interface EventPublisherMBean
Parameters:
password - the JMS password

setJmsProviderClass

public void setJmsProviderClass(java.lang.String providerClass)
Description copied from interface: EventPublisherMBean
Set the class name of the JMS Provider

Specified by:
setJmsProviderClass in interface EventPublisherMBean
Parameters:
providerClass - the class name of the JMS Provider

setJmsUpdateQueueName

public void setJmsUpdateQueueName(java.lang.String updateQueue)
Description copied from interface: EventPublisherMBean
Set the name of the Update Queue

Specified by:
setJmsUpdateQueueName in interface EventPublisherMBean
Parameters:
updateQueue - the name of the Update Queue

setJmsUser

public void setJmsUser(java.lang.String name)
Description copied from interface: EventPublisherMBean
Set the JMS user name

Specified by:
setJmsUser in interface EventPublisherMBean
Parameters:
name - the JMS user name

setMaxQueueSize

public void setMaxQueueSize(int queueSize)
Description copied from interface: EventPublisherMBean
Set the max size of the publish queue

Specified by:
setMaxQueueSize in interface EventPublisherMBean
Parameters:
queueSize - max size of the publish queue

setPublishUpdateEvents

public void setPublishUpdateEvents(boolean publishUpdateEvents)
Description copied from interface: EventPublisherMBean
Set if the service is set to publish update events

Specified by:
setPublishUpdateEvents in interface EventPublisherMBean
Parameters:
publishUpdateEvents - if the service is set to publish update events

getJmsHost

public java.lang.String getJmsHost()
Description copied from interface: EventPublisherMBean
Get the JMS hostname

Specified by:
getJmsHost in interface EventPublisherMBean
Returns:
the JMS hostname

getJmsPort

public int getJmsPort()
Description copied from interface: EventPublisherMBean
Get the JMS port

Specified by:
getJmsPort in interface EventPublisherMBean
Returns:
the JMS port

setJmsHost

public void setJmsHost(java.lang.String host)
Description copied from interface: EventPublisherMBean
Set the JMS host name

Specified by:
setJmsHost in interface EventPublisherMBean
Parameters:
host - the JMS host name

setJmsPort

public void setJmsPort(int port)
Description copied from interface: EventPublisherMBean
Set the JMS port

Specified by:
setJmsPort in interface EventPublisherMBean
Parameters:
port - the JMS port


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.