momo-jun commented on code in PR #589:
URL: https://github.com/apache/pulsar-site/pull/589#discussion_r1209659193


##########
docs/client-libraries-producers.md:
##########
@@ -386,13 +337,33 @@ To use a custom message router, you need to provide an 
implementation of the [Me
 public interface MessageRouter extends Serializable {
     int choosePartition(Message msg);
 }
+```
+
+The following router routes every message to partition 10:
+
+```java
+public class AlwaysTenRouter implements MessageRouter {
+    public int choosePartition(Message msg) {
+        return 10;
+    }
+}
+```
+
+With that implementation, you can send messages to partitioned topics as below.
+
+```java
+Producer<byte[]> producer = pulsarClient.newProducer()
+        .topic("my-topic")
+        .messageRouter(new AlwaysTenRouter())
+        .create();
+producer.send("Partitioned topic message".getBytes());
 ```
 
   </TabItem>
 
   <TabItem value="C++">
 
-To use a custom message router, you need to provide an implementation of the 
``MessageRoutingPolicy interface, which has just one `getPartition` method:
+To use a custom message router, you need to provide an implementation of the 
`MessageRoutingPolicy· interface, which has just one `getPartition` method:

Review Comment:
   ```suggestion
   To use a custom message router, you need to provide an implementation of the 
`MessageRoutingPolicy` interface, which has one `getPartition` method:
   ```



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to