-
Notifications
You must be signed in to change notification settings - Fork 692
Control sync/async publish in Spring Cloud Stream binder #2473
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2473 +/- ##
============================================
- Coverage 81.42% 74.22% -7.21%
+ Complexity 2377 2154 -223
============================================
Files 267 267
Lines 7722 7727 +5
Branches 798 798
============================================
- Hits 6288 5735 -553
- Misses 1095 1622 +527
- Partials 339 370 +31
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
@@ -24,4 +24,13 @@ | |||
* @author Chengyuan Zhao | |||
*/ | |||
public class PubSubProducerProperties extends PubSubCommonProperties { | |||
private boolean sync; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While uninitialized defaults to false for boolean
, it might be nice to just have sync = false
to be explicit on the defaults
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
@@ -71,4 +94,25 @@ public void testAfterUnbindConsumer() { | |||
verify(this.channelProvisioner).afterUnbindConsumer(this.consumerDestination); | |||
} | |||
|
|||
@Test | |||
public void producerSyncPropertyFalseByDefault() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's possible, I think it would be better to set the property via spring.cloud.stream.gcp.pubsub.default.producer.sync
rather than set the setting through the property class directly. Mainly to verify that spring.cloud.stream.gcp.pubsub.default.producer.sync
is indeed the correct format of the property name (as I am not sure what the correct form is myself).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I've been getting increasingly uncomfortable with the amount of mocking in this test. I'll either move this into an integration test, or turn this test into a light integration test with only a mocked pubsub template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the best I could do without testing SCS implementation details. There is still one mocked transition from our properties into a SCS wrapper, but at least it tests the property mapping correctly.
Kudos, SonarCloud Quality Gate passed!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Expose the Spring Integration
PubSubMessageHandler
'ssync
property via extended binder properties. Turning async mode off is useful when errors must be exposed to sender.There is currently no way to force synchronous sending through Cloud Pub/Sub Spring Cloud Stream binder.