Package org.camunda.bpm.engine.impl.persistence.entity

Examples of org.camunda.bpm.engine.impl.persistence.entity.MessageEventSubscriptionEntity


    .execute(new Command<Void>() {
      public Void execute(CommandContext commandContext) {
        Calendar calendar = new GregorianCalendar();


        MessageEventSubscriptionEntity messageEventSubscriptionEntity1 = new MessageEventSubscriptionEntity();
        messageEventSubscriptionEntity1.setEventName("messageName");
        messageEventSubscriptionEntity1.setActivityId("someActivity");
        calendar.set(2001, 1, 1);
        messageEventSubscriptionEntity1.setCreated(calendar.getTime());
        messageEventSubscriptionEntity1.insert();

        MessageEventSubscriptionEntity messageEventSubscriptionEntity2 = new MessageEventSubscriptionEntity();
        messageEventSubscriptionEntity2.setEventName("messageName");
        messageEventSubscriptionEntity2.setActivityId("someActivity");
        calendar.set(2000, 1, 1);
        messageEventSubscriptionEntity2.setCreated(calendar.getTime());
        messageEventSubscriptionEntity2.insert();

        SignalEventSubscriptionEntity signalEventSubscriptionEntity3 = new SignalEventSubscriptionEntity();
        signalEventSubscriptionEntity3.setEventName("messageName2");
        signalEventSubscriptionEntity3.setActivityId("someOtherActivity");
        calendar.set(2002, 1, 1);
View Full Code Here


  protected MessageCorrelationResult tryCorrelateMessageToProcessDefinition(CommandContext commandContext, String messageName, CorrelationSet correlationSet) {
    if (messageName == null) {
      return null;
    }

    MessageEventSubscriptionEntity messageEventSubscription = commandContext.getEventSubscriptionManager()
      .findMessageStartEventSubscriptionByName(messageName);
    if(messageEventSubscription == null || messageEventSubscription.getConfiguration() == null) {
      return null;

    } else {
      DeploymentCache deploymentCache = Context
        .getProcessEngineConfiguration()
        .getDeploymentCache();

      String processDefinitionId = messageEventSubscription.getConfiguration();
      ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
      if (processDefinition == null) {
        LOGGER.log(Level.FINE, "Found event subscription with {0} but process definition {1} could not be found.",
            new Object[]{messageEventSubscription, processDefinitionId});
        return null;

      } else {
        return MessageCorrelationResult.matchedProcessDefinition(processDefinition, messageEventSubscription.getActivityId());
      }
    }
  }
View Full Code Here

  public ProcessInstance execute(CommandContext commandContext) {

    ensureNotNull("Cannot start process instance by message", "message name", messageName);

    MessageEventSubscriptionEntity messageEventSubscription = commandContext.getEventSubscriptionManager()
      .findMessageStartEventSubscriptionByName(messageName);

    ensureNotNull("Cannot start process instance by message: no subscription to message with name '" + messageName + "' found", "messageEventSubscription", messageEventSubscription);

    String processDefinitionId = messageEventSubscription.getConfiguration();
    ensureNotNull("Cannot start process instance by message: subscription to message with name '" + messageName + "' is not a message start event", "processDefinitionId", processDefinitionId);

    DeploymentCache deploymentCache = Context
      .getProcessEngineConfiguration()
      .getDeploymentCache();

    ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
    ensureNotNull("No process definition found for id '" + processDefinitionId + "'", "processDefinition", processDefinition);

    ActivityImpl startActivity = processDefinition.findActivity(messageEventSubscription.getActivityId());
    ExecutionEntity processInstance = processDefinition.createProcessInstance(businessKey, startActivity);

    if (processVariables != null) {
      processInstance.setVariables(processVariables);
    }
View Full Code Here

          if(!subscriptionsForSameMessageName.isEmpty()) {
            throw new ProcessEngineException("Cannot deploy process definition '" + processDefinition.getResourceName()
                    + "': there already is a message event subscription for the message with name '" + messageEventDefinition.getEventName() + "'.");
          }

          MessageEventSubscriptionEntity newSubscription = new MessageEventSubscriptionEntity();
          newSubscription.setEventName(messageEventDefinition.getEventName());
          newSubscription.setActivityId(messageEventDefinition.getActivityId());
          newSubscription.setConfiguration(processDefinition.getId());

          newSubscription.insert();
        }
      }
    }
  }
View Full Code Here

   * @return subscription entity
   */
  private EventSubscriptionEntity createEventSubscription(ExecutionEntity execution) {
    EventSubscriptionEntity eventSubscriptionEntity = null;
    if (eventType.equals(MessageEventHandler.EVENT_HANDLER_TYPE)) {
      eventSubscriptionEntity = new MessageEventSubscriptionEntity(execution);
    } else if (eventType.equals(SignalEventHandler.EVENT_HANDLER_TYPE)) {
      eventSubscriptionEntity = new SignalEventSubscriptionEntity(execution);
    } else {
      throw new ProcessEngineException("Found event definition of unknown type: " + eventType);
    }
View Full Code Here

    return result;
  }

  protected MessageCorrelationResult tryCorrelateMessageToProcessDefinition(CommandContext commandContext, String messageName, CorrelationSet correlationSet) {

    MessageEventSubscriptionEntity messageEventSubscription = commandContext.getEventSubscriptionManager()
      .findMessageStartEventSubscriptionByName(messageName);
    if(messageEventSubscription == null || messageEventSubscription.getConfiguration() == null) {
      return null;

    } else {
      DeploymentCache deploymentCache = Context
        .getProcessEngineConfiguration()
        .getDeploymentCache();

      String processDefinitionId = messageEventSubscription.getConfiguration();
      ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
      if (processDefinition == null) {
        LOGGER.log(Level.FINE, "Found event subscription with {0} but process definition {1} could not be found.",
            new Object[]{messageEventSubscription, processDefinitionId});
        return null;

      } else {
        return MessageCorrelationResult.matchedProcessDefinition(processDefinition, messageEventSubscription.getActivityId());
      }
    }
  }
View Full Code Here

          if(!subscriptionsForSameMessageName.isEmpty()) {
            throw new ProcessEngineException("Cannot deploy process definition '" + processDefinition.getResourceName()
                    + "': there already is a message event subscription for the message with name '" + messageEventDefinition.getEventName() + "'.");
          }

          MessageEventSubscriptionEntity newSubscription = new MessageEventSubscriptionEntity();
          newSubscription.setEventName(messageEventDefinition.getEventName());
          newSubscription.setActivityId(messageEventDefinition.getActivityId());
          newSubscription.setConfiguration(processDefinition.getId());

          newSubscription.insert();
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.camunda.bpm.engine.impl.persistence.entity.MessageEventSubscriptionEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.