/** * Publish finish events for each of the specified query labels * * <pre> * {@code * LabelledEvents.start("get", 1l, bus, "typeA", "custom"); try { return "ok"; } finally { RequestEvents.finish("get", 1l, bus, "typeA", "custom"); } * * } * </pre> * * * @param query Completed query * @param correlationId Identifier * @param bus EventBus to post events to * @param labels Query types to post to event bus */ public static <T> void finish(T query, long correlationId, EventBus bus, String... labels) { for (String type : labels) { RemoveLabelledQuery<T> next = finish(query, correlationId, type); bus.post(next); } } /**
/** * Marks the start of a query identified by the provided correlationId, with additional query type and data parameters * * @param query - Query data * @param correlationId - Identifier * @param label - allows queries to be grouped by label * @return Start event to pass to the Events systems EventBus */ public static <T> AddLabelledQuery<T> start(T query, long correlationId, String label) { return start(query, correlationId, label, null); }
/** * Publish start events for each of the specified query types * * <pre> * {@code LabelledEvents.start("get", 1l, bus, "typeA", "custom"); try { return "ok"; } finally { RequestEvents.finish("get", 1l, bus, "typeA", "custom"); } * } * </pre> * * @param query Completed query * @param correlationId Identifier * @param bus EventBus to post events to * @param labels Query labels to post to event bus */ public static <T> void start(T query, long correlationId, EventBus bus, String... labels) { for (String label : labels) { AddLabelledQuery<T> next = start(query, correlationId, label, null); bus.post(next); } }
@Test public void createRemoveLabelledQuery() { RemoveLabelledQuery<String> userQuery = LabelledEvents.finish(query, corrId, label); RequestData<String> rd = userQuery.getData(); assertThat(rd.getQuery(), is(query)); assertThat(rd.getType(), is(label)); assertThat(rd.getCorrelationId(), is(corrId)); } }
@Test public void createAddLabelledQuery() { AddLabelledQuery<String> userQuery = LabelledEvents.start(query, corrId, label); RequestData rd = userQuery.getData(); assertThat(rd.getQuery(), is(query)); assertThat(rd.getType(), is(label)); assertThat(rd.getCorrelationId(), is(corrId)); }
/** * Publish finish events for each of the specified query labels * * <pre> * {@code * LabelledEvents.start("get", 1l, bus, "typeA", "custom"); try { return "ok"; } finally { RequestEvents.finish("get", 1l, bus, "typeA", "custom"); } * * } * </pre> * * * @param query Completed query * @param correlationId Identifier * @param bus EventBus to post events to * @param labels Query types to post to event bus */ public static <T> void finish(T query, long correlationId, EventBus bus, String... labels) { for (String type : labels) { RemoveLabelledQuery<T> next = finish(query, correlationId, type); bus.post(next); } } /**
@Test public void createAddLabelledQueryWithAdditionalData() { AddLabelledQuery<String> userQuery = LabelledEvents.start(query, corrId, label, addData); RequestData rd = userQuery.getData(); assertThat(rd.getQuery(), is(query)); assertThat(rd.getType(), is(label)); assertThat(rd.getCorrelationId(), is(corrId)); assertThat(rd.getAdditionalData(), is(addData)); }
/** * Marks the start of a query identified by the provided correlationId, with additional query type and data parameters * * @param query - Query data * @param correlationId - Identifier * @param label - allows queries to be grouped by label * @return Start event to pass to the Events systems EventBus */ public static <T> AddLabelledQuery<T> start(T query, long correlationId, String label) { return start(query, correlationId, label, null); }
/** * Publish start events for each of the specified query types * * <pre> * {@code LabelledEvents.start("get", 1l, bus, "typeA", "custom"); try { return "ok"; } finally { RequestEvents.finish("get", 1l, bus, "typeA", "custom"); } * } * </pre> * * @param query Completed query * @param correlationId Identifier * @param bus EventBus to post events to * @param labels Query labels to post to event bus */ public static <T> void start(T query, long correlationId, EventBus bus, String... labels) { for (String label : labels) { AddLabelledQuery<T> next = start(query, correlationId, label, null); bus.post(next); } }