shibd opened a new issue, #352: URL: https://github.com/apache/pulsar-client-cpp/issues/352
### Search before asking - [X] I searched in the [issues](https://github.com/apache/pulsar-client-cpp/issues) and found nothing similar. ### Version - master - 3.4.1 Candidate 1 ### Minimal reproduce step ```c /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ #include <gtest/gtest.h> #include <pulsar/c/client.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <future> static const char *lookup_url = "pulsar://localhost:6650"; struct flush_ctx { pulsar_result result; }; TEST(c_ProducerTest, testBatchSendAndFlush) { pulsar_client_configuration_t *conf = pulsar_client_configuration_create(); pulsar_client_t *client = pulsar_client_create(lookup_url, conf); char topic[128]; snprintf(topic, sizeof(topic), "c-consumer-test-batch-receive-%ld", time(NULL)); pulsar_producer_configuration_t *producer_conf = pulsar_producer_configuration_create(); pulsar_producer_configuration_set_batching_enabled(producer_conf, true); pulsar_producer_configuration_set_batching_max_messages(producer_conf, 100); pulsar_producer_configuration_set_batching_max_publish_delay_ms(producer_conf, 10000); pulsar_producer_t *producer; pulsar_result result = pulsar_client_create_producer(client, topic, producer_conf, &producer); ASSERT_EQ(pulsar_result_Ok, result); // Sending two more messages proves that the batch_receive_policy works. for (int i = 0; i < 5; i++) { pulsar_message_t *msg = pulsar_message_create(); char buf[128]; snprintf(buf, sizeof(buf), "msg-%d", i); pulsar_message_set_content(msg, buf, strlen(buf) + 1); pulsar_producer_send_async(producer, msg, [](pulsar_result async_result, pulsar_message_id_t *msg_id, void *ctx){ printf("sedd success\n"); }, nullptr); pulsar_message_free(msg); } printf("start flush \n"); struct flush_ctx flushCtx = {pulsar_result_UnknownError}; pulsar_producer_flush_async(producer, [](pulsar_result result, void *ctx){ auto *context = static_cast<struct flush_ctx *>(ctx); printf("flush callback %d\n", context->result); context->result = result; printf("call context %d\n", context->result); delete context; }, &flushCtx); printf("end flush \n"); sleep(2); pulsar_producer_close(producer); pulsar_client_close(client); } ``` ### What did you expect to see? success. ### What did you see instead? Process finished with exit code 134 (interrupted by signal 6: SIGABRT) ### Anything else? flush's callback is called twice. ### Are you willing to submit a PR? - [ ] I'm willing to submit a PR! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
