-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[consumer] Support parse broker metadata
- Loading branch information
ZhangJian He
committed
May 30, 2023
1 parent
4209987
commit 4969de7
Showing
7 changed files
with
135 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* 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. | ||
*/ | ||
// Run `docker-compose up -d` to set up the test environment for this test. | ||
#include <gtest/gtest.h> | ||
#include <pulsar/Client.h> | ||
|
||
using namespace pulsar; | ||
|
||
#ifndef TEST_ROOT_PATH | ||
#define TEST_ROOT_PATH "." | ||
#endif | ||
|
||
TEST(BrokerMetadataTest, testConsumeSuccess) { | ||
Client client{"pulsar://localhost:6650"}; | ||
Producer producer; | ||
Result producerResult = client.createProducer("persistent://public/default/testConsumeSuccess", producer); | ||
ASSERT_EQ(producerResult, ResultOk); | ||
Consumer consumer; | ||
Result consumerResult = | ||
client.subscribe("persistent://public/default/testConsumeSuccess", "testConsumeSuccess", consumer); | ||
ASSERT_EQ(consumerResult, ResultOk); | ||
const auto msg = MessageBuilder().setContent("testConsumeSuccess").build(); | ||
Result sendResult = producer.send(msg); | ||
ASSERT_EQ(sendResult, ResultOk); | ||
Message receivedMsg; | ||
Result receiveResult = consumer.receive(receivedMsg); | ||
ASSERT_EQ(receiveResult, ResultOk); | ||
ASSERT_EQ(receivedMsg.getDataAsString(), "testConsumeSuccess"); | ||
client.close(); | ||
} | ||
|
||
int main(int argc, char* argv[]) { | ||
::testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
version: '3' | ||
networks: | ||
pulsar: | ||
driver: bridge | ||
services: | ||
standalone: | ||
image: apachepulsar/pulsar:latest | ||
container_name: standalone | ||
hostname: local | ||
restart: "no" | ||
networks: | ||
- pulsar | ||
environment: | ||
- metadataStoreUrl=zk:localhost:2181 | ||
- clusterName=standalone-broker-metadata | ||
- advertisedAddress=localhost | ||
- advertisedListeners=external:pulsar://localhost:6650 | ||
- PULSAR_MEM=-Xms512m -Xmx512m -XX:MaxDirectMemorySize=256m | ||
- PULSAR_PREFIX_BROKER_ENTRY_METADATA_INTERCEPTORS=org.apache.pulsar.common.intercept.AppendIndexMetadataInterceptor | ||
- PULSAR_PREFIX_EXPOSING_BROKER_ENTRY_METADATA_TO_CLIENT_ENABLED=true | ||
ports: | ||
- "6650:6650" | ||
- "8080:8080" | ||
command: bash -c "bin/apply-config-from-env.py conf/standalone.conf && exec bin/pulsar standalone -nss -nfw" |