Hi, Can I reify protobuf message (async message) ...
# pact-plugins
t
Hi, Can I reify protobuf message (async message) like a normal message? I expect to able to get message object without any matching and pass it to a callback/handler.
t
Yes
Oh wait, sorry, I misread the question. I don’t actually know - but I would assume you can
t
when I call ffi method
pactffi_message_reify
I cant get something that I can decode into original object
m
There is a way to get it Tien, when I'm at my computer I'll check. There is a message iterator you can use to get the raw btye array, which you can use to pass it back on to the test without matchers etc
👍 1
t
Never mind. I think I went to the wrong direction. After adding
debug!
and compiling
rust_ffi
I think
assume you can
from Timothy is the correct answer for now. I got an error before I can confirm. I will ask in another thread.
👍 1
I can confirm the answer is
yes
🙌 1
m
So yes, you can get them via the message iterator, i.e. these messages
Copy code
pactffi_pact_handle_get_message_iter
pactffi_pact_message_iter_next
pactffi_message_get_contents_length
pactffi_message_get_contents_bin
There are two
sync
versions of the iterator also.
Is that right @uglyog?
💯 1
(or rather, that’s what I’m doing - I hope it’s right)
t
I don't need to call those ffi methods. I just need to call
pactffi_message_reify
. The reason it doesn't work before is I went to the wrong direction (typo in pact:proto, missing content type
application/protobuf
, wrong matching format...)
m
on wow, that returns back the byte array? I thought I tried that and it didn’t work. that’s MUCH easier 😆
I guess the type declaration is
char*
, but that’s just an array of bytes
t
It return json like this https://github.com/tienvx/pact-php-protobuf/blob/main/example/async-message/broker/pacts/protobufMessageConsumer-protobufMessageProvider.json#L7 All I need to do is
base64_decode
and merge to object then pass to callback