You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -29,7 +31,7 @@ When troubleshooting or fine tuning it is worth reading the `librdkafka` and `co
29
31
30
32
## Configuration properties
31
33
32
-
Producer, consumer and global configuration properties are described [here](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md).
34
+
Producer, consumer and global configuration properties are described [here](https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md).
33
35
The configuration on the underlying Kafka client can be adjusted like so:
There is a good description [here](https://github.com/edenhill/librdkafka/wiki/How-to-decrease-message-latency) on improving the latency by applying producer/consumer settings on librdkafka. Here is how you enter the settings using SlimMessageBus:
58
+
There is a good description [here](https://github.com/confluentinc/librdkafka/wiki/How-to-decrease-message-latency) on improving the latency by applying producer/consumer settings on librdkafka. Here is how you enter the settings using SlimMessageBus:
The file `cloudkarafka_2020-12.ca` has to be set to `Copy to Output Directory` as `Copy always`.
121
123
122
-
## Selecting message partition for topic producer
124
+
## Producers
125
+
126
+
### High throughput publish
127
+
128
+
By default each [.Publish()](../src/SlimMessageBus/IPublishBus.cs) / [.Send()](../src/SlimMessageBus/RequestResponse/IRequestResponseBus.cs) is producing the message to the Kafka transport and awaiting the response.
129
+
This is to ensure the errors in delivery to the Kafka transport are reported as [ProducerMessageBusException](../src/SlimMessageBus/Exceptions/ProducerMessageBusException.cs) and ensuring delivery to the kafka cluster.
130
+
131
+
However, for scenarios where we want higher throughput with the sacrifice of delivery we can use the `.EnableProduceAwait(false)` on the producer or bus configuration.
132
+
When await is disabled the message will be delivered to the Kafka client without awaiting the produce result, and the client's internal buffering will be used more effectively.
133
+
134
+
```cs
135
+
mbb.Produce<PingMessage>(x=>
136
+
{
137
+
x.DefaultTopic(topic);
138
+
// Partition #0 - for even counters, and #1 - for odd counters
139
+
x.PartitionProvider((m, t) =>m.Counter%2);
140
+
x.EnableProduceAwait(enableProduceAwait);
141
+
});
142
+
```
143
+
144
+
### Selecting message partition for topic producer
123
145
124
146
Kafka topics are broken into partitions. The question is how does SMB Kafka choose the partition to assign the message?
125
147
There are two possible options:
126
148
127
-
### Default partitioner with message key
149
+
####Default partitioner with message key
128
150
129
151
Currently, [confluent-kafka-dotnet](https://github.com/confluentinc/confluent-kafka-dotnet) does not support custom partitioners (see [here](https://github.com/confluentinc/confluent-kafka-dotnet/issues/343)).
130
152
The default partitioner is supported, which works in this way:
@@ -148,7 +170,7 @@ mbb
148
170
149
171
The key must be a `byte[]`.
150
172
151
-
### Assigning partition explicitly
173
+
####Assigning partition explicitly
152
174
153
175
SMB Kafka allows to set a provider (selector) that will assign the partition number for a given message and topic pair. Here is an example:
154
176
@@ -167,33 +189,13 @@ mbb
167
189
168
190
With this approach your provider needs to know the number of partitions for a topic.
169
191
170
-
## Consumer context
171
-
172
-
The consumer can implement the `IConsumerWithContext` interface to access the Kafka native message:
This could be useful to extract the message's offset or partition.
189
-
190
192
## Message Headers
191
193
192
194
SMB uses headers to pass additional metadata information with the message. This includes the `MessageType` (of type `string`) or in the case of request/response messages the `RequestId` (of type `string`), `ReplyTo` (of type `string`) and `Expires` (of type `long`).
193
195
194
196
The Kafka message header values are natively binary (`byte[]`) in the underlying .NET client, as a result SMB needs to serialize the header values.
195
197
By default the [DefaultKafkaHeaderSerializer](../src/SlimMessageBus.Host.Kafka/DefaultKafkaHeaderSerializer.cs) is used to serialize header values.
196
-
If you need to specify a different serializer provide a specfic`IMessageSerializer` implementation (custom or one of the available serialization plugins):
198
+
If you need to specify a different serializer provide a specific`IMessageSerializer` implementation (custom or one of the available serialization plugins):
197
199
198
200
```cs
199
201
// MessageBusBuilder mbb;
@@ -209,9 +211,30 @@ mbb
209
211
210
212
## Consumers
211
213
214
+
### Consumer context
215
+
216
+
The consumer can implement the `IConsumerWithContext` interface to access the Kafka native message:
This could be useful to extract the message's offset or partition.
233
+
212
234
### Offset Commit
213
235
214
-
In the current Kafka provider implementation, SMB handles the manual commit of topic-partition offsets for the consumer. This configuration is controlled through the following methods on the consumer builder:
236
+
In the current Kafka provider implementation, SMB handles the manual commit of topic-partition offsets for the consumer.Th
237
+
is configuration is controlled through the following methods on the consumer builder:
215
238
216
239
-`CheckpointEvery(int)` – Commits the offset after a specified number of processed messages.
217
240
-`CheckpointAfter(TimeSpan)` – Commits the offset after a specified time interval.
The file `cloudkarafka_2020-12.ca` has to be set to `Copy to Output Directory` as `Copy always`.
121
123
122
-
## Selecting message partition for topic producer
124
+
## Producers
125
+
126
+
### High throughput publish
127
+
128
+
By default each [.Publish()](../src/SlimMessageBus/IPublishBus.cs) / [.Send()](../src/SlimMessageBus/RequestResponse/IRequestResponseBus.cs) is producing the message to the Kafka transport and awaiting the response.
129
+
This is to ensure the errors in delivery to the Kafka transport are reported as [ProducerMessageBusException](../src/SlimMessageBus/Exceptions/ProducerMessageBusException.cs) and ensuring delivery to the kafka cluster.
130
+
131
+
However, for scenarios where we want higher throughput with the sacrifice of delivery we can use the `.EnableProduceAwait(false)` on the producer or bus configuration.
132
+
When await is disabled the message will be delivered to the Kafka client without awaiting the produce result, and the client's internal buffering will be used more effectively.
### Selecting message partition for topic producer
123
137
124
138
Kafka topics are broken into partitions. The question is how does SMB Kafka choose the partition to assign the message?
125
139
There are two possible options:
126
140
127
-
### Default partitioner with message key
141
+
####Default partitioner with message key
128
142
129
143
Currently, [confluent-kafka-dotnet](https://github.com/confluentinc/confluent-kafka-dotnet) does not support custom partitioners (see [here](https://github.com/confluentinc/confluent-kafka-dotnet/issues/343)).
130
144
The default partitioner is supported, which works in this way:
@@ -148,7 +162,7 @@ mbb
148
162
149
163
The key must be a `byte[]`.
150
164
151
-
### Assigning partition explicitly
165
+
####Assigning partition explicitly
152
166
153
167
SMB Kafka allows to set a provider (selector) that will assign the partition number for a given message and topic pair. Here is an example:
154
168
@@ -167,33 +181,13 @@ mbb
167
181
168
182
With this approach your provider needs to know the number of partitions for a topic.
169
183
170
-
## Consumer context
171
-
172
-
The consumer can implement the `IConsumerWithContext` interface to access the Kafka native message:
This could be useful to extract the message's offset or partition.
189
-
190
184
## Message Headers
191
185
192
186
SMB uses headers to pass additional metadata information with the message. This includes the `MessageType` (of type `string`) or in the case of request/response messages the `RequestId` (of type `string`), `ReplyTo` (of type `string`) and `Expires` (of type `long`).
193
187
194
188
The Kafka message header values are natively binary (`byte[]`) in the underlying .NET client, as a result SMB needs to serialize the header values.
195
189
By default the [DefaultKafkaHeaderSerializer](../src/SlimMessageBus.Host.Kafka/DefaultKafkaHeaderSerializer.cs) is used to serialize header values.
196
-
If you need to specify a different serializer provide a specfic`IMessageSerializer` implementation (custom or one of the available serialization plugins):
190
+
If you need to specify a different serializer provide a specific`IMessageSerializer` implementation (custom or one of the available serialization plugins):
197
191
198
192
```cs
199
193
// MessageBusBuilder mbb;
@@ -209,6 +203,26 @@ mbb
209
203
210
204
## Consumers
211
205
206
+
### Consumer context
207
+
208
+
The consumer can implement the `IConsumerWithContext` interface to access the Kafka native message:
0 commit comments