@Subscribe
    public void publishClusterEvent(Object event) {
        if (event instanceof DeadEvent) {
            LOG.debug("Skipping DeadEvent on cluster event bus");
            return;
        }

        final String className = AutoValueUtils.getCanonicalName(event.getClass());
        final ClusterEvent clusterEvent = ClusterEvent.create(nodeId.getNodeId(), className, Collections.singleton(nodeId.getNodeId()), event);

        try {
            final String id = dbCollection.save(clusterEvent, WriteConcern.JOURNALED).getSavedId();
            // We are handling a locally generated event, so we can speed up processing by posting it to the local event
            // bus immediately. Due to having added the local node id to its list of consumers, it will not be picked up
            // by the db cursor again, avoiding double processing of the event. See #11263 for details.
            serverEventBus.post(event);
            LOG.debug("Published cluster event with ID <{}> and type <{}>", id, className);
        } catch (MongoException e) {
            LOG.error("Couldn't publish cluster event of type <" + className + ">", e);
        }
    }
@Test
    public void publishClusterEventHandlesAutoValueCorrectly() throws Exception {
        @SuppressWarnings("deprecation")
        DBCollection collection = mongoConnection.getDatabase().getCollection(ClusterEventPeriodical.COLLECTION_NAME);
        DebugEvent event = DebugEvent.create("Node ID", "Test");

        assertThat(collection.count()).isEqualTo(0L);

        clusterEventPeriodical.publishClusterEvent(event);

        verify(clusterEventBus, never()).post(any());
        assertThat(collection.count()).isEqualTo(1L);

        DBObject dbObject = collection.findOne();

        assertThat((String) dbObject.get("producer")).isEqualTo(nodeId.getNodeId());
        assertThat((String) dbObject.get("event_class")).isEqualTo(DebugEvent.class.getCanonicalName());
    }