You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2021/01/15 09:52:55 UTC

[camel] branch master updated: CAMEL-16022: Add message ordering to Google PubSub (#4877)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new c8db940  CAMEL-16022: Add message ordering to Google PubSub (#4877)
c8db940 is described below

commit c8db94095bb668ba22ed1c4337b67156e52a6ae6
Author: Preben Asmussen <pr...@dr.dk>
AuthorDate: Fri Jan 15 10:52:34 2021 +0100

    CAMEL-16022: Add message ordering to Google PubSub (#4877)
    
    CAMEL-16022: Add message ordering to Google PubSub
---
 .../pubsub/GooglePubsubEndpointConfigurer.java     |  12 +++
 .../pubsub/GooglePubsubEndpointUriFactory.java     |  12 ++-
 .../component/google/pubsub/google-pubsub.json     |   2 +
 .../src/main/docs/google-pubsub-component.adoc     |  13 ++-
 .../google/pubsub/GooglePubsubComponent.java       |  19 +++-
 .../google/pubsub/GooglePubsubConstants.java       |   1 +
 .../google/pubsub/GooglePubsubEndpoint.java        |  25 +++++
 .../google/pubsub/GooglePubsubProducer.java        |  11 ++-
 .../pubsub/integration/MessageOrderingTest.java    | 103 +++++++++++++++++++++
 9 files changed, 187 insertions(+), 11 deletions(-)

diff --git a/components/camel-google-pubsub/src/generated/java/org/apache/camel/component/google/pubsub/GooglePubsubEndpointConfigurer.java b/components/camel-google-pubsub/src/generated/java/org/apache/camel/component/google/pubsub/GooglePubsubEndpointConfigurer.java
index da15ab4..8b8737b 100644
--- a/components/camel-google-pubsub/src/generated/java/org/apache/camel/component/google/pubsub/GooglePubsubEndpointConfigurer.java
+++ b/components/camel-google-pubsub/src/generated/java/org/apache/camel/component/google/pubsub/GooglePubsubEndpointConfigurer.java
@@ -37,6 +37,10 @@ public class GooglePubsubEndpointConfigurer extends PropertyConfigurerSupport im
         case "loggerId": target.setLoggerId(property(camelContext, java.lang.String.class, value)); return true;
         case "maxmessagesperpoll":
         case "maxMessagesPerPoll": target.setMaxMessagesPerPoll(property(camelContext, java.lang.Integer.class, value)); return true;
+        case "messageorderingenabled":
+        case "messageOrderingEnabled": target.setMessageOrderingEnabled(property(camelContext, boolean.class, value)); return true;
+        case "pubsubendpoint":
+        case "pubsubEndpoint": target.setPubsubEndpoint(property(camelContext, java.lang.String.class, value)); return true;
         case "serializer": target.setSerializer(property(camelContext, org.apache.camel.component.google.pubsub.serializer.GooglePubsubSerializer.class, value)); return true;
         case "synchronouspull":
         case "synchronousPull": target.setSynchronousPull(property(camelContext, boolean.class, value)); return true;
@@ -68,6 +72,10 @@ public class GooglePubsubEndpointConfigurer extends PropertyConfigurerSupport im
         case "loggerId": return java.lang.String.class;
         case "maxmessagesperpoll":
         case "maxMessagesPerPoll": return java.lang.Integer.class;
+        case "messageorderingenabled":
+        case "messageOrderingEnabled": return boolean.class;
+        case "pubsubendpoint":
+        case "pubsubEndpoint": return java.lang.String.class;
         case "serializer": return org.apache.camel.component.google.pubsub.serializer.GooglePubsubSerializer.class;
         case "synchronouspull":
         case "synchronousPull": return boolean.class;
@@ -95,6 +103,10 @@ public class GooglePubsubEndpointConfigurer extends PropertyConfigurerSupport im
         case "loggerId": return target.getLoggerId();
         case "maxmessagesperpoll":
         case "maxMessagesPerPoll": return target.getMaxMessagesPerPoll();
+        case "messageorderingenabled":
+        case "messageOrderingEnabled": return target.isMessageOrderingEnabled();
+        case "pubsubendpoint":
+        case "pubsubEndpoint": return target.getPubsubEndpoint();
         case "serializer": return target.getSerializer();
         case "synchronouspull":
         case "synchronousPull": return target.isSynchronousPull();
diff --git a/components/camel-google-pubsub/src/generated/java/org/apache/camel/component/google/pubsub/GooglePubsubEndpointUriFactory.java b/components/camel-google-pubsub/src/generated/java/org/apache/camel/component/google/pubsub/GooglePubsubEndpointUriFactory.java
index 7ed88f4..a54d3b7 100644
--- a/components/camel-google-pubsub/src/generated/java/org/apache/camel/component/google/pubsub/GooglePubsubEndpointUriFactory.java
+++ b/components/camel-google-pubsub/src/generated/java/org/apache/camel/component/google/pubsub/GooglePubsubEndpointUriFactory.java
@@ -20,18 +20,20 @@ public class GooglePubsubEndpointUriFactory extends org.apache.camel.support.com
     private static final Set<String> PROPERTY_NAMES;
     private static final Set<String> SECRET_PROPERTY_NAMES;
     static {
-        Set<String> props = new HashSet<>(12);
+        Set<String> props = new HashSet<>(14);
+        props.add("exchangePattern");
+        props.add("serializer");
+        props.add("synchronousPull");
+        props.add("concurrentConsumers");
         props.add("lazyStartProducer");
         props.add("bridgeErrorHandler");
+        props.add("pubsubEndpoint");
+        props.add("messageOrderingEnabled");
         props.add("destinationName");
         props.add("ackMode");
-        props.add("exchangePattern");
-        props.add("serializer");
         props.add("maxMessagesPerPoll");
-        props.add("synchronousPull");
         props.add("loggerId");
         props.add("projectId");
-        props.add("concurrentConsumers");
         props.add("exceptionHandler");
         PROPERTY_NAMES = Collections.unmodifiableSet(props);
         SECRET_PROPERTY_NAMES = Collections.emptySet();
diff --git a/components/camel-google-pubsub/src/generated/resources/org/apache/camel/component/google/pubsub/google-pubsub.json b/components/camel-google-pubsub/src/generated/resources/org/apache/camel/component/google/pubsub/google-pubsub.json
index 36716b1..a499644 100644
--- a/components/camel-google-pubsub/src/generated/resources/org/apache/camel/component/google/pubsub/google-pubsub.json
+++ b/components/camel-google-pubsub/src/generated/resources/org/apache/camel/component/google/pubsub/google-pubsub.json
@@ -42,6 +42,8 @@
     "exceptionHandler": { "kind": "parameter", "displayName": "Exception Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", "deprecated": false, "autowired": false, "secret": false, "description": "To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the con [...]
     "exchangePattern": { "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut", "InOptionalOut" ], "deprecated": false, "autowired": false, "secret": false, "description": "Sets the exchange pattern when the consumer creates an exchange." },
     "lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during sta [...]
+    "messageOrderingEnabled": { "kind": "parameter", "displayName": "Message Ordering Enabled", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Should message ordering be enabled" },
+    "pubsubEndpoint": { "kind": "parameter", "displayName": "Pubsub Endpoint", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Pub\/Sub endpoint to use. Required when using message ordering, and ensures that messages are received in order even when multiple publishers are used" },
     "serializer": { "kind": "parameter", "displayName": "Serializer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.google.pubsub.serializer.GooglePubsubSerializer", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "description": "A custom GooglePubsubSerializer to use for serializing message payloads in the producer" }
   }
 }
diff --git a/components/camel-google-pubsub/src/main/docs/google-pubsub-component.adoc b/components/camel-google-pubsub/src/main/docs/google-pubsub-component.adoc
index c9f0f81..a7c67af 100644
--- a/components/camel-google-pubsub/src/main/docs/google-pubsub-component.adoc
+++ b/components/camel-google-pubsub/src/main/docs/google-pubsub-component.adoc
@@ -81,7 +81,7 @@ with the following path and query parameters:
 |===
 
 
-=== Query Parameters (10 parameters):
+=== Query Parameters (12 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -96,6 +96,8 @@ with the following path and query parameters:
 | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
 | *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. There are 3 enums and the value can be one of: InOnly, InOut, InOptionalOut |  | ExchangePattern
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
+| *messageOrderingEnabled* (producer) | Should message ordering be enabled | false | boolean
+| *pubsubEndpoint* (producer) | Pub/Sub endpoint to use. Required when using message ordering, and ensures that messages are received in order even when multiple publishers are used |  | String
 | *serializer* (producer) | *Autowired* A custom GooglePubsubSerializer to use for serializing message payloads in the producer |  | GooglePubsubSerializer
 |===
 // endpoint options: END
@@ -141,6 +143,15 @@ Google PubSub expects the payload to be byte[] array, Producer endpoints will se
 * Everything else will be serialised into byte[] array
 
 A Map set as message header `GooglePubsubConstants.ATTRIBUTES` will be sent as PubSub attributes.
+
+Google PubSub supports ordered message delivery.
+
+To enable this set set the options messageOrderingEnabled to true, and the pubsubEndpoint to a GCP region.
+
+When producing messages set the message header `GooglePubsubConstants.ORDERING_KEY` . This will be set as the PubSub orderingKey for the message.
+
+More information in https://cloud.google.com/pubsub/docs/ordering[Ordering messages].
+ 
 Once exchange has been delivered to PubSub the PubSub Message ID will be assigned to
 the header `GooglePubsubConstants.MESSAGE_ID`.
 
diff --git a/components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubComponent.java b/components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubComponent.java
index fcd6445..a727380 100644
--- a/components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubComponent.java
+++ b/components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubComponent.java
@@ -41,12 +41,15 @@ import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.annotations.Component;
 import org.apache.camel.support.DefaultComponent;
 import org.apache.camel.util.StringHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Represents the component that manages {@link GooglePubsubEndpoint}.
  */
 @Component("google-pubsub")
 public class GooglePubsubComponent extends DefaultComponent {
+    private static final Logger LOG = LoggerFactory.getLogger(GooglePubsubComponent.class);
 
     @Metadata(
               label = "common",
@@ -116,11 +119,11 @@ public class GooglePubsubComponent extends DefaultComponent {
         super.doShutdown();
     }
 
-    public Publisher getPublisher(String topicName) throws ExecutionException {
-        return cachedPublishers.get(topicName, () -> buildPublisher(topicName));
+    public Publisher getPublisher(String topicName, GooglePubsubEndpoint googlePubsubEndpoint) throws ExecutionException {
+        return cachedPublishers.get(topicName, () -> buildPublisher(topicName, googlePubsubEndpoint));
     }
 
-    private Publisher buildPublisher(String topicName) throws IOException {
+    private Publisher buildPublisher(String topicName, GooglePubsubEndpoint googlePubsubEndpoint) throws IOException {
         Publisher.Builder builder = Publisher.newBuilder(topicName);
         if (StringHelper.trimToNull(endpoint) != null) {
             ManagedChannel channel = ManagedChannelBuilder.forTarget(endpoint).usePlaintext().build();
@@ -129,6 +132,16 @@ public class GooglePubsubComponent extends DefaultComponent {
             CredentialsProvider credentialsProvider = NoCredentialsProvider.create();
             builder.setChannelProvider(channelProvider).setCredentialsProvider(credentialsProvider);
         }
+        if (StringHelper.trimToNull(googlePubsubEndpoint.getPubsubEndpoint()) != null) {
+            builder.setEndpoint(googlePubsubEndpoint.getPubsubEndpoint());
+        }
+        if (googlePubsubEndpoint.isMessageOrderingEnabled()) {
+            builder.setEnableMessageOrdering(true);
+            if (StringHelper.trimToNull(googlePubsubEndpoint.getPubsubEndpoint()) == null) {
+                LOG.warn("In conjunction with enabeling message ordering the pubsubEndpoint should be set. "
+                         + "Message ordering is only guaranteed when send to the same region.");
+            }
+        }
         return builder.build();
     }
 
diff --git a/components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubConstants.java b/components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubConstants.java
index 17e625a..e44a417 100644
--- a/components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubConstants.java
+++ b/components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubConstants.java
@@ -22,6 +22,7 @@ public final class GooglePubsubConstants {
     public static final String ACK_ID = "CamelGooglePubsub.MsgAckId";
     public static final String PUBLISH_TIME = "CamelGooglePubsub.PublishTime";
     public static final String ATTRIBUTES = "CamelGooglePubsub.Attributes";
+    public static final String ORDERING_KEY = "CamelGooglePubsub.OrderingKey";
     public static final String RESERVED_GOOGLE_CLIENT_ATTRIBUTE_PREFIX = "goog";
 
     public enum AckMode {
diff --git a/components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubEndpoint.java b/components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubEndpoint.java
index 5951673..94ca30f 100644
--- a/components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubEndpoint.java
+++ b/components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubEndpoint.java
@@ -72,6 +72,15 @@ public class GooglePubsubEndpoint extends DefaultEndpoint {
               description = "AUTO = exchange gets ack'ed/nack'ed on completion. NONE = downstream process has to ack/nack explicitly")
     private GooglePubsubConstants.AckMode ackMode = GooglePubsubConstants.AckMode.AUTO;
 
+    @UriParam(defaultValue = "false",
+              description = "Should message ordering be enabled",
+              label = "producer,advanced")
+    private boolean messageOrderingEnabled;
+
+    @UriParam(description = "Pub/Sub endpoint to use. Required when using message ordering, and ensures that messages are received in order even when multiple publishers are used",
+              label = "producer,advanced")
+    private String pubsubEndpoint;
+
     @UriParam(name = "serializer",
               description = "A custom GooglePubsubSerializer to use for serializing message payloads in the producer",
               label = "producer,advanced")
@@ -198,4 +207,20 @@ public class GooglePubsubEndpoint extends DefaultEndpoint {
     public void setSerializer(GooglePubsubSerializer serializer) {
         this.serializer = serializer;
     }
+
+    public boolean isMessageOrderingEnabled() {
+        return this.messageOrderingEnabled;
+    }
+
+    public void setMessageOrderingEnabled(boolean messageOrderingEnabled) {
+        this.messageOrderingEnabled = messageOrderingEnabled;
+    }
+
+    public String getPubsubEndpoint() {
+        return this.pubsubEndpoint;
+    }
+
+    public void setPubsubEndpoint(String pubsubEndpoint) {
+        this.pubsubEndpoint = pubsubEndpoint;
+    }
 }
diff --git a/components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubProducer.java b/components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubProducer.java
index 995368d..233fbb0 100644
--- a/components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubProducer.java
+++ b/components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubProducer.java
@@ -29,6 +29,8 @@ import org.apache.camel.support.DefaultProducer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.camel.component.google.pubsub.GooglePubsubConstants.ATTRIBUTES;
+import static org.apache.camel.component.google.pubsub.GooglePubsubConstants.ORDERING_KEY;
 import static org.apache.camel.component.google.pubsub.GooglePubsubConstants.RESERVED_GOOGLE_CLIENT_ATTRIBUTE_PREFIX;
 
 /**
@@ -82,7 +84,7 @@ public class GooglePubsubProducer extends DefaultProducer {
         GooglePubsubEndpoint endpoint = (GooglePubsubEndpoint) getEndpoint();
         String topicName = String.format("projects/%s/topics/%s", endpoint.getProjectId(), endpoint.getDestinationName());
 
-        Publisher publisher = endpoint.getComponent().getPublisher(topicName);
+        Publisher publisher = endpoint.getComponent().getPublisher(topicName, endpoint);
 
         Object body = exchange.getIn().getBody();
         ByteString byteString;
@@ -96,7 +98,7 @@ public class GooglePubsubProducer extends DefaultProducer {
         }
 
         PubsubMessage.Builder messageBuilder = PubsubMessage.newBuilder().setData(byteString);
-        Map<String, String> attributes = exchange.getIn().getHeader(GooglePubsubConstants.ATTRIBUTES, Map.class);
+        Map<String, String> attributes = exchange.getIn().getHeader(ATTRIBUTES, Map.class);
         if (attributes != null) {
             for (Map.Entry<String, String> attribute : attributes.entrySet()) {
                 if (!attribute.getKey().startsWith(RESERVED_GOOGLE_CLIENT_ATTRIBUTE_PREFIX)) {
@@ -104,6 +106,11 @@ public class GooglePubsubProducer extends DefaultProducer {
                 }
             }
         }
+        String orderingKey = exchange.getIn().getHeader(ORDERING_KEY, String.class);
+        if (orderingKey != null) {
+            messageBuilder.setOrderingKey(orderingKey);
+        }
+
         PubsubMessage message = messageBuilder.build();
 
         ApiFuture<String> messageIdFuture = publisher.publish(message);
diff --git a/components/camel-google-pubsub/src/test/java/org/apache/camel/component/google/pubsub/integration/MessageOrderingTest.java b/components/camel-google-pubsub/src/test/java/org/apache/camel/component/google/pubsub/integration/MessageOrderingTest.java
new file mode 100644
index 0000000..e49509d
--- /dev/null
+++ b/components/camel-google-pubsub/src/test/java/org/apache/camel/component/google/pubsub/integration/MessageOrderingTest.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.google.pubsub.integration;
+
+import java.util.Arrays;
+import java.util.List;
+
+import com.google.pubsub.v1.ProjectSubscriptionName;
+import com.google.pubsub.v1.Subscription;
+import com.google.pubsub.v1.Topic;
+import com.google.pubsub.v1.TopicName;
+import org.apache.camel.Endpoint;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.google.pubsub.PubsubTestSupport;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.camel.component.google.pubsub.GooglePubsubConstants.ORDERING_KEY;
+
+class MessageOrderingTest extends PubsubTestSupport {
+
+    private static final String TOPIC_NAME = "camel.input-topic";
+    private static final String SUBSCRIPTION_NAME = "camel.input-topic-subscription";
+
+    @EndpointInject("direct:in")
+    private Endpoint directIn;
+
+    @EndpointInject("google-pubsub:{{project.id}}:" + TOPIC_NAME
+                    + "?messageOrderingEnabled=true&pubsubEndpoint=us-east1-pubsub.googleapis.com:443")
+    private Endpoint pubsubTopic;
+
+    @EndpointInject("google-pubsub:{{project.id}}:" + SUBSCRIPTION_NAME)
+    private Endpoint pubsubSubscription;
+
+    @EndpointInject("mock:input")
+    private MockEndpoint inputMock;
+
+    @EndpointInject("mock:output")
+    private MockEndpoint outputMock;
+
+    @Produce("direct:in")
+    private ProducerTemplate producer;
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                from(directIn).routeId("directRoute")
+                        .setHeader(ORDERING_KEY, constant("orderkey"))
+                        .to(pubsubTopic)
+                        .to(inputMock);
+
+                from(pubsubSubscription).routeId("subscriptionRoute")
+                        .autoStartup(false)
+                        .to(outputMock);
+            }
+        };
+    }
+
+    @Override
+    public void createTopicSubscription() {
+        TopicName inputTopicName = TopicName.of(PROJECT_ID, TOPIC_NAME);
+        ProjectSubscriptionName projectInputSubscriptionName = ProjectSubscriptionName.of(PROJECT_ID, SUBSCRIPTION_NAME);
+        Topic inputTopic = Topic.newBuilder().setName(inputTopicName.toString()).build();
+        Subscription inputSubscription = Subscription.newBuilder()
+                .setName(projectInputSubscriptionName.toString())
+                .setTopic(inputTopic.getName())
+                .setEnableMessageOrdering(true)
+                .build();
+        createTopicSubscriptionPair(inputTopic, inputSubscription);
+    }
+
+    @Test
+    void orderedMessageDeliveryTest() throws Exception {
+        List<String> bodyList = Arrays.asList("1", "2", "3", "4", "5", "6");
+        inputMock.expectedMessageCount(6);
+        outputMock.expectedMessageCount(6);
+        for (String string : bodyList) {
+            producer.sendBody(string);
+        }
+        inputMock.assertIsSatisfied();
+        context.getRouteController().startRoute("subscriptionRoute");
+        outputMock.expectedBodiesReceived(bodyList);
+        outputMock.assertIsSatisfied();
+    }
+}