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
Copy file name to clipboardExpand all lines: README.md
+44-7Lines changed: 44 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,27 +32,40 @@ Simple start consist only from 3 simple steps.
32
32
33
33
#### 2. Configure Producer
34
34
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
+
publicclassTestProducerConfiguration {
40
+
41
+
@Bean
42
+
publicProducerFactoryproducerFactory() {
43
+
returnnewProducerFactory()
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.
36
51
37
52
```java
38
53
@Service
39
54
classMyProducer {
40
55
41
-
privatefinalstaticStringTOPIC="my-topic";
42
-
43
56
@Autowired
44
57
privatePulsarTemplate<MyMsg> producer;
45
58
46
59
voidsend(MyMsgmsg) {
47
-
producer.send(TOPIC, msg);
60
+
producer.send("my-topic", msg);
48
61
}
49
62
}
50
63
51
64
```
52
65
53
66
#### 3. Configure Consumer
54
67
55
-
Just annotate your service with `@PulsarConsumer` annotation.
68
+
Annotate your service method with `@PulsarConsumer` annotation.
56
69
57
70
```java
58
71
@Service
@@ -63,12 +76,36 @@ class MyConsumer {
63
76
producer.send(TOPIC, msg);
64
77
}
65
78
}
66
-
67
79
```
68
80
69
81
## Documentation
70
82
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.
0 commit comments