Hi <@U078Y59KC3B> Am trying create a pulsar funct...
# ask-ai
r
Hi @RunLLM Am trying create a pulsar function in Go. I would like to use Manual delivery semantics (ProcessingGuarantees_MANUAL) as for my function, i would like to have the control for ack() and nack(). as mentioned in the docs, if i want to do a ack(), i need to do context.getCurrentRecord().ack(). But in Go sdk, fctx.GetCurrentRecord() returns a pulsar.Message not a pulsar.ConsumerMessage. And i don't have the input consumer info anywhere from fctx. So i cannot do a ack() manually inside my Go function my requirement is to manually ack() myself. please help!!
r
To manually acknowledge messages in a Pulsar function using the Go SDK, you need to ensure that your function is set up to use manual delivery semantics. The Go SDK provides a way to handle message acknowledgments manually, but it seems there might be some confusion regarding the
ack()
method. According to the Pulsar Go Function documentation, the
GetCurrentRecord()
method returns a
pulsar.Message
, which does not directly expose an
ack()
method. Instead, you should use the
ackInputMessage
method within your function's context to acknowledge messages manually. This method is part of the internal handling of messages in the Pulsar Go SDK. If you want more detailed guidance on implementing manual acknowledgment in your function, please let me know, and I can provide a step-by-step breakdown. Sources: - Pulsar Go Function Instance 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
r
@RunLLM ackInputMessage() is not exported outside for usage
r
It seems likely that the
ackInputMessage()
method is not directly accessible for use outside the internal implementation of the Pulsar Go SDK. This means you might need to handle acknowledgments differently in your Go function. One approach is to use the
respondMessage()
method, which is used internally to handle acknowledgments. This method takes a
pulsar.Message
and a boolean indicating whether to acknowledge (
true
) or negatively acknowledge (
false
) the message. You can call this method with the appropriate parameters to manually acknowledge messages. If you need more detailed guidance on how to implement this in your function, please let me know, and I can provide further assistance. Sources: - Pulsar Go Function Instance 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
r
@RunLLM respondMessage() is also not exposed outside
r
If both
ackInputMessage()
and
respondMessage()
are not exposed for external use, you may need to directly interact with the consumer to manually acknowledge messages. In the Pulsar Go client, you can use the
Ack()
method on the consumer to acknowledge messages. Here's a general approach you can take: 1. Access the Consumer: Ensure you have access to the consumer instance that is receiving messages. This might require modifying how your function is set up to ensure the consumer is accessible. 2. Acknowledge Messages: Use the
Ack()
method on the consumer to manually acknowledge messages. You will need to pass the
pulsar.Message
to this method. If you need more detailed guidance on how to set this up, please let me know, and I can provide further assistance. Sources: - Pulsar Go Client Consumer Interface 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
r
@RunLLM consumer object that is receiving the messages.is part of the goInstance object from the function. even this too, is not exposed, please check
r
If the consumer object within the
goInstance
is not exposed, it limits direct access to the consumer for manual acknowledgment. This is a design choice in the Pulsar Go SDK to encapsulate the consumer logic within the function instance. To work around this limitation, you might consider the following options: 1. Modify the SDK: If you have control over the SDK, you could modify it to expose the necessary methods or objects. This would involve making the consumer or its methods accessible from outside the
goInstance
. 2. Contribute to the SDK: If modifying the SDK is not feasible, consider contributing to the Pulsar Go SDK by proposing changes that expose the necessary functionality for manual acknowledgment. This could involve creating a pull request or opening an issue to discuss the need for such a feature. 3. Alternative Approaches: If neither of the above options is viable, you might need to explore alternative approaches to achieve your desired functionality, such as using a different SDK or language that provides the required level of control. If you need more detailed guidance on any of these options, please let me know. Sources: - Pulsar Go Function Instance 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.