All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.boozallen.aissemble.pipeline.invocation.service.endpoint.MessageEndpoint Maven / Gradle / Ivy

There is a newer version: 1.10.0-rc2
Show newest version
package com.boozallen.aissemble.pipeline.invocation.service.endpoint;

/*-
 * #%L
 * aiSSEMBLE::Extensions::Pipeline Invocation Service
 * %%
 * Copyright (C) 2021 Booz Allen
 * %%
 * This software package is licensed under the Booz Allen Public License. All Rights Reserved.
 * #L%
 */

import com.boozallen.aissemble.pipeline.invocation.service.PipelineInvocationAgent;
import com.boozallen.aissemble.pipeline.invocation.service.serialization.PipelineInvocationRequest;
import org.eclipse.microprofile.reactive.messaging.Acknowledgment;
import org.eclipse.microprofile.reactive.messaging.Incoming;
import org.jboss.logging.Logger;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;

/**
 * Entrypoint for message-based requests for SparkApplication submission.
 */
@ApplicationScoped
public class MessageEndpoint {
    public static final String CHANNEL_NAME = "pipeline-invocation";

    private static final Logger logger = Logger.getLogger(MessageEndpoint.class);

    @Inject
    PipelineInvocationAgent pipelineInvocationAgent;

    /**
     * Receives a message requesting the submission of a SparkApplication to the cluster for processing
     * @param rawRequest: JSON string representing the desired PipelineInvocationRequest.
     */
    @Incoming(CHANNEL_NAME)
    @Acknowledgment(Acknowledgment.Strategy.PRE_PROCESSING)
    public void receivePipelineRequest(String rawRequest) {
        try {
            PipelineInvocationRequest pipelineInvocationRequest = PipelineInvocationRequest.fromString(rawRequest);
            logger.info("Received message request to submit " + pipelineInvocationRequest.getApplicationName() + ".");
            pipelineInvocationAgent.submitSparkApplication(pipelineInvocationRequest);
            logger.info("Submitted " + pipelineInvocationRequest.getApplicationName() + " for processing.");
        } catch (Exception failsafe) {
            throw new RuntimeException(failsafe);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy