apache / apache/pulsar-client-go

Unable to read BOOLEAN value from pulsar message

Open
#1,103 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
745
Forks
389
Avg merge
3d 20h
Merged PRs (30d)
3

Description

#### Expected behavior

Sending pulsar message with value type Boolean (wrapper class) in java with RSA encryption enabled but unable to read it at consumer side with go client. correct boolean value should be received provided correct decryption keys.

#### Actual behavior

value is always empty and not sure what will be the right schema type for boolean value.

#### Steps to reproduce

Here I am writing producer in go (integration test) instead of JAVA.
producer code:
```
keyReader := crypto.NewFileKeyReader('PROVIDE PATH TO PUBLIC KEY', 'PROVIDE PATH TO PRIVATE KEY')
producer, _ := client.CreateProducer(pulsar.ProducerOptions{
Topic: "some-topic",
Encryption: &pulsar.ProducerEncryptionInfo{
KeyReader: keyReader,
ProducerCryptoFailureAction: crypto.ProducerCryptoFailureActionFail,
Keys: []string{"client-rsa.pem"},
},
})

msgId, err := producer.Send(ctx, &pulsar.ProducerMessage{
Key: "abc-key",
Value: true,
})
```
Consumer code:
```
keyReader := crypto.NewFileKeyReader('PROVIDE PATH TO PUBLIC KEY', 'PROVIDE PATH TO PRIVATE KEY')
options := pulsar.ConsumerOptions{
Topic: topic-name,
Type: pulsar.Shared,
MessageChannel: channel,
SubscriptionInitialPosition: pulsar.SubscriptionPositionEarliest,
Decryption: &pulsar.MessageDecryptionInfo{
KeyReader: keyReader,
ConsumerCryptoFailureAction: crypto.ConsumerCryptoFailureActionFail,
},
}
```
How to use schematype for BOOLEAN value? I checked the https://github.com/apache/pulsar-client-go/blob/master/pulsar/schema.go but it is unclear for boolean value. any help would be appreciated.

**_Workaround/solution_**: Currently I am reading payload directly, checking if it is not nil and then converting it to bool.
```
payload := msg.Payload()
if payload != nil {
value := payload[0] != 0
}
```

#### System configuration
**Pulsar version**: 3.0.x

Contributor guide

Open the contributing guide

Research direction

Start with pulsar/schema.go and the provided Go producer and consumer snippets, then reproduce the encrypted Boolean message case described in the issue. Check how the Go client represents the Boolean schema and payload after decryption. Done means the consumer receives the Boolean value correctly, or the supported schema usage and limitation are documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
stream-processing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.