You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2018/06/05 01:32:19 UTC
[GitHub] merlimat closed pull request #1906: Fixed message routing mode in
Py client
merlimat closed pull request #1906: Fixed message routing mode in Py client
URL: https://github.com/apache/incubator-pulsar/pull/1906
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/pulsar-client-cpp/python/pulsar/__init__.py b/pulsar-client-cpp/python/pulsar/__init__.py
index 5b7380fe0b..d8254d3bad 100644
--- a/pulsar-client-cpp/python/pulsar/__init__.py
+++ b/pulsar-client-cpp/python/pulsar/__init__.py
@@ -282,7 +282,8 @@ def create_producer(self, topic,
batching_enabled=False,
batching_max_messages=1000,
batching_max_allowed_size_in_bytes=128*1024,
- batching_max_publish_delay_ms=10
+ batching_max_publish_delay_ms=10,
+ message_routing_mode=PartitionsRoutingMode.RoundRobinDistribution
):
"""
Create a new producer on a given topic.
@@ -317,7 +318,8 @@ def create_producer(self, topic,
* `block_if_queue_full`: Set whether `send_async` operations should
block when the outgoing message queue is full.
* `message_routing_mode`:
- Set the message routing mode for the partitioned producer.
+ Set the message routing mode for the partitioned producer. Default is `PartitionsRoutingMode.RoundRobinDistribution`,
+ other option is `PartitionsRoutingMode.UseSinglePartition`
"""
_check_type(str, topic, 'topic')
_check_type_or_none(str, producer_name, 'producer_name')
@@ -340,6 +342,7 @@ def create_producer(self, topic,
conf.batching_max_messages(batching_max_messages)
conf.batching_max_allowed_size_in_bytes(batching_max_allowed_size_in_bytes)
conf.batching_max_publish_delay_ms(batching_max_publish_delay_ms)
+ conf.partitions_routing_mode(message_routing_mode)
if producer_name:
conf.producer_name(producer_name)
if initial_sequence_id:
diff --git a/pulsar-client-cpp/python/pulsar_test.py b/pulsar-client-cpp/python/pulsar_test.py
index f35736dbc7..e2f3e251bc 100755
--- a/pulsar-client-cpp/python/pulsar_test.py
+++ b/pulsar-client-cpp/python/pulsar_test.py
@@ -22,7 +22,7 @@
from unittest import TestCase, main
import time
from pulsar import Client, MessageId, \
- CompressionType, ConsumerType
+ CompressionType, ConsumerType, PartitionsRoutingMode
from _pulsar import ProducerConfiguration, ConsumerConfiguration
@@ -324,6 +324,13 @@ def test_producer_deduplication(self):
# Exception is expected
pass
+ def test_producer_routing_mode(self):
+ client = Client(self.serviceUrl)
+ producer = client.create_producer('my-python-test-producer',
+ message_routing_mode=PartitionsRoutingMode.UseSinglePartition)
+ producer.send(b'test')
+ client.close()
+
def test_message_argument_errors(self):
client = Client(self.serviceUrl)
topic = 'persistent://sample/standalone/ns1/my-python-test-producer'
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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
With regards,
Apache Git Services