org.alfresco.bm.event.mongo
Class MongoEventService

java.lang.Object
  extended by org.alfresco.bm.event.AbstractEventService
      extended by org.alfresco.bm.event.mongo.MongoEventService
All Implemented Interfaces:
EventService

public class MongoEventService
extends AbstractEventService

An EventService MongoDB collection

Since:
1.0
Author:
Derek Hulley

Constructor Summary
MongoEventService(org.springframework.data.mongodb.core.MongoTemplate mongo, String collection)
          Construct a provider that works using the given Mongo instance and collection name.
 
Method Summary
 long count()
           
 boolean deleteEvent(Event event)
          Delete an event from the provider.
 List<Event> findEvents(String name, int skip, int limit)
          Find any event matching the given name, using the paging criteria
 Event getEvent(String id)
          Fetch a specific event by unique ID
 Event lockEvent(Event event, String lockOwner)
          Lock an event for processing by the given owner
 Event nextEvent(String dataOwner, long latestScheduledTime, long latestQueueTime)
          Retrieve the next event in the queue.
 Event putEvent(Event event)
          Adds an event to the provider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MongoEventService

public MongoEventService(org.springframework.data.mongodb.core.MongoTemplate mongo,
                         String collection)
Construct a provider that works using the given Mongo instance and collection name.

Parameters:
mongo - the MongoDB template to use
collection - the name of the MongoDB collection
Method Detail

count

public long count()
Returns:
Returns the number of events in the queue

findEvents

public List<Event> findEvents(String name,
                              int skip,
                              int limit)
Description copied from interface: EventService
Find any event matching the given name, using the paging criteria

Parameters:
name - find events with the given name
skip - the number of results to skip
limit - the maximum number of results to retrieve
Returns:
an event or null if not found

nextEvent

public Event nextEvent(String dataOwner,
                       long latestScheduledTime,
                       long latestQueueTime)
Retrieve the next event in the queue.

This method must update the event queue time to the current time atomically.

Parameters:
dataOwner - the identifier of the client queuing events
latestQueueTime - the event scheduled time must not be greater than this
Returns:
Returns the next event in the queue or null

lockEvent

public Event lockEvent(Event event,
                       String lockOwner)
Lock an event for processing by the given owner

Parameters:
event - the event to lock
lockOwner - the lock owner
Returns:
Returns the locked event or null if it could not be locked.

getEvent

public Event getEvent(String id)
Description copied from interface: EventService
Fetch a specific event by unique ID

Parameters:
id - the event ID
Returns:
the event or null if not found

deleteEvent

public boolean deleteEvent(Event event)
Description copied from interface: EventService
Delete an event from the provider. This can be done after the event has been fully processed and there is no further requirement for it.

NOTE: The data cannot be accessed after this event.

Parameters:
event - the event to delete
Returns:
true if the event was deleted otherwise false

putEvent

public Event putEvent(Event event)
Description copied from interface: EventService
Adds an event to the provider. This is done to populate the queue with a new event to be processed.

Parameters:
event - the event to add (the event ID must be null


Copyright © 2012. All Rights Reserved.