You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/01/13 15:05:17 UTC

[GitHub] [camel] pax95 opened a new pull request #4877: CAMEL-16022: Add message ordering to Google PubSub

pax95 opened a new pull request #4877:
URL: https://github.com/apache/camel/pull/4877


   - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).  Trivial changes like typos do not require a JIRA issue.  Your pull request should address just this issue, without pulling in other changes.
   - [ ] Each commit in the pull request should have a meaningful subject line and body.
   - [ ] If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
   - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [ ] Run `mvn clean install -Psourcecheck` in your module with source check enabled to make sure basic checks pass and there are no checkstyle violations. A more thorough check will be performed on your pull request automatically.
   Below are the contribution guidelines:
   https://github.com/apache/camel/blob/master/CONTRIBUTING.md


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] pax95 commented on a change in pull request #4877: CAMEL-16022: Add message ordering to Google PubSub

Posted by GitBox <gi...@apache.org>.
pax95 commented on a change in pull request #4877:
URL: https://github.com/apache/camel/pull/4877#discussion_r558119657



##########
File path: components/camel-google-pubsub/src/test/java/org/apache/camel/component/google/pubsub/integration/MessageOrderingTest.java
##########
@@ -0,0 +1,104 @@
+/*
+ * 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");

Review comment:
       @davsclaus 
   Fixed in latest commit.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] omarsmak commented on a change in pull request #4877: CAMEL-16022: Add message ordering to Google PubSub

Posted by GitBox <gi...@apache.org>.
omarsmak commented on a change in pull request #4877:
URL: https://github.com/apache/camel/pull/4877#discussion_r557290700



##########
File path: components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubComponent.java
##########
@@ -129,6 +132,15 @@ private Publisher buildPublisher(String topicName) throws IOException {
             CredentialsProvider credentialsProvider = NoCredentialsProvider.create();
             builder.setChannelProvider(channelProvider).setCredentialsProvider(credentialsProvider);
         }
+        if (googlePubsubEndpoint.isMessageOrderingEnabled()) {
+            builder.setEnableMessageOrdering(true);
+            if (StringHelper.trimToNull(googlePubsubEndpoint.getPubsubEndpoint()) != null) {
+                builder.setEndpoint(googlePubsubEndpoint.getPubsubEndpoint());

Review comment:
       Okay, then for now we can just enable the endpoint override without the message ordering. And then later we can do the endpoint refactor (to have only one endpoint option to configure instead of two). Would be great if you can create a JIRA for the proposed improvement. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] pax95 commented on a change in pull request #4877: CAMEL-16022: Add message ordering to Google PubSub

Posted by GitBox <gi...@apache.org>.
pax95 commented on a change in pull request #4877:
URL: https://github.com/apache/camel/pull/4877#discussion_r557078567



##########
File path: components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubComponent.java
##########
@@ -129,6 +132,15 @@ private Publisher buildPublisher(String topicName) throws IOException {
             CredentialsProvider credentialsProvider = NoCredentialsProvider.create();
             builder.setChannelProvider(channelProvider).setCredentialsProvider(credentialsProvider);
         }
+        if (googlePubsubEndpoint.isMessageOrderingEnabled()) {
+            builder.setEnableMessageOrdering(true);
+            if (StringHelper.trimToNull(googlePubsubEndpoint.getPubsubEndpoint()) != null) {
+                builder.setEndpoint(googlePubsubEndpoint.getPubsubEndpoint());
+            } else {
+                LOG.warn("In conjunction with enabeling message ordering the pubsubEndpoint should be set. "
+                         + "Message ordering is only garantied when send to the same region.");

Review comment:
       fixed




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] omarsmak commented on a change in pull request #4877: CAMEL-16022: Add message ordering to Google PubSub

Posted by GitBox <gi...@apache.org>.
omarsmak commented on a change in pull request #4877:
URL: https://github.com/apache/camel/pull/4877#discussion_r557262208



##########
File path: components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubComponent.java
##########
@@ -129,6 +132,15 @@ private Publisher buildPublisher(String topicName) throws IOException {
             CredentialsProvider credentialsProvider = NoCredentialsProvider.create();
             builder.setChannelProvider(channelProvider).setCredentialsProvider(credentialsProvider);
         }
+        if (googlePubsubEndpoint.isMessageOrderingEnabled()) {
+            builder.setEnableMessageOrdering(true);
+            if (StringHelper.trimToNull(googlePubsubEndpoint.getPubsubEndpoint()) != null) {
+                builder.setEndpoint(googlePubsubEndpoint.getPubsubEndpoint());

Review comment:
       I see. My problem here is that, we will end up with two similar endpoint options which could be a bit confusing to the user. Hence, can we somehow refactor this to only have one endpoint option to be overriden (emulator and API endpoint)? Also, I don't think overriding the endpoint should be only possible when the message ordering is enabled.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] pax95 commented on a change in pull request #4877: CAMEL-16022: Add message ordering to Google PubSub

Posted by GitBox <gi...@apache.org>.
pax95 commented on a change in pull request #4877:
URL: https://github.com/apache/camel/pull/4877#discussion_r557080830



##########
File path: components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubComponent.java
##########
@@ -129,6 +132,15 @@ private Publisher buildPublisher(String topicName) throws IOException {
             CredentialsProvider credentialsProvider = NoCredentialsProvider.create();
             builder.setChannelProvider(channelProvider).setCredentialsProvider(credentialsProvider);
         }
+        if (googlePubsubEndpoint.isMessageOrderingEnabled()) {
+            builder.setEnableMessageOrdering(true);
+            if (StringHelper.trimToNull(googlePubsubEndpoint.getPubsubEndpoint()) != null) {
+                builder.setEndpoint(googlePubsubEndpoint.getPubsubEndpoint());

Review comment:
       From what I see the endpoint is used by the  description = "Endpoint to use with local Pub/Sub emulator."
   when running unittests. Also it set's up a NoCredentialsProvider so I guess this is not a 'real' runtime usable property.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] davsclaus commented on a change in pull request #4877: CAMEL-16022: Add message ordering to Google PubSub

Posted by GitBox <gi...@apache.org>.
davsclaus commented on a change in pull request #4877:
URL: https://github.com/apache/camel/pull/4877#discussion_r557638244



##########
File path: components/camel-google-pubsub/src/test/java/org/apache/camel/component/google/pubsub/integration/MessageOrderingTest.java
##########
@@ -0,0 +1,104 @@
+/*
+ * 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");

Review comment:
       You would ideally set the exceptions BEFORE you send or start route, eg
   
   1. set mock expecation
   2. send messages
   3. assert mock
   
   Here you do 2, 1, 3 instead




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] davsclaus merged pull request #4877: CAMEL-16022: Add message ordering to Google PubSub

Posted by GitBox <gi...@apache.org>.
davsclaus merged pull request #4877:
URL: https://github.com/apache/camel/pull/4877


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] oscerd commented on pull request #4877: CAMEL-16022: Add message ordering to Google PubSub

Posted by GitBox <gi...@apache.org>.
oscerd commented on pull request #4877:
URL: https://github.com/apache/camel/pull/4877#issuecomment-760080461


   We can do that later, let's open an improvement about this for 3.8


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] omarsmak commented on a change in pull request #4877: CAMEL-16022: Add message ordering to Google PubSub

Posted by GitBox <gi...@apache.org>.
omarsmak commented on a change in pull request #4877:
URL: https://github.com/apache/camel/pull/4877#discussion_r556654222



##########
File path: components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubComponent.java
##########
@@ -129,6 +132,15 @@ private Publisher buildPublisher(String topicName) throws IOException {
             CredentialsProvider credentialsProvider = NoCredentialsProvider.create();
             builder.setChannelProvider(channelProvider).setCredentialsProvider(credentialsProvider);
         }
+        if (googlePubsubEndpoint.isMessageOrderingEnabled()) {
+            builder.setEnableMessageOrdering(true);
+            if (StringHelper.trimToNull(googlePubsubEndpoint.getPubsubEndpoint()) != null) {
+                builder.setEndpoint(googlePubsubEndpoint.getPubsubEndpoint());
+            } else {
+                LOG.warn("In conjunction with enabeling message ordering the pubsubEndpoint should be set. "
+                         + "Message ordering is only garantied when send to the same region.");

Review comment:
       typo
   ```suggestion
                            + "Message ordering is only guaranteed when send to the same region.");
   ```

##########
File path: components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubComponent.java
##########
@@ -129,6 +132,15 @@ private Publisher buildPublisher(String topicName) throws IOException {
             CredentialsProvider credentialsProvider = NoCredentialsProvider.create();
             builder.setChannelProvider(channelProvider).setCredentialsProvider(credentialsProvider);
         }
+        if (googlePubsubEndpoint.isMessageOrderingEnabled()) {
+            builder.setEnableMessageOrdering(true);
+            if (StringHelper.trimToNull(googlePubsubEndpoint.getPubsubEndpoint()) != null) {
+                builder.setEndpoint(googlePubsubEndpoint.getPubsubEndpoint());

Review comment:
       I am bit confused here, why do you need to override the endpoint here if the message ordering is enabled? And also it looks the endpoint could be overriden [here](https://github.com/apache/camel/pull/4877/files#diff-fab91f6f43de3fd75a1134f3fe2fda9b52f3d78a45336ab56a758eae05fba1edR129) and hence I don't think this option is needed. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] pax95 commented on a change in pull request #4877: CAMEL-16022: Add message ordering to Google PubSub

Posted by GitBox <gi...@apache.org>.
pax95 commented on a change in pull request #4877:
URL: https://github.com/apache/camel/pull/4877#discussion_r557283290



##########
File path: components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubComponent.java
##########
@@ -129,6 +132,15 @@ private Publisher buildPublisher(String topicName) throws IOException {
             CredentialsProvider credentialsProvider = NoCredentialsProvider.create();
             builder.setChannelProvider(channelProvider).setCredentialsProvider(credentialsProvider);
         }
+        if (googlePubsubEndpoint.isMessageOrderingEnabled()) {
+            builder.setEnableMessageOrdering(true);
+            if (StringHelper.trimToNull(googlePubsubEndpoint.getPubsubEndpoint()) != null) {
+                builder.setEndpoint(googlePubsubEndpoint.getPubsubEndpoint());

Review comment:
       @oscerd Would be good if we could improve this later so that the emulator uses the pubsubEndpoint. 
   @omarsmak Agree overriding the endpoint should be possible even without message ordering.  




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] pax95 commented on a change in pull request #4877: CAMEL-16022: Add message ordering to Google PubSub

Posted by GitBox <gi...@apache.org>.
pax95 commented on a change in pull request #4877:
URL: https://github.com/apache/camel/pull/4877#discussion_r557376895



##########
File path: components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubComponent.java
##########
@@ -129,6 +132,15 @@ private Publisher buildPublisher(String topicName) throws IOException {
             CredentialsProvider credentialsProvider = NoCredentialsProvider.create();
             builder.setChannelProvider(channelProvider).setCredentialsProvider(credentialsProvider);
         }
+        if (googlePubsubEndpoint.isMessageOrderingEnabled()) {
+            builder.setEnableMessageOrdering(true);
+            if (StringHelper.trimToNull(googlePubsubEndpoint.getPubsubEndpoint()) != null) {
+                builder.setEndpoint(googlePubsubEndpoint.getPubsubEndpoint());

Review comment:
       enabled endpoint override, and created https://issues.apache.org/jira/browse/CAMEL-16036 to improve the component later.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] omarsmak commented on a change in pull request #4877: CAMEL-16022: Add message ordering to Google PubSub

Posted by GitBox <gi...@apache.org>.
omarsmak commented on a change in pull request #4877:
URL: https://github.com/apache/camel/pull/4877#discussion_r557290700



##########
File path: components/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubComponent.java
##########
@@ -129,6 +132,15 @@ private Publisher buildPublisher(String topicName) throws IOException {
             CredentialsProvider credentialsProvider = NoCredentialsProvider.create();
             builder.setChannelProvider(channelProvider).setCredentialsProvider(credentialsProvider);
         }
+        if (googlePubsubEndpoint.isMessageOrderingEnabled()) {
+            builder.setEnableMessageOrdering(true);
+            if (StringHelper.trimToNull(googlePubsubEndpoint.getPubsubEndpoint()) != null) {
+                builder.setEndpoint(googlePubsubEndpoint.getPubsubEndpoint());

Review comment:
       Okay, then for now we can just enabling the endpoint override without the message ordering. And then later we can do the endpoint refactor (to have only one endpoint option to configure instead of two). Would be great if you can create a JIRA for the proposed improvement. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org