Skip to content

Commit bad1170

Browse files
committed
Updated readme with information about properties configuration and added quick start info about producer factory.
1 parent 2e2fbf5 commit bad1170

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

README.md

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,40 @@ Simple start consist only from 3 simple steps.
3232

3333
#### 2. Configure Producer
3434

35-
Just inject `PulsarTemplate` into your service
35+
Create your configuration class with all producers you would like to register.
36+
37+
```java
38+
@Configuration
39+
public class TestProducerConfiguration {
40+
41+
@Bean
42+
public ProducerFactory producerFactory() {
43+
return new ProducerFactory()
44+
.addProducer("my-topic", MyMsg.class)
45+
.addProducer("other-topic", String.class);
46+
}
47+
}
48+
```
49+
50+
Use registered producers by simply injecting the `PulsarTemplate` into your service.
3651

3752
```java
3853
@Service
3954
class MyProducer {
4055

41-
private final static String TOPIC = "my-topic";
42-
4356
@Autowired
4457
private PulsarTemplate<MyMsg> producer;
4558

4659
void send(MyMsg msg) {
47-
producer.send(TOPIC, msg);
60+
producer.send("my-topic", msg);
4861
}
4962
}
5063

5164
```
5265

5366
#### 3. Configure Consumer
5467

55-
Just annotate your service with `@PulsarConsumer` annotation.
68+
Annotate your service method with `@PulsarConsumer` annotation.
5669

5770
```java
5871
@Service
@@ -63,12 +76,36 @@ class MyConsumer {
6376
producer.send(TOPIC, msg);
6477
}
6578
}
66-
6779
```
6880

6981
## Documentation
7082

71-
TODO
83+
### Configuration
84+
85+
Default configuration:
86+
```properties
87+
pulsar.serviceUrl=pulsar://localhost:6650
88+
pulsar.ioThreads=10
89+
pulsar.listenerThreads=10
90+
pulsar.isEnableTcpNoDelay=false
91+
pulsar.keepAliveIntervalSec=20
92+
pulsar.connectionTimeoutSec=10
93+
pulsar.operationTimeoutSec=15
94+
pulsar.startingBackoffIntervalMs=100
95+
pulsar.maxBackoffIntervalSec=10
96+
```
97+
98+
Properties explained:
99+
100+
- `pulsar.serviceUrl` - URL used to connect to pulsar cluster.
101+
- `pulsar.ioThreads` - Number of threads to be used for handling connections to brokers.
102+
- `pulsar.listenerThreads` - Set the number of threads to be used for message listeners/subscribers.
103+
- `pulsar.isEnableTcpNoDelay` - Whether to use TCP no-delay flag on the connection, to disable Nagle algorithm.
104+
- `pulsar.keepAliveInterval` - Keep alive interval for each client-broker-connection.
105+
- `pulsar.connectionTimeoutSec` - duration of time to wait for a connection to a broker to be established. If the duration passes without a response from the broker, the connection attempt is dropped.
106+
- `pulsar.operationTimeoutSec` - Operation timeout.
107+
- `pulsar.startingBackoffIntervalMs` - Duration of time for a backoff interval (Retry algorithm).
108+
- `pulsar.maxBackoffIntervalSec` - The maximum duration of time for a backoff interval (Retry algorithm).
72109

73110
## Contributing
74111

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

0 commit comments

Comments
 (0)