Omaha #2760 Made external JMS route for registry events
Change-Id: I8ff1af48468896dadd41bdcf8a6e6e7bc24c9eb6 Former-commit-id: 22e51bc1f882c535c7bafcdfd84428700eb6e547
This commit is contained in:
parent
dbf301b8c4
commit
0d1767a3d7
7 changed files with 255 additions and 18 deletions
|
@ -3,5 +3,6 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="resources"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
||||
.,\
|
||||
resources/
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
# Registry event external publish
|
||||
registry.event.external.publish=false
|
||||
# Registry event external publish uri
|
||||
registry.event.external.publish.uri=jms-generic:topic:registryExternalPublishTopic
|
|
@ -1,6 +1,7 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
|
||||
|
||||
<bean factory-bean="eventBus" factory-method="register">
|
||||
<constructor-arg ref="RegistrySubscriptionManager" />
|
||||
|
@ -14,7 +15,36 @@
|
|||
<constructor-arg ref="AuditableEventService" />
|
||||
</bean>
|
||||
|
||||
<bean factory-bean="eventBus" factory-method="register">
|
||||
<bean factory-bean="eventBus" factory-method="register">
|
||||
<constructor-arg ref="RegistryGarbageCollector" />
|
||||
</bean>
|
||||
|
||||
<!-- TODO: This is a sample external endpoint for registry events.
|
||||
It is dormant as long as the ${registry.event.external.publish} prop
|
||||
is set to false. Which by default until Hazard Services uses this, will be.
|
||||
When Hazard Services comes on line, the sampleExternalMessageHandler and the
|
||||
route can go away. -->
|
||||
|
||||
<bean id="sampleExternalMessageHandler"
|
||||
class="com.raytheon.uf.edex.registry.ebxml.publish.SampleExternalMessageHandler">
|
||||
</bean>
|
||||
|
||||
<camelContext id="externalRegistryEventDelivery-camel"
|
||||
xmlns="http://camel.apache.org/schema/spring" errorHandlerRef="errorHandler">
|
||||
<endpoint id="externalRegistryEventDelivery"
|
||||
uri="jms-generic:topic:registryExternalPublishTopic" />
|
||||
<route id="registryExternalPublishTopic">
|
||||
<from ref="externalRegistryEventDelivery" />
|
||||
<doTry>
|
||||
<pipeline>
|
||||
<bean ref="serializationUtil" method="transformFromThrift"/>
|
||||
<bean ref="sampleExternalMessageHandler" method="notify" />
|
||||
</pipeline>
|
||||
<doCatch>
|
||||
<exception>java.lang.Throwable</exception>
|
||||
<to uri="log:externalRegistryEventDelivery?level=ERROR" />
|
||||
</doCatch>
|
||||
</doTry>
|
||||
</route>
|
||||
</camelContext>
|
||||
</beans>
|
|
@ -0,0 +1,128 @@
|
|||
package com.raytheon.uf.edex.registry.ebxml.publish;
|
||||
|
||||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
|
||||
import com.raytheon.uf.common.event.Event;
|
||||
import com.raytheon.uf.common.event.EventBus;
|
||||
import com.raytheon.uf.common.registry.event.RegistryEvent;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.edex.core.EDEXUtil;
|
||||
import com.raytheon.uf.edex.core.EdexException;
|
||||
|
||||
/**
|
||||
*
|
||||
* Publish Registry events
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* June 25, 2014 2760 dhladky Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class PublishRegistryEvent {
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(PublishRegistryEvent.class);
|
||||
|
||||
/** static instance **/
|
||||
public static PublishRegistryEvent instance = null;
|
||||
|
||||
/** allow external publish of registry events **/
|
||||
private final boolean externalPublish;
|
||||
|
||||
/** URI to send events to, this could be another queue, topic, etc **/
|
||||
public final String externalUri;
|
||||
|
||||
private PublishRegistryEvent() {
|
||||
|
||||
externalPublish = Boolean.parseBoolean(System.getProperty("registry.event.external.publish"));
|
||||
externalUri = System.getProperty("registry.event.external.publish.uri");
|
||||
|
||||
statusHandler.info("Registry configured to publish events externally: "+externalPublish);
|
||||
|
||||
if (externalPublish) {
|
||||
statusHandler.info("External URI: "+externalUri);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Static for speed
|
||||
* @return
|
||||
*/
|
||||
public static PublishRegistryEvent getInstance() {
|
||||
|
||||
if (instance == null) {
|
||||
instance = new PublishRegistryEvent();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish registry event, general method.
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
public void publish(Event event) {
|
||||
|
||||
if (instance.externalPublish) {
|
||||
try {
|
||||
// filter out internal audit trail, statistics, etc
|
||||
if (event instanceof RegistryEvent) {
|
||||
publishExternal(event);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
statusHandler.error("Can't send event to external URI!: "
|
||||
+ instance.externalUri, e);
|
||||
}
|
||||
}
|
||||
|
||||
// local publish as usual
|
||||
EventBus.publish(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish registry events to an external route
|
||||
*
|
||||
* @param event
|
||||
* @throws EdexException
|
||||
* @throws SerializationException
|
||||
*/
|
||||
private void publishExternal(Event event) throws Exception {
|
||||
|
||||
if (event != null) {
|
||||
byte[] bytes = SerializationUtil.transformToThrift(event);
|
||||
EDEXUtil.getMessageProducer().sendAsyncUri(instance.externalUri, bytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.raytheon.uf.edex.registry.ebxml.publish;
|
||||
|
||||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
|
||||
import com.raytheon.uf.common.registry.event.RegistryEvent;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
||||
/**
|
||||
*
|
||||
* Sample External Registry Event Handler
|
||||
*
|
||||
* This is a sample class only here to prove external delivery of registry messages.
|
||||
* When an actual handler is created this can go away along with it's supporting spring.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* June 25, 2014 2760 dhladky Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class SampleExternalMessageHandler {
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(SampleExternalMessageHandler.class);
|
||||
|
||||
// default pub constuctor
|
||||
public SampleExternalMessageHandler() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify of arrival on the JMS route specified in spring
|
||||
* @param RegistryEvent
|
||||
*/
|
||||
public void notify(RegistryEvent event) {
|
||||
|
||||
if (event != null) {
|
||||
statusHandler.info("Received Registry event externally: "+event.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -52,7 +52,6 @@ import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryResponseType;
|
|||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.raytheon.uf.common.event.EventBus;
|
||||
import com.raytheon.uf.common.registry.constants.ActionTypes;
|
||||
import com.raytheon.uf.common.registry.constants.AssociationTypes;
|
||||
import com.raytheon.uf.common.registry.constants.DeletionScope;
|
||||
|
@ -73,6 +72,7 @@ import com.raytheon.uf.common.util.CollectionUtil;
|
|||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectDao;
|
||||
import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
|
||||
import com.raytheon.uf.edex.registry.ebxml.publish.PublishRegistryEvent;
|
||||
import com.raytheon.uf.edex.registry.ebxml.services.cataloger.CatalogerImpl;
|
||||
import com.raytheon.uf.edex.registry.ebxml.services.query.QueryManagerImpl;
|
||||
import com.raytheon.uf.edex.registry.ebxml.services.validator.ValidatorImpl;
|
||||
|
@ -113,6 +113,7 @@ import com.raytheon.uf.edex.registry.events.DeleteSlotEvent;
|
|||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
* 4/11/2014 3011 bphillip Modified merge behavior
|
||||
* 4/17/2014 3011 bphillip Delete slot events now contain strings
|
||||
* June 25, 2014 2760 dhladky Added external delivery of registry events
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
|
@ -153,6 +154,9 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
private RegistryObjectDao registryObjectDao;
|
||||
|
||||
private RegistryXPathProcessor xpathProcessor;
|
||||
|
||||
/** publishes registry events **/
|
||||
private PublishRegistryEvent publisher = PublishRegistryEvent.getInstance();
|
||||
|
||||
/**
|
||||
* The Remove Objects protocol allows a client to remove or delete one or
|
||||
|
@ -300,15 +304,15 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
event.setAction(Action.DELETE);
|
||||
event.setLid(obj.getLid());
|
||||
event.setObjectType(objectType);
|
||||
EventBus.publish(event);
|
||||
publisher.publish(event);
|
||||
}
|
||||
DeleteSlotEvent deleteEvent = new DeleteSlotEvent(obj.getSlot());
|
||||
EventBus.publish(deleteEvent);
|
||||
EventBus.publish(new RegistryStatisticsEvent(obj.getObjectType(),
|
||||
publisher.publish(deleteEvent);
|
||||
publisher.publish(new RegistryStatisticsEvent(obj.getObjectType(),
|
||||
obj.getStatus(), obj.getOwner(), avTimePerRecord));
|
||||
}
|
||||
|
||||
EventBus.publish(new CreateAuditTrailEvent(request.getId(), request,
|
||||
publisher.publish(new CreateAuditTrailEvent(request.getId(), request,
|
||||
ActionTypes.delete, objectsToRemove, TimeUtil
|
||||
.currentTimeMillis()));
|
||||
|
||||
|
@ -474,24 +478,24 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
long currentTime = TimeUtil.currentTimeMillis();
|
||||
if (!objsCreated.isEmpty()) {
|
||||
for (RegistryObjectType obj : objsCreated) {
|
||||
EventBus.publish(new InsertRegistryEvent(obj.getId(), obj
|
||||
publisher.publish(new InsertRegistryEvent(obj.getId(), obj
|
||||
.getLid(), request.getUsername(), obj.getObjectType()));
|
||||
EventBus.publish(new RegistryStatisticsEvent(obj
|
||||
publisher.publish(new RegistryStatisticsEvent(obj
|
||||
.getObjectType(), obj.getStatus(), obj.getOwner(),
|
||||
avTimePerRecord));
|
||||
}
|
||||
EventBus.publish(new CreateAuditTrailEvent(request.getId(),
|
||||
publisher.publish(new CreateAuditTrailEvent(request.getId(),
|
||||
request, ActionTypes.create, objsCreated, currentTime));
|
||||
}
|
||||
if (!objsUpdated.isEmpty()) {
|
||||
for (RegistryObjectType obj : objsUpdated) {
|
||||
EventBus.publish(new UpdateRegistryEvent(obj.getId(), obj
|
||||
publisher.publish(new UpdateRegistryEvent(obj.getId(), obj
|
||||
.getLid(), request.getUsername(), obj.getObjectType()));
|
||||
EventBus.publish(new RegistryStatisticsEvent(obj
|
||||
publisher.publish(new RegistryStatisticsEvent(obj
|
||||
.getObjectType(), obj.getStatus(), obj.getOwner(),
|
||||
avTimePerRecord));
|
||||
}
|
||||
EventBus.publish(new CreateAuditTrailEvent(request.getId(),
|
||||
publisher.publish(new CreateAuditTrailEvent(request.getId(),
|
||||
request, ActionTypes.update, objsUpdated, currentTime));
|
||||
}
|
||||
|
||||
|
@ -746,7 +750,7 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
mergeObjects(updatedObject, objToUpdate);
|
||||
}
|
||||
if (!objectsToUpdate.isEmpty()) {
|
||||
EventBus.publish(new CreateAuditTrailEvent(request.getId(),
|
||||
publisher.publish(new CreateAuditTrailEvent(request.getId(),
|
||||
request, ActionTypes.update, objectsToUpdate, TimeUtil
|
||||
.currentTimeMillis()));
|
||||
}
|
||||
|
@ -762,7 +766,7 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
RegistryObjectType existingObject) {
|
||||
DeleteSlotEvent deleteSlotEvent = new DeleteSlotEvent(existingObject.getSlot());
|
||||
registryObjectDao.merge(newObject, existingObject);
|
||||
EventBus.publish(deleteSlotEvent);
|
||||
publisher.publish(deleteSlotEvent);
|
||||
}
|
||||
|
||||
private RegistryObjectType applyUpdates(RegistryObjectType objectToUpdate,
|
||||
|
@ -858,5 +862,5 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
public void setXpathProcessor(RegistryXPathProcessor xpathProcessor) {
|
||||
this.xpathProcessor = xpathProcessor;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue