public MessageSubscriptionRecordStream receiveMessageSubscriptions() { return RecordingExporter.messageSubscriptionRecords().withPartitionId(partitionId); }
public MessageSubscriptionRecordStream receiveMessageSubscriptions() { return RecordingExporter.messageSubscriptionRecords().withPartitionId(partitionId); }
public static MessageSubscriptionRecordStream messageSubscriptionRecords( final MessageSubscriptionIntent intent) { return messageSubscriptionRecords().withIntent(intent); }
public static MessageSubscriptionRecordStream messageSubscriptionRecords( final MessageSubscriptionIntent intent) { return messageSubscriptionRecords().withIntent(intent); }
@Test public void shouldOpenMessageSubscription() { final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("orderId", "order-123")); final Record<WorkflowInstanceRecordValue> catchEventEntered = testClient.receiveElementInState("receive-message", enteredState); final Record<MessageSubscriptionRecordValue> messageSubscription = RecordingExporter.messageSubscriptionRecords(MessageSubscriptionIntent.OPENED).getFirst(); assertThat(messageSubscription.getMetadata().getValueType()) .isEqualTo(ValueType.MESSAGE_SUBSCRIPTION); assertThat(messageSubscription.getMetadata().getRecordType()).isEqualTo(RecordType.EVENT); assertMessageSubscription( workflowInstanceKey, "order-123", catchEventEntered, messageSubscription); }
@Test public void shouldOpenMessageSubscription() { final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("orderId", "order-123")); final Record<WorkflowInstanceRecordValue> catchEventEntered = testClient.receiveElementInState("receive-message", enteredState); final Record<MessageSubscriptionRecordValue> messageSubscription = RecordingExporter.messageSubscriptionRecords(MessageSubscriptionIntent.OPENED).getFirst(); assertThat(messageSubscription.getMetadata().getValueType()) .isEqualTo(ValueType.MESSAGE_SUBSCRIPTION); assertThat(messageSubscription.getMetadata().getRecordType()).isEqualTo(RecordType.EVENT); assertMessageSubscription( workflowInstanceKey, "order-123", catchEventEntered, messageSubscription); }
@Test public void shouldCorrelateMessageWithZeroTTL() { // given testClient.deploy(SINGLE_MESSAGE_WORKFLOW); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("key", "order-123")); assertThat( RecordingExporter.messageSubscriptionRecords(MessageSubscriptionIntent.OPENED).exists()) .isTrue(); // when testClient.publishMessage("message", "order-123", asMsgPack("foo", "bar"), 0); // then final Record<WorkflowInstanceRecordValue> event = testClient.receiveElementInState("receive-message", WorkflowInstanceIntent.EVENT_TRIGGERED); assertThat(event.getValue().getWorkflowInstanceKey()).isEqualTo(workflowInstanceKey); }
@Test public void shouldCorrelateMessageWithZeroTTL() { // given testClient.deploy(SINGLE_MESSAGE_WORKFLOW); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("key", "order-123")); assertThat( RecordingExporter.messageSubscriptionRecords(MessageSubscriptionIntent.OPENED).exists()) .isTrue(); // when testClient.publishMessage("message", "order-123", asMsgPack("foo", "bar"), 0); // then final Record<WorkflowInstanceRecordValue> event = testClient.receiveElementInState( "receive-message", WorkflowInstanceIntent.ELEMENT_COMPLETED); assertThat(event.getValue().getWorkflowInstanceKey()).isEqualTo(workflowInstanceKey); }
@Test public void shouldCorrelateMessageIfEnteredBefore() { // given testClient.deploy(SINGLE_MESSAGE_WORKFLOW); testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("key", "order-123")); assertThat( RecordingExporter.messageSubscriptionRecords(MessageSubscriptionIntent.OPENED).exists()) .isTrue(); // when testClient.publishMessage("message", "order-123", asMsgPack("foo", "bar")); // then final Record<WorkflowInstanceRecordValue> event = testClient.receiveElementInState("receive-message", WorkflowInstanceIntent.EVENT_TRIGGERED); assertWorkflowInstancePayload(event, "{'key':'order-123', 'foo':'bar'}"); }
@Test public void shouldCorrelateMessageIfEnteredBefore() { // given testClient.deploy(SINGLE_MESSAGE_WORKFLOW); testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("key", "order-123")); assertThat( RecordingExporter.messageSubscriptionRecords(MessageSubscriptionIntent.OPENED).exists()) .isTrue(); // when testClient.publishMessage("message", "order-123", asMsgPack("foo", "bar")); // then final Record<WorkflowInstanceRecordValue> event = testClient.receiveElementInState( "receive-message", WorkflowInstanceIntent.ELEMENT_COMPLETED); assertWorkflowInstancePayload(event, "{'key':'order-123', 'foo':'bar'}"); }
@Test public void shouldCloseMessageSubscription() { // given final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("orderId", "order-123")); final Record<WorkflowInstanceRecordValue> catchEventEntered = testClient.receiveElementInState("receive-message", enteredState); // when testClient.cancelWorkflowInstance(workflowInstanceKey); // then final Record<MessageSubscriptionRecordValue> messageSubscription = RecordingExporter.messageSubscriptionRecords(MessageSubscriptionIntent.CLOSED).getFirst(); assertThat(messageSubscription.getMetadata().getRecordType()).isEqualTo(RecordType.EVENT); Assertions.assertThat(messageSubscription.getValue()) .hasWorkflowInstanceKey(workflowInstanceKey) .hasElementInstanceKey(catchEventEntered.getKey()) .hasMessageName("order canceled") .hasCorrelationKey(""); }
@Test public void shouldCloseMessageSubscription() { // given final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("orderId", "order-123")); final Record<WorkflowInstanceRecordValue> catchEventEntered = testClient.receiveElementInState("receive-message", enteredState); // when testClient.cancelWorkflowInstance(workflowInstanceKey); // then final Record<MessageSubscriptionRecordValue> messageSubscription = RecordingExporter.messageSubscriptionRecords(MessageSubscriptionIntent.CLOSED).getFirst(); assertThat(messageSubscription.getMetadata().getRecordType()).isEqualTo(RecordType.EVENT); Assertions.assertThat(messageSubscription.getValue()) .hasWorkflowInstanceKey(workflowInstanceKey) .hasElementInstanceKey(catchEventEntered.getKey()) .hasMessageName("order canceled") .hasCorrelationKey(""); }
@Test public void shouldOpenMessageSubscriptionsOnDifferentPartitions() { // when IntStream.range(0, 10) .forEach( i -> { testClient.createWorkflowInstance( PROCESS_ID, asMsgPack("key", CORRELATION_KEY_PARTITION_0)); testClient.createWorkflowInstance( PROCESS_ID, asMsgPack("key", CORRELATION_KEY_PARTITION_1)); testClient.createWorkflowInstance( PROCESS_ID, asMsgPack("key", CORRELATION_KEY_PARTITION_2)); }); // then assertThat( RecordingExporter.messageSubscriptionRecords(MessageSubscriptionIntent.OPENED) .limit(30)) .extracting(r -> tuple(r.getMetadata().getPartitionId(), r.getValue().getCorrelationKey())) .containsOnly( tuple(0, CORRELATION_KEY_PARTITION_0), tuple(1, CORRELATION_KEY_PARTITION_1), tuple(2, CORRELATION_KEY_PARTITION_2)); }
@Test public void shouldOpenMessageSubscriptionsOnDifferentPartitions() { // when IntStream.range(0, 10) .forEach( i -> { testClient.createWorkflowInstance( PROCESS_ID, asMsgPack("key", CORRELATION_KEY_PARTITION_0)); testClient.createWorkflowInstance( PROCESS_ID, asMsgPack("key", CORRELATION_KEY_PARTITION_1)); testClient.createWorkflowInstance( PROCESS_ID, asMsgPack("key", CORRELATION_KEY_PARTITION_2)); }); // then assertThat( RecordingExporter.messageSubscriptionRecords(MessageSubscriptionIntent.OPENED) .limit(30)) .extracting(r -> tuple(r.getMetadata().getPartitionId(), r.getValue().getCorrelationKey())) .containsOnly( tuple(0, CORRELATION_KEY_PARTITION_0), tuple(1, CORRELATION_KEY_PARTITION_1), tuple(2, CORRELATION_KEY_PARTITION_2)); }