This repository was archived by the owner on Aug 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
JsonEnvelope Cookbook
allanmckenzie edited this page Sep 29, 2016
·
11 revisions
import static uk.gov.justice.services.messaging.DefaultJsonEnvelope.envelopeFrom;
import static uk.gov.justice.services.messaging.JsonObjectMetadata.metadataWithRandomUUID;
final UUID correlationId = randomUUID();
final UUID sessionId = randomUUID();
final UUID userId = randomUUID();
final UUID streamId = randomUUID();
final String commandName = "notification-added";
final JsonObject payload = createObjectBuilder()
.add("exampleField", "Example Value")
.build();
final JsonEnvelope command = envelopeFrom(
metadataWithRandomUUID(commandName)
.withClientCorrelationId(correlationId.toString())
.withSessionId(sessionId.toString())
.withUserId(userId.toString())
.withStreamId(streamId)
.build(),
payload
);