Search in sources :

Example 1 with AbstractMessageProcessor

use of org.apache.synapse.message.processor.impl.AbstractMessageProcessor in project wso2-synapse by wso2.

the class MessageProcessorDeployer method updateSynapseArtifact.

@Override
public String updateSynapseArtifact(OMElement artifactConfig, String fileName, String existingArtifactName, Properties properties) {
    if (log.isDebugEnabled()) {
        log.debug("Message Processor update from file : " + fileName + " has started");
    }
    try {
        MessageProcessor mp = MessageProcessorFactory.createMessageProcessor(artifactConfig);
        if (mp == null) {
            handleSynapseArtifactDeploymentError("Message Processor update failed. The artifact " + "defined in the file: " + fileName + " is not valid");
            return null;
        }
        mp.setFileName(new File(fileName).getName());
        if (log.isDebugEnabled()) {
            log.debug("MessageProcessor: " + mp.getName() + " has been built from the file: " + fileName);
        }
        MessageProcessor existingMp = getSynapseConfiguration().getMessageProcessors().get(existingArtifactName);
        if (existingMp instanceof AbstractMessageProcessor) {
            ((AbstractMessageProcessor) existingMp).destroy(true);
        } else {
            existingMp.destroy();
        }
        // We should add the updated MessageProcessor as a new MessageProcessor
        // and remove the old one
        mp.init(getSynapseEnvironment());
        getSynapseConfiguration().removeMessageProcessor(existingArtifactName);
        log.info("MessageProcessor: " + existingArtifactName + " has been undeployed");
        getSynapseConfiguration().addMessageProcessor(mp.getName(), mp);
        log.info("MessageProcessor: " + mp.getName() + " has been updated from the file: " + fileName);
        waitForCompletion();
        return mp.getName();
    } catch (DeploymentException e) {
        handleSynapseArtifactDeploymentError("Error while updating the MessageProcessor from the " + "file: " + fileName);
    }
    return null;
}
Also used : MessageProcessor(org.apache.synapse.message.processor.MessageProcessor) AbstractMessageProcessor(org.apache.synapse.message.processor.impl.AbstractMessageProcessor) AbstractMessageProcessor(org.apache.synapse.message.processor.impl.AbstractMessageProcessor) DeploymentException(org.apache.axis2.deployment.DeploymentException) File(java.io.File)

Example 2 with AbstractMessageProcessor

use of org.apache.synapse.message.processor.impl.AbstractMessageProcessor in project wso2-synapse by wso2.

the class SynapseConfiguration method destroy.

public synchronized void destroy(boolean preserverState) {
    if (log.isDebugEnabled()) {
        log.debug("Destroying the Synapse Configuration");
    }
    // clear the timer tasks of Synapse
    synapseTimer.cancel();
    synapseTimer = null;
    // stop and shutdown all the proxy services
    for (ProxyService p : getProxyServices()) {
        if (p.getTargetInLineInSequence() != null) {
            p.getTargetInLineInSequence().destroy();
        }
        if (p.getTargetInLineOutSequence() != null) {
            p.getTargetInLineOutSequence().destroy();
        }
    }
    // destroy the managed mediators
    for (ManagedLifecycle seq : getDefinedSequences().values()) {
        seq.destroy();
    }
    // destroy sequence templates
    for (TemplateMediator seqTemplate : getSequenceTemplates().values()) {
        seqTemplate.destroy();
    }
    // destroy inbound endpoint
    for (InboundEndpoint endpoint : getInboundEndpoints()) {
        // This path trigger from server shutdown hook. So we don't want to remove scheduled inbound tasks
        // from registry. Only un-deployment should remove task from registry. Ref product-ei#1206
        endpoint.destroy(false);
    }
    // destroy the managed endpoints
    for (Endpoint endpoint : getDefinedEndpoints().values()) {
        endpoint.destroy();
    }
    // destroy the startups
    for (ManagedLifecycle stp : startups.values()) {
        stp.destroy();
    }
    // clear session information used for SA load balancing
    try {
        SALSessions.getInstance().reset();
        DataSourceRepositoryHolder.getInstance().getDataSourceRepositoryManager().clear();
    } catch (Throwable ignored) {
    }
    // destroy the priority executors.
    for (PriorityExecutor pe : executors.values()) {
        pe.destroy();
    }
    // destroy the Message Stores
    for (MessageStore ms : messageStores.values()) {
        if (ms instanceof AbstractMessageProcessor) {
            ((AbstractMessageProcessor) ms).destroy(preserverState);
        } else {
            ms.destroy();
        }
    }
    // destroy the Message processors
    for (MessageProcessor mp : messageProcessors.values()) {
        mp.destroy();
    }
    for (API api : apiTable.values()) {
        api.destroy();
    }
}
Also used : InboundEndpoint(org.apache.synapse.inbound.InboundEndpoint) MessageStore(org.apache.synapse.message.store.MessageStore) TemplateMediator(org.apache.synapse.mediators.template.TemplateMediator) InboundEndpoint(org.apache.synapse.inbound.InboundEndpoint) Endpoint(org.apache.synapse.endpoints.Endpoint) ProxyService(org.apache.synapse.core.axis2.ProxyService) AbstractMessageProcessor(org.apache.synapse.message.processor.impl.AbstractMessageProcessor) MessageProcessor(org.apache.synapse.message.processor.MessageProcessor) AbstractMessageProcessor(org.apache.synapse.message.processor.impl.AbstractMessageProcessor) API(org.apache.synapse.rest.API) PriorityExecutor(org.apache.synapse.commons.executors.PriorityExecutor) ManagedLifecycle(org.apache.synapse.ManagedLifecycle)

Aggregations

MessageProcessor (org.apache.synapse.message.processor.MessageProcessor)2 AbstractMessageProcessor (org.apache.synapse.message.processor.impl.AbstractMessageProcessor)2 File (java.io.File)1 DeploymentException (org.apache.axis2.deployment.DeploymentException)1 ManagedLifecycle (org.apache.synapse.ManagedLifecycle)1 PriorityExecutor (org.apache.synapse.commons.executors.PriorityExecutor)1 ProxyService (org.apache.synapse.core.axis2.ProxyService)1 Endpoint (org.apache.synapse.endpoints.Endpoint)1 InboundEndpoint (org.apache.synapse.inbound.InboundEndpoint)1 TemplateMediator (org.apache.synapse.mediators.template.TemplateMediator)1 MessageStore (org.apache.synapse.message.store.MessageStore)1 API (org.apache.synapse.rest.API)1