nats-io / nats.c

A C client for NATS
Apache License 2.0
390 stars 137 forks source link

The protobuf-c and ssh libraries are looked for when using the cnats static library. #678

Closed li1786422 closed 1 year ago

li1786422 commented 1 year ago

What version were you using?

natsclient 3.61

What environment was the server running in?

Static libraries generated by vs code cmake on windows using the visio studio 2022 compiler (for x64 architectures).

Is this defect reproducible?

When using the cnats static library, the link will look for protobuf-c libraries, and when generating the cnats library, the static library of protobuf-c is used.

Given the capability you are leveraging, describe your expectation?

Use the cnats library without relying on any other libraries.

Given the expectation, what is the defect you are observing?

Problems with static library generation mechanism under windows or cmake writing

levb commented 1 year ago

@li1786422 Are you observing this when linking the example apps? There was a recent conversation about it in the #C channel on Slack.

A quick workaround could be: if you are not using the now-deprecated NATS Streaming (aka STAN), you can compile with -DNATS_BUILD_STREAMING=OFF. STAN is the only part of the code that has a libprotobuf-c dependency.

levb commented 1 year ago

@li1786422 Did my suggestion above work for you?

li1786422 commented 1 year ago

ok I will try it

li1786422 commented 1 year ago

but jetstream also use libprotobuf-c to encode

li1786422 commented 1 year ago

please nat-c have the ues of key-value example?

kozlovic commented 1 year ago

but jetstream also use libprotobuf-c to encode

@li1786422 No, JetStream does not need libprotobuf-c, the protocols are JSON.

key-value example?

We don't have examples per-se, but you could have a look at the tests, this should give you all the help you need. Check tests that start with test_KeyValue:

li1786422 commented 1 year ago

ok

li1786422 commented 1 year ago

Is it possible to set the lifetime of a message on jetstream, I only found a MaxAge in the jetStreamConfig but I don't know if it's relevant.

kozlovic commented 1 year ago

@li1786422 No, you cannot set a TTL per-message. It is only at the stream level.

li1786422 commented 1 year ago

@li1786422 No, you cannot set a TTL per-message. It is only at the stream level. Please set the survival of a message to be limited only from MaxMsgSize, jsDiscardPolicy?and What is the meaning of MaxAge in jetStreamConfig, is it in years, months, days or seconds?

kozlovic commented 1 year ago

@li1786422 You will find more information about the stream configuration here. MaxAge is the time to live of messages in the stream expressed in nanoseconds (this comes from Go time.Duration that is an int64 and the unit is nanoseconds).

li1786422 commented 1 year ago

Thanks Sorry I only looked in the source code and didn't find that explanation.

@li1786422您可以在此处找到有关流配置的更多信息。MaxAge 是流中消息的生存时间,以纳秒表示(这来自 Go time.Duration,是一个 int64,单位是纳秒)。 Thanks Sorry I only looked in the source code and didn't find that explanation.

li1786422 commented 1 year ago

Please use js_SubscribeSync(&sub, js, subj, &jsOpts, NULL, NULL); to subscribe to a topic, and after that subscribe to a topic by while(1){ natsSubscription_NextMsg(&msg, sub, 5000); if (s ! = NATS_OK) break;

        if (start == 0)
        start = nats_Now(); s = natsMsg_NextMsg(sub, 5000); 
       if (s ! = NATS_OK)
        sleep(1)//sleep 1 seconds this is pseudocode
        s = natsMsg_Ack(msg, nullptr);
        The method natsMsg_Destroy(msg);

} keeps printing the data, what is the reason for the garbled order of the fetched data When the client pulls data, how to ensure the correct order of the data when it stays for a while and then pulls the data?

kozlovic commented 1 year ago

@li1786422 I am not sure I understand your question. Are you saying that messages "1, 2, 3, 4, 5" are in the stream and using the code above you don't see messages "1, 2, 3, 4, 5" being received? We would need to see the content of the subscribe options to see for instance if you have created a queue (and have multiple instances running) instead of a regular consumer, or if you have a MaxAckWait that is way too small (smaller than your sleep interval) that then causes the server to redeliver messages.

Also, I would prefer that either we close this issue (related to CMake) if the original problem is somehow addressed and that you open new issues when dealing with different questions/issues. Is that ok?

li1786422 commented 1 year ago

@li1786422 I am not sure I understand your question. Are you saying that messages "1, 2, 3, 4, 5" are in the stream and using the code above you don't see messages "1, 2, 3, 4, 5" being received? We would need to see the content of the subscribe options to see for instance if you have created a queue (and have multiple instances running) instead of a regular consumer, or if you have a MaxAckWait that is way too small (smaller than your sleep interval) that then causes the server to redeliver messages.

Also, I would prefer that either we close this issue (related to CMake) if the original problem is somehow addressed and that you open new issues when dealing with different questions/issues. Is that ok? this question I have commited ,The issue is Subscription Data Disorder Problem #690 Please help me with the answer thanks

levb commented 1 year ago

Closing since the original issue is resolved, and the new ticket filed