This is an automated email from the ASF dual-hosted git repository.
mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 794d3ad Fixed message routing mode in Py client (#1906)
794d3ad is described below
commit 794d3ad3a48b855c9387cbd48453a915fb073589
Author: Matteo Merli <[email protected]>
AuthorDate: Mon Jun 4 18:32:17 2018 -0700
Fixed message routing mode in Py client (#1906)
---
pulsar-client-cpp/python/pulsar/__init__.py | 7 +++++--
pulsar-client-cpp/python/pulsar_test.py | 9 ++++++++-
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/pulsar-client-cpp/python/pulsar/__init__.py
b/pulsar-client-cpp/python/pulsar/__init__.py
index 5b7380f..d8254d3 100644
--- a/pulsar-client-cpp/python/pulsar/__init__.py
+++ b/pulsar-client-cpp/python/pulsar/__init__.py
@@ -282,7 +282,8 @@ class Client:
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 @@ class Client:
* `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 @@ class Client:
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 f35736d..e2f3e25 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 @@ class PulsarTest(TestCase):
# 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'
--
To stop receiving notification emails like this one, please contact
[email protected].