Skip to content
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

Merged
merged 3 commits into from
Nov 18, 2024

Conversation

abhakish
Copy link
Contributor

With this change, based on configurations the block/chaincode events can now be sent to multiple topics.

}

for (String topic : optionalChaincodeDetails.get().getListenerTopics()) {
sendMessage(topic, payload, chaincodeName, fabricTxId, eventName, channelName, messageKey);
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

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

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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] List.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Comment on lines 106 to 116
if (!optionalChaincodeDetails.isPresent()
|| CollectionUtils.isEmpty(optionalChaincodeDetails.get().getListenerTopics())) {
sendMessage(
kafkaProperties.getEventListeners().get(0).getTopic(),
payload,
chaincodeName,
fabricTxId,
eventName,
channelName,
messageKey);
return;
Copy link
Contributor

@nithin-pankaj nithin-pankaj Oct 21, 2024

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

corrected

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) {
Copy link
Contributor

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?

@adityajoshi12 adityajoshi12 merged commit 16b6c99 into hyperledger-labs:main Nov 18, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants