See: Description
Interface | Description |
---|---|
Message |
Provides methods to update the content of a Spark message.
|
MessageAttributeValueType<T> |
Type of data supported by the Vault Java SDK.
|
MessageContext |
Contains contextual information about a Message.
|
MessageDeliveryError |
Provides methods to retrieve the failure type and error message of the failed Spark message delivery.
|
MessageDeliveryEventHandler |
Invoked when the outbound Spark message delivery fails.
|
MessageDeliveryEventHandlerContext |
Retrieves the context and delivery error of the failed Spark message delivery.
|
MessageProcessor |
Invoked to process a message received by an inbound queue.
|
PutMessageResponse |
The response returned by
QueueService.putMessage(Message) . |
PutMessageResult |
Represents the result for a specific connection during
QueueService.putMessage(Message) . |
QueueService |
Provides methods to create and put messages in a queue.
|
Enum | Description |
---|---|
MessageDeliveryErrorType |
Error types that may occur when sending a Spark message.
|
Annotation Type | Description |
---|---|
MessageDeliveryEventHandlerInfo |
Indicates a class is a
MessageDeliveryEventHandler . |
MessageProcessorInfo |
Indicates a class is a
MessageProcessor . |
To use Spark messages, you must first set up a Connection and Queue in Vault Admin for each vault that needs to send or receive a message. Connections can be set up for the local vault, with another vault, or with an external application. Learn more about Spark Messaging in the Developer Portal.
@MessageProcessorInfo()
public class ProcessStudy implements MessageProcessor { public void execute(MessageContext context) { String docId = context.getMessage().getAttribute("docId",MessageAttributeValueType.STRING); String docName = context.getMessage().getAttribute("docName",MessageAttributeValueType.STRING); String remoteVaultId = context.getRemoteVaultId(); HttpService httpService = ServiceLocator.locate(HttpService.class); // When a message is received, create a CrossLink to the document in the source vault. HttpRequest httpRequest = httpService.newLocalHttpRequest() .setMethod(HttpMethod.POST) .setBodyParam("source_document_id__v",docId) .setBodyParam("source_vault_id__v", remoteVaultId) .setBodyParam("source_binding_rule__v", "Latest version") .setBodyParam("name__v",docName) .setBodyParam("type__v", "TypeX") .setBodyParam("lifecycle__v", "General Lifecycle") .appendPath("/api/v18.3/objects/documents"); httpService.send(httpRequest,HttpResponseBodyValueType.JSONDATA) .onSuccess(response -> { // After CrossLink is created, start the Approval workflow JsonData body = response.getResponse(); String crossLinkDocId = body.getJsonObject().getValue("id", JsonValueType.NUMBER).toString(); HttpRequest startWorkflowRequest = httpService.newLocalHttpRequest() .setMethod(HttpMethod.PUT) .setBodyParam("Approver", RequestContext.get().getCurrentUserId()) .setBodyParam("dueDate", LocalDate.now().plusDays(30).toString()) .appendPath("/api/v18.3/objects/documents/" + crossLinkDocId + "/versions/0/1/lifecycle_actions/startApproval"); httpService.send(startWorkflowRequest,HttpResponseBodyValueType.STRING) .onError(starkWorkflowResponse -> { int startWorkflowResponseCode = starkWorkflowResponse.getHttpResponse().getHttpStatusCode(); ServiceLocator.locate(LogService.class).info("RESPONSE: " + responseCode); }) .execute(); }) .onError(response -> { int responseCode = response.getHttpResponse().getHttpStatusCode(); ServiceLocator.locate(LogService.class).info("RESPONSE: " + responseCode); }) .execute(); } }
Copyright © Veeva Systems 2017–2020. All rights reserved.