Skip to content

Commit

Permalink
Remove unused method to publish events
Browse files Browse the repository at this point in the history
Signed-off-by: Abhay Kishore <abhay.kishore@walmart.com>
  • Loading branch information
abhakish committed Oct 22, 2024
1 parent b8a187e commit 5564e57
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@
@ConditionalOnProperty("kafka.event-listeners[0].brokerHost")
public interface EventPublishService {

/**
* @param payload String message payload
* @param fabricTxId String Fabric transaction ID
* @param eventName String chaincode event-name
* @param channelName String Name of the channel where the event was generated.
* @return status boolean status of msg sent
*/
boolean sendMessage(
final String payload, String fabricTxId, String eventName, String channelName);

/**
* @param payload String message payload
* @param fabricTxId String Fabric transaction ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,64 +28,6 @@ public class EventPublishServiceImpl implements EventPublishService {

@Autowired private RoutingKafkaTemplate routingKafkaTemplate;

@Override
public boolean sendMessage(String msg, String fabricTxId, String eventName, String channelName) {

log.debug("Send Event Message - " + msg);

boolean status = true;

try {

ProducerRecord<Object, Object> producerRecord =
new ProducerRecord<>(
kafkaProperties.getEventListeners().get(0).getTopic(),
String.valueOf(msg.hashCode()),
msg);

producerRecord
.headers()
.add(
new RecordHeader(FabricClientConstants.FABRIC_TRANSACTION_ID, fabricTxId.getBytes()));
producerRecord
.headers()
.add(new RecordHeader(FabricClientConstants.FABRIC_EVENT_NAME, eventName.getBytes()));
producerRecord
.headers()
.add(new RecordHeader(FabricClientConstants.FABRIC_CHANNEL_NAME, channelName.getBytes()));

ListenableFuture<SendResult<Object, Object>> future =
routingKafkaTemplate.send(producerRecord);

future.addCallback(
new ListenableFutureCallback<SendResult<Object, Object>>() {

@Override
public void onSuccess(SendResult<Object, Object> result) {
log.info(
"Sent message '{}' to partition {} for offset {}",
msg,
result.getRecordMetadata().partition(),
result.getRecordMetadata().offset());
}

@Override
public void onFailure(Throwable ex) {
log.error(
"Failed to send message event for Transaction ID {} due to {}",
fabricTxId,
ex.getMessage());
}
});

} catch (Exception ex) {
status = false;
log.error("Error sending message - " + ex.getMessage());
}

return status;
}

@Override
public void publishChaincodeEvents(
String payload,
Expand Down

0 comments on commit 5564e57

Please sign in to comment.