Search in sources :

Example 11 with Message

use of io.automatiko.engine.workflow.bpmn2.core.Message in project droolsjbpm-integration by kiegroup.

the class KafkaServerExtensionConsumerTest method testWithDestroy.

@Test
public void testWithDestroy() {
    when(processDefinition.getSignalsDesc()).thenReturn(Collections.singletonList(createSignal("MySignal2", "String")));
    Message msg = new Message("MyMessage");
    msg.setName("Hello2");
    msg.setType("String");
    msg.addIncomingNode(mock(Node.class));
    extension.onDeploy(getDeploymentEvent("MyDeploy4"));
    publishEvent("MySignal2", "{\"id\":\"javi\",\"type\":\"one\",\"source\":\"pepe\",\"data\":\"javierito\"}");
    verify(processService, getTimeout()).signalEvent("MyDeploy4", "MySignal2", "javierito");
    extension.destroy(server, registry);
    mockConsumer = new MockConsumer<String, byte[]>(OffsetResetStrategy.EARLIEST);
    when(processDefinition.getSignalsDesc()).thenReturn(Collections.emptyList());
    when(processDefinition.getMessagesDesc()).thenReturn(Collections.singletonList(MessageDescImpl.from(msg)));
    extension.setKafkaConsumer(mockConsumer);
    extension.init(server, registry);
    extension.onDeploy(getDeploymentEvent("MyDeploy5"));
    publishEvent("Hello2", "{\"id\":\"javi\",\"type\":\"one\",\"source\":\"pepe\",\"data\":\"pepe\"}");
    verify(processService, getTimeout()).signalEvent("MyDeploy5", "Message-Hello2", "pepe");
}
Also used : Message(org.jbpm.bpmn2.core.Message) Node(org.kie.api.definition.process.Node) Test(org.junit.Test)

Example 12 with Message

use of io.automatiko.engine.workflow.bpmn2.core.Message in project droolsjbpm-integration by kiegroup.

the class KafkaServerExtensionConsumerTest method testKafkaServerExecutorMessage.

@Test
public void testKafkaServerExecutorMessage() {
    Message msg = new Message("MyMessage");
    msg.setName("Hello");
    msg.setType("String");
    msg.addIncomingNode(mock(Node.class));
    when(processDefinition.getMessagesDesc()).thenReturn(Collections.singletonList(MessageDescImpl.from(msg)));
    extension.onDeploy(getDeploymentEvent("MyDeploy2"));
    publishEvent("Hello", "{\"id\":\"javi\",\"type\":\"one\",\"source\":\"pepe\",\"data\":\"pepe\"}");
    verify(processService, getTimeout()).signalEvent("MyDeploy2", "Message-Hello", "pepe");
}
Also used : Message(org.jbpm.bpmn2.core.Message) Node(org.kie.api.definition.process.Node) Test(org.junit.Test)

Example 13 with Message

use of io.automatiko.engine.workflow.bpmn2.core.Message in project droolsjbpm-integration by kiegroup.

the class KafkaServerExtensionConsumerTest method testMessageDisable.

@Test
public void testMessageDisable() {
    when(processDefinition.getMessagesDesc()).thenReturn(Collections.singletonList(MessageDescImpl.from(new Message("MyMessage"))));
    System.setProperty(MESSAGE_MAPPING_PROPERTY, Mapping.NONE.toString());
    extension.onDeploy(getDeploymentEvent("MyDeploy4"));
    verify(processDefinition, never()).getMessagesDesc();
}
Also used : Message(org.jbpm.bpmn2.core.Message) Test(org.junit.Test)

Example 14 with Message

use of io.automatiko.engine.workflow.bpmn2.core.Message in project automatiko-engine by automatiko-io.

the class IntermediateThrowEventHandler method handleMessageNode.

@SuppressWarnings("unchecked")
public void handleMessageNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    ActionNode actionNode = (ActionNode) node;
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("dataInput".equals(nodeName)) {
            String id = ((Element) xmlNode).getAttribute("id");
            String inputName = ((Element) xmlNode).getAttribute("name");
            dataInputs.put(id, inputName);
        } else if ("dataInputAssociation".equals(nodeName)) {
            readDataInputAssociation(xmlNode, actionNode, parser);
        } else if ("messageEventDefinition".equals(nodeName)) {
            String messageRef = ((Element) xmlNode).getAttribute("messageRef");
            Map<String, Message> messages = (Map<String, Message>) ((ProcessBuildData) parser.getData()).getMetaData("Messages");
            if (messages == null) {
                throw new IllegalArgumentException("No messages found");
            }
            Message message = messages.get(messageRef);
            if (message == null) {
                throw new IllegalArgumentException("Could not find message " + messageRef);
            }
            String variable = (String) actionNode.getMetaData(MAPPING_VARIABLE_KEY);
            Variable v = (Variable) ((ProcessBuildData) parser.getData()).getMetaData("Variable");
            if (v != null) {
                variable = (String) v.getMetaData(variable);
            }
            actionNode.setMetaData("MessageType", message.getType());
            actionNode.setMetaData("TriggerType", "ProduceMessage");
            actionNode.setMetaData("TriggerRef", message.getName());
            for (Entry<String, Object> entry : message.getMetaData().entrySet()) {
                actionNode.setMetaData(entry.getKey(), entry.getValue());
            }
            ConsequenceAction action = createJavaAction(new HandleMessageAction(message.getType(), variable, (Transformation) actionNode.getMetaData().get(TRANSFORMATION_KEY)));
            actionNode.setAction(action);
        }
        xmlNode = xmlNode.getNextSibling();
    }
}
Also used : Transformation(io.automatiko.engine.workflow.process.core.node.Transformation) Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) Message(io.automatiko.engine.workflow.bpmn2.core.Message) Element(org.w3c.dom.Element) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) HandleMessageAction(io.automatiko.engine.workflow.base.instance.impl.actions.HandleMessageAction) Map(java.util.Map) NamedNodeMap(org.w3c.dom.NamedNodeMap)

Example 15 with Message

use of io.automatiko.engine.workflow.bpmn2.core.Message in project automatiko-engine by automatiko-io.

the class InMessageRefHandler method end.

@SuppressWarnings("unchecked")
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    Element element = parser.endElementBuilder();
    String messageId = element.getTextContent();
    Map<String, Message> messages = (Map<String, Message>) ((ProcessBuildData) parser.getData()).getMetaData("Messages");
    if (messages == null) {
        throw new IllegalArgumentException("No messages found");
    }
    Operation operation = (Operation) parser.getParent();
    Message message = messages.get(messageId);
    if (message != null) {
        operation.setMessage(message);
    }
    return parser.getCurrent();
}
Also used : Message(io.automatiko.engine.workflow.bpmn2.core.Message) Element(org.w3c.dom.Element) Operation(io.automatiko.engine.workflow.bpmn2.core.Interface.Operation) Map(java.util.Map)

Aggregations

Map (java.util.Map)28 Message (org.jbpm.bpmn2.core.Message)27 Element (org.w3c.dom.Element)16 ArrayList (java.util.ArrayList)14 Message (io.automatiko.engine.workflow.bpmn2.core.Message)9 Test (org.junit.Test)9 List (java.util.List)7 EventFilter (org.jbpm.process.core.event.EventFilter)7 EventTypeFilter (org.jbpm.process.core.event.EventTypeFilter)7 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)6 Signal (org.jbpm.bpmn2.core.Signal)5 ProcessBuildData (org.jbpm.compiler.xml.ProcessBuildData)5 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)5 StartNode (org.jbpm.workflow.core.node.StartNode)5 HashMap (java.util.HashMap)4 Error (org.jbpm.bpmn2.core.Error)4 Escalation (org.jbpm.bpmn2.core.Escalation)4 ConstraintTrigger (org.jbpm.workflow.core.node.ConstraintTrigger)4 EventNode (org.jbpm.workflow.core.node.EventNode)4 Node (org.kie.api.definition.process.Node)4