-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support multiple outbound topics for publishing blockchain events #152
Conversation
} | ||
|
||
for (String topic : optionalChaincodeDetails.get().getListenerTopics()) { | ||
sendMessage(topic, payload, chaincodeName, fabricTxId, eventName, channelName, messageKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does all these topics rely on the same Kafka Template? What if they belong to different outbound brokers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All topics rely on the same kafka template. We can provide multiple brokers in brokerHost
field in application.yml in comma separated manner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated code to create multiple producers and using RoutingKafkaTemplate
to dispatch message based on topic name configured while creating producer factory
110d6fd
to
ddf0b3b
Compare
offsetResetPolicy: <possible values are earliest / latest> if not provided, default will be latest. | ||
event-listener: | ||
event-listeners: <Note : This is a list and Multiple event listeners can be configured> | ||
brokerHost: <Comma separated list of boostrap servers> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] List.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
if (!optionalChaincodeDetails.isPresent() | ||
|| CollectionUtils.isEmpty(optionalChaincodeDetails.get().getListenerTopics())) { | ||
sendMessage( | ||
kafkaProperties.getEventListeners().get(0).getTopic(), | ||
payload, | ||
chaincodeName, | ||
fabricTxId, | ||
eventName, | ||
channelName, | ||
messageKey); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should we publish the chaincode details when the corresponding channel-chaincode names are not present in the Events config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corrected
Signed-off-by: Abhay Kishore <[email protected]>
Signed-off-by: Abhay Kishore <[email protected]>
public class EventPublishServiceImpl implements EventPublishService { | ||
|
||
@Autowired private KafkaProperties kafkaProperties; | ||
|
||
@Autowired private FabricProperties fabricProperties; | ||
|
||
@Autowired private KafkaTemplate<String, String> kafkaTemplate; | ||
@Autowired private RoutingKafkaTemplate routingKafkaTemplate; | ||
|
||
@Override | ||
public boolean sendMessage(String msg, String fabricTxId, String eventName, String channelName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this method is unused, could you also remove this from the service?
Signed-off-by: Abhay Kishore <[email protected]>
With this change, based on configurations the block/chaincode events can now be sent to multiple topics.