Package org.forgerock.audit.handlers.jms
Class JmsAuditEventHandler
- java.lang.Object
-
- org.forgerock.audit.events.handlers.AuditEventHandlerBase
-
- org.forgerock.audit.handlers.jms.JmsAuditEventHandler
-
- All Implemented Interfaces:
AuditEventHandler,BatchConsumer
public class JmsAuditEventHandler extends AuditEventHandlerBase implements BatchConsumer
Publishes Audit events on a JMS Topic.
-
-
Field Summary
-
Fields inherited from class org.forgerock.audit.events.handlers.AuditEventHandlerBase
eventTopicsMetaData
-
-
Constructor Summary
Constructors Constructor Description JmsAuditEventHandler(JmsContextManager jmsContextManager, BatchPublisherFactory publisherFactory, JmsAuditEventHandlerConfiguration configuration, EventTopicsMetaData eventTopicsMetaData)Creates a new AuditEventHandler instance that publishes JMS messages on a JMS Topic for each Audit event.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddToBatch(String topic, JsonValue event, StringBuilder payload)Adds an audit event to a batch payload.Promise<Void,BatchException>publishBatch(String payload)Publishes the batch payload.Promise<ResourceResponse,ResourceException>publishEvent(Context context, String topic, JsonValue event)Publishes an event to the provided topic.Promise<QueryResponse,ResourceException>queryEvents(Context context, String topic, QueryRequest queryRequest, QueryResourceHandler queryResourceHandler)Returns NotSupportedException as query is not implemented for JMS.Promise<ResourceResponse,ResourceException>readEvent(Context context, String topic, String resourceId)Returns NotSupportedException as read is not implemented for JMS.voidshutdown()Closes the JMS connection.voidstartup()Creates the JMS Topic and ConnectionFactory from the context configuration settings and opens the JMS connection.-
Methods inherited from class org.forgerock.audit.events.handlers.AuditEventHandlerBase
getHandledTopics, getName, handleAction, isEnabled
-
-
-
-
Constructor Detail
-
JmsAuditEventHandler
@Inject public JmsAuditEventHandler(JmsContextManager jmsContextManager, BatchPublisherFactory publisherFactory, JmsAuditEventHandlerConfiguration configuration, EventTopicsMetaData eventTopicsMetaData) throws ResourceException
Creates a new AuditEventHandler instance that publishes JMS messages on a JMS Topic for each Audit event.- Parameters:
jmsContextManager- optional injectedJmsContextManager.publisherFactory- the batch publisher factory ornullconfiguration- Configuration parameters that can be adjusted by system administrators.eventTopicsMetaData- Meta-data for all audit event topics.- Throws:
ResourceException- If JMS connections cannot be established.
-
-
Method Detail
-
startup
public void startup() throws ResourceExceptionCreates the JMS Topic and ConnectionFactory from the context configuration settings and opens the JMS connection.- Specified by:
startupin interfaceAuditEventHandler- Throws:
ResourceException- if starting the AuditEventHandler fails
-
shutdown
public void shutdown() throws ResourceExceptionCloses the JMS connection.- Specified by:
shutdownin interfaceAuditEventHandler- Throws:
ResourceException- if closing the AuditEventHandler fails
-
queryEvents
public Promise<QueryResponse,ResourceException> queryEvents(Context context, String topic, QueryRequest queryRequest, QueryResourceHandler queryResourceHandler)
Returns NotSupportedException as query is not implemented for JMS.
Query some events from the provided topic.- Specified by:
queryEventsin interfaceAuditEventHandler- Parameters:
context- The context chain that initiated the event.topic- The topic on which query is performed.queryRequest- The request with the query.queryResourceHandler- The handler to process responses for the query.- Returns:
- NotSupportedException as query is not implemented for JMS.
-
readEvent
public Promise<ResourceResponse,ResourceException> readEvent(Context context, String topic, String resourceId)
Returns NotSupportedException as read is not implemented for JMS.
Reads an event with the provided resource id from the provided topic.- Specified by:
readEventin interfaceAuditEventHandler- Parameters:
context- The context chain that initiated the event.topic- The topic where event is read.resourceId- The identifier of the event.- Returns:
- NotSupportedException as read is not implemented for JMS.
-
publishEvent
public Promise<ResourceResponse,ResourceException> publishEvent(Context context, String topic, JsonValue event)
Description copied from interface:AuditEventHandlerPublishes an event to the provided topic.Note for implementors, it is imperative that the supplied
eventis not modified in any way as this may cause undesirable behaviour where multiple handlers are configured. If theeventmust be modified, then make a copy of it and work with that.- Specified by:
publishEventin interfaceAuditEventHandler- Parameters:
context- The context chain that initiated the event.topic- The topic where to publish the event.event- The event to publish - which should be considered immutable.- Returns:
- a promise with either a response or an exception
-
addToBatch
public void addToBatch(String topic, JsonValue event, StringBuilder payload) throws BatchException
Description copied from interface:BatchConsumerAdds an audit event to a batch payload.- Specified by:
addToBatchin interfaceBatchConsumer- Parameters:
topic- event topicevent- event JSON payloadpayload- batch payload- Throws:
BatchException- indicates failure to add-to-batch
-
publishBatch
public Promise<Void,BatchException> publishBatch(String payload)
Description copied from interface:BatchConsumerPublishes the batch payload.- Specified by:
publishBatchin interfaceBatchConsumer- Parameters:
payload- batch payload- Returns:
- a simple promise encapsulating any potential batch exception
-
-