Skip to content
This repository was archived by the owner on Aug 13, 2020. It is now read-only.

JsonEnvelope Cookbook

Jacek Obarymski edited this page Sep 30, 2016 · 11 revisions

To create a full JsonEnvelope

import static uk.gov.justice.services.messaging.DefaultJsonEnvelope.envelope;
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 JsonEnvelope command = envelope()
             .with(metadataWithRandomUUID(commandName)
                    .withClientCorrelationId(correlationId.toString())
                    .withSessionId(sessionId.toString())
                    .withUserId(userId.toString())
                    .withStreamId(streamId))
             .withPayloadOf("Example Value", "exampleField")
             .build();
Clone this wiki locally