├── docs ├── _config.yml ├── images │ ├── ha.png │ ├── wx.jpg │ ├── actor1.png │ ├── actor2.png │ ├── actor3.png │ ├── arch1.png │ ├── arch3.png │ ├── arch4.png │ ├── idea.png │ ├── mysql1.png │ ├── mysql2.png │ ├── design1.png │ ├── design2.png │ ├── design3.png │ ├── design4.png │ ├── support1.png │ ├── support2.jpg │ ├── support3.png │ ├── logo │ │ ├── ctrip.png │ │ ├── qunar.png │ │ ├── yeepay.png │ │ ├── hongsong.png │ │ ├── iymedia.png │ │ ├── teammark.png │ │ ├── bianlifeng.png │ │ ├── jinhui365.png │ │ └── soonchina.png │ └── circuitbreaker1.png └── cn │ ├── contributing.md │ ├── support.md │ ├── opensource.md │ ├── share.md │ ├── debug.md │ ├── faq.md │ ├── code.md │ ├── trace.md │ ├── quickstart.md │ └── net.md ├── qmq-dist ├── conf │ ├── valid-api-tokens.properties │ ├── broker-http-port-map.properties │ ├── gateway.properties │ ├── hbase.properties │ ├── delay.properties │ ├── metaserver.properties │ ├── datasource.properties │ ├── backup.properties │ ├── broker.properties │ ├── watchdog.properties │ └── logback.xml ├── sql │ ├── 001_add_ext_to_broker_group.sql │ ├── init_backup_hbase.sql │ ├── init_backup.sql │ └── init_client.sql └── bin │ ├── backup-env.sh │ ├── broker-env.sh │ ├── delay-env.sh │ ├── metaserver-env.sh │ ├── tools-env.sh │ ├── watchdog-env.sh │ ├── tools.cmd │ ├── watchdog.cmd │ ├── broker.cmd │ ├── backup.cmd │ ├── delay.cmd │ ├── metaserver.cmd │ ├── base.cmd │ ├── base.sh │ └── tools.sh ├── clients ├── erlang │ ├── rebar.config │ ├── rebar3 │ ├── .gitignore │ ├── src │ │ └── qmqec.app.src │ └── README.md ├── cpp │ └── pitocin │ │ ├── test │ │ ├── test_link.mk │ │ ├── test_conn.mk │ │ ├── test_http.mk │ │ ├── test_get_time.mk │ │ ├── test_meta_tcp.mk │ │ ├── test_client1.mk │ │ ├── test_broker_heartbeat.mk │ │ ├── test_client2.mk │ │ ├── test_http.cpp │ │ ├── test_client1.cpp │ │ ├── test_link.cpp │ │ └── test_conn.cpp │ │ ├── lib │ │ └── http-parser-master.zip │ │ └── .gitignore └── csharp │ └── qmqclient │ ├── Id │ ├── IdGenerator.cs │ └── TimestampIdGenerator.cs │ ├── Transport │ ├── Client.cs │ ├── Sender.cs │ ├── Processor.cs │ ├── KeepliveStrategy.cs │ ├── ChannelContext.cs │ ├── InputStream.cs │ ├── Handler.cs │ ├── Channel.cs │ ├── EncodeHandler.cs │ ├── AbstractHandler.cs │ └── EventLoop.cs │ ├── Exceptions │ ├── RemoteException.cs │ ├── BrokerRejectException.cs │ ├── BrokerReadOnlyException.cs │ ├── NoWritableBrokerException.cs │ ├── EnqueueException.cs │ ├── DuplicateMessageException.cs │ ├── BlockMessageException.cs │ ├── NeedRetryException.cs │ └── BrokerUnassignedException.cs │ ├── Consumer │ ├── IRequestHandler.cs │ ├── PulledMessageHandler.cs │ ├── ConsumeMode.cs │ ├── IConsumerRegister.cs │ ├── IMessageHandleTask.cs │ └── PullResult.cs │ ├── Codec │ ├── NewQmq │ │ ├── PayloadHolder.cs │ │ ├── Datagram.cs │ │ ├── SendMessageResponseCode.cs │ │ └── RemotingHeader.cs │ ├── Encoder.cs │ ├── Decoder.cs │ └── Flag.cs │ ├── tag │ └── TagType.cs │ ├── MessageSendStateListener.cs │ ├── Tx │ └── MessageStore.cs │ ├── MessageConsumer.cs │ ├── ProducerMessage.cs │ ├── Util │ ├── HostAndPort.cs │ ├── DateTimeUtils.cs │ ├── NetUtils.cs │ ├── StaticRandom.cs │ ├── WaitHolder.cs │ ├── StateChangedArgs.cs │ └── FloatingParser.cs │ ├── NewQmq │ ├── IDataTransformer.cs │ ├── Model │ │ ├── AckRequest.cs │ │ ├── PullMessageRequest.cs │ │ └── BrokerGroupInfo.cs │ ├── LoadBalance.cs │ ├── PullController.cs │ └── MesssageAckPayloadHolder.cs │ ├── Cluster │ └── ICluster.cs │ ├── Model │ ├── ConsumerRejectException.cs │ ├── ChannelState.cs │ ├── QueryRequest.cs │ ├── HandlerMismatchException.cs │ └── ACKMessage.cs │ ├── qmqclient.csproj │ ├── Pull │ └── IPullConsumer.cs │ ├── MessageSubscriber.cs │ ├── MessageProducer.cs │ └── ListenerHolder.cs ├── Makefile ├── qmq-watchdog └── src │ └── main │ ├── resources │ └── META-INF │ │ └── services │ │ └── qunar.tc.qmq.task.database.IDatabaseDriver │ └── java │ └── qunar │ └── tc │ └── qmq │ └── task │ ├── LeaderChangedListener.java │ ├── model │ ├── DataSourceInfo.java │ └── DataSourceInfoStatus.java │ └── database │ ├── DatasourceWrapper.java │ ├── IDatabaseDriver.java │ └── IDataSourceService.java ├── qmq-client └── src │ ├── main │ ├── resources │ │ └── META-INF │ │ │ ├── spring.handlers │ │ │ └── spring.schemas │ └── java │ │ └── qunar │ │ └── tc │ │ └── qmq │ │ ├── consumer │ │ ├── pull │ │ │ ├── PullStrategy.java │ │ │ ├── AckHook.java │ │ │ ├── PulledMessageFilter.java │ │ │ ├── AlwaysPullStrategy.java │ │ │ ├── PushConsumer.java │ │ │ └── PushConsumerParam.java │ │ └── register │ │ │ └── ConsumerRegister.java │ │ ├── common │ │ ├── ClientIdProvider.java │ │ ├── EnvProvider.java │ │ ├── ClientIdProviderFactory.java │ │ └── StatusSource.java │ │ └── producer │ │ ├── sender │ │ ├── Router.java │ │ └── Route.java │ │ ├── idgenerator │ │ └── IdGenerator.java │ │ ├── tx │ │ ├── SqlStatementProvider.java │ │ └── spring │ │ │ └── RouterSelector.java │ │ ├── RegistryResolver.java │ │ └── QueueSender.java │ └── test │ └── resources │ └── logback.xml ├── qmq-server └── src │ └── main │ ├── resources │ └── META-INF │ │ └── services │ │ └── qunar.tc.qmq.store.PullMessageFilter │ └── java │ └── qunar │ └── tc │ └── qmq │ ├── store │ ├── EnvRuleGetter.java │ └── PullMessageFilter.java │ ├── processor │ └── filters │ │ ├── Invoker.java │ │ └── ReceiveFilter.java │ ├── sync │ └── master │ │ └── SyncProcessor.java │ └── utils │ └── ConsumerGroupUtils.java ├── qmq-store └── src │ └── main │ └── java │ └── qunar │ └── tc │ └── qmq │ └── store │ ├── MemTableFactory.java │ ├── FlushHook.java │ ├── LogVisitor.java │ ├── Serde.java │ ├── CheckpointLoader.java │ ├── MessageFilter.java │ ├── Visitable.java │ ├── Action.java │ ├── AppendMessageStatus.java │ ├── ActionReaderWriter.java │ ├── MessageAppender.java │ ├── GetMessageStatus.java │ └── buffer │ └── Buffer.java ├── .github └── ISSUE_TEMPLATE │ └── bug_template.md ├── qmq-common └── src │ └── main │ └── java │ └── qunar │ └── tc │ └── qmq │ ├── batch │ ├── MpscLinkedQueuePad0.java │ ├── MpscLinkedQueuePad1.java │ └── Processor.java │ ├── utils │ ├── SubjectUtils.java │ └── ObjectUtils.java │ ├── common │ └── Disposable.java │ ├── configuration │ ├── Listener.java │ └── DynamicConfigFactory.java │ ├── metrics │ ├── QmqMeter.java │ ├── QmqTimer.java │ └── QmqCounter.java │ ├── broker │ └── BrokerLoadBalance.java │ └── service │ └── exceptions │ └── BlockMessageException.java ├── qmq-server-common └── src │ └── main │ └── java │ └── qunar │ └── tc │ └── qmq │ ├── jdbc │ ├── DataSourceFactory.java │ └── DefaultDataSourceFactory.java │ ├── netty │ └── ConnectionEventHandler.java │ └── meta │ ├── BrokerRequestType.java │ └── BrokerRegisterResponse.java ├── qmq-metaserver └── src │ └── main │ └── java │ └── qunar │ └── tc │ └── qmq │ └── meta │ ├── model │ ├── MetaServerConst.java │ └── ClientSubjectInfo.java │ ├── spi │ ├── ClientRegisterAuthService.java │ ├── impl │ │ └── DefaultClientRegisterAuthService.java │ └── ClientRegisterAuthFactory.java │ ├── exception │ ├── NoSuchServiceException.java │ └── ServiceNotOfRequiredTypeException.java │ ├── route │ ├── ExtendService.java │ ├── SubjectRouteExtend.java │ ├── SubjectRegisterService.java │ ├── SubjectConsumerService.java │ └── SubjectRouter.java │ ├── store │ ├── ClientDbConfigurationStore.java │ └── ClientMetaInfoStore.java │ ├── cache │ └── CacheManagerExtend.java │ ├── web │ └── ResultStatus.java │ ├── loadbalance │ └── LoadBalanceFactory.java │ ├── management │ └── MetaManagementAction.java │ └── utils │ └── SubjectUtils.java ├── qmq-backup └── src │ ├── main │ └── java │ │ └── qunar │ │ └── tc │ │ └── qmq │ │ └── backup │ │ ├── spi │ │ ├── DeadMessageSpiHandler.java │ │ ├── impl │ │ │ └── DefaultDeadMessageSpiHandler.java │ │ └── DeadMessageHandlerFactory.java │ │ ├── base │ │ ├── Flushable.java │ │ ├── ScheduleFlushable.java │ │ ├── UnsupportedArgumentsException.java │ │ └── QmqBackupException.java │ │ ├── service │ │ ├── FileStore.java │ │ ├── SyncLogIterator.java │ │ ├── BatchBackup.java │ │ └── DicService.java │ │ ├── store │ │ ├── DicStore.java │ │ ├── RocksDBStore.java │ │ ├── RecordStore.java │ │ └── MessageStore.java │ │ ├── config │ │ └── BackupConfig.java │ │ └── sync │ │ └── LogSyncDispatcher.java │ └── test │ └── http │ └── FindMessageApi.http ├── .gitignore ├── qmq-demo ├── README.md └── src │ └── main │ ├── resources │ └── application.properties │ └── java │ └── qunar │ └── tc │ └── qmq │ └── demo │ └── dao │ └── OrderRepository.java ├── qmq-api ├── pom.xml └── src │ └── main │ └── java │ └── qunar │ └── tc │ └── qmq │ ├── BaseConsumer.java │ ├── MessageListener.java │ ├── ListenerHolder.java │ ├── IdempotentAttachable.java │ ├── FilterAttachable.java │ ├── TransactionProvider.java │ └── TransactionListener.java ├── qmq-metrics-prometheus └── src │ └── main │ └── resources │ └── META-INF │ └── services │ └── qunar.tc.qmq.metrics.QmqMetricRegistry ├── qmq-remoting └── src │ └── main │ └── java │ └── qunar │ └── tc │ └── qmq │ ├── protocol │ ├── consumer │ │ └── PullFilter.java │ └── PayloadHolder.java │ ├── netty │ ├── client │ │ ├── Response.java │ │ └── HttpResponseCallback.java │ └── exception │ │ ├── RemoteBusyException.java │ │ ├── RemoteResponseUnreadableException.java │ │ ├── EncodeException.java │ │ └── BrokerRejectException.java │ └── metainfoclient │ └── ConsumerStateChangedListener.java ├── qmq-delay-server └── src │ └── main │ └── java │ └── qunar │ └── tc │ └── qmq │ └── delay │ ├── EventListener.java │ ├── Switchable.java │ ├── receiver │ ├── Invoker.java │ └── filter │ │ └── Filter.java │ ├── base │ ├── AppendException.java │ └── GroupSendException.java │ ├── sync │ └── slave │ │ └── SyncLogProcessor.java │ ├── store │ ├── log │ │ ├── SegmentContainer.java │ │ └── Log.java │ ├── visitor │ │ └── LogVisitor.java │ ├── DelaySegmentValidator.java │ ├── model │ │ └── RecordResult.java │ └── appender │ │ └── LogAppender.java │ ├── sender │ └── DelayProcessor.java │ └── container │ └── Bootstrap.java └── qmq-sync └── src └── main └── java └── qunar └── tc └── qmq └── sync ├── SyncLogProcessor.java └── SyncType.java /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /qmq-dist/conf/valid-api-tokens.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /clients/erlang/rebar.config: -------------------------------------------------------------------------------- 1 | {erl_opts, [debug_info]}. 2 | {deps, []}. -------------------------------------------------------------------------------- /qmq-dist/conf/broker-http-port-map.properties: -------------------------------------------------------------------------------- 1 | [/]= -------------------------------------------------------------------------------- /qmq-dist/conf/gateway.properties: -------------------------------------------------------------------------------- 1 | # 可选, 暴露http服务的端口,默认值是8080 2 | gateway.port=8080 -------------------------------------------------------------------------------- /docs/images/ha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/ha.png -------------------------------------------------------------------------------- /docs/images/wx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/wx.jpg -------------------------------------------------------------------------------- /clients/erlang/rebar3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/clients/erlang/rebar3 -------------------------------------------------------------------------------- /docs/images/actor1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/actor1.png -------------------------------------------------------------------------------- /docs/images/actor2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/actor2.png -------------------------------------------------------------------------------- /docs/images/actor3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/actor3.png -------------------------------------------------------------------------------- /docs/images/arch1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/arch1.png -------------------------------------------------------------------------------- /docs/images/arch3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/arch3.png -------------------------------------------------------------------------------- /docs/images/arch4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/arch4.png -------------------------------------------------------------------------------- /docs/images/idea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/idea.png -------------------------------------------------------------------------------- /docs/images/mysql1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/mysql1.png -------------------------------------------------------------------------------- /docs/images/mysql2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/mysql2.png -------------------------------------------------------------------------------- /docs/images/design1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/design1.png -------------------------------------------------------------------------------- /docs/images/design2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/design2.png -------------------------------------------------------------------------------- /docs/images/design3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/design3.png -------------------------------------------------------------------------------- /docs/images/design4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/design4.png -------------------------------------------------------------------------------- /docs/images/support1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/support1.png -------------------------------------------------------------------------------- /docs/images/support2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/support2.jpg -------------------------------------------------------------------------------- /docs/images/support3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/support3.png -------------------------------------------------------------------------------- /docs/images/logo/ctrip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/logo/ctrip.png -------------------------------------------------------------------------------- /docs/images/logo/qunar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/logo/qunar.png -------------------------------------------------------------------------------- /docs/images/logo/yeepay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/logo/yeepay.png -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | package: 2 | mvn -U clean package -Pdist -Dmaven.test.skip=true -DskipTests -am -pl qmq-dist 3 | -------------------------------------------------------------------------------- /docs/images/logo/hongsong.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/logo/hongsong.png -------------------------------------------------------------------------------- /docs/images/logo/iymedia.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/logo/iymedia.png -------------------------------------------------------------------------------- /docs/images/logo/teammark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/logo/teammark.png -------------------------------------------------------------------------------- /qmq-dist/sql/001_add_ext_to_broker_group.sql: -------------------------------------------------------------------------------- 1 | alter table broker_group add column `ext` text COMMENT '扩展信息'; -------------------------------------------------------------------------------- /docs/images/circuitbreaker1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/circuitbreaker1.png -------------------------------------------------------------------------------- /docs/images/logo/bianlifeng.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/logo/bianlifeng.png -------------------------------------------------------------------------------- /docs/images/logo/jinhui365.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/logo/jinhui365.png -------------------------------------------------------------------------------- /docs/images/logo/soonchina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/docs/images/logo/soonchina.png -------------------------------------------------------------------------------- /qmq-dist/bin/backup-env.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | 4 | JAVA_HOME="" 5 | JAVA_OPTS="" 6 | -------------------------------------------------------------------------------- /qmq-dist/bin/broker-env.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | 4 | JAVA_HOME="" 5 | JAVA_OPTS="" 6 | -------------------------------------------------------------------------------- /qmq-dist/bin/delay-env.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | 4 | JAVA_HOME="" 5 | JAVA_OPTS="" 6 | -------------------------------------------------------------------------------- /docs/cn/contributing.md: -------------------------------------------------------------------------------- 1 | 如果你遇到问题或需要新功能,欢迎[创建issue] 2 | 3 | 如果你可以解决某个[issue], 欢迎发送PR 4 | 5 | 如果你觉得该项目对你有帮助,也请不吝Star -------------------------------------------------------------------------------- /qmq-dist/bin/metaserver-env.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | 4 | JAVA_HOME="" 5 | JAVA_OPTS="-Xms1g -Xmx1g" 6 | -------------------------------------------------------------------------------- /qmq-dist/bin/tools-env.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | 4 | JAVA_HOME="" 5 | JAVA_OPTS="-Xms256m -Xmx256m" 6 | 7 | -------------------------------------------------------------------------------- /qmq-dist/conf/hbase.properties: -------------------------------------------------------------------------------- 1 | hbase.zookeeper.quorum= 2 | hbase.zookeeper.znode.parent= 3 | # Also Other Settings About HBase 4 | -------------------------------------------------------------------------------- /clients/cpp/pitocin/test/test_link.mk: -------------------------------------------------------------------------------- 1 | test_link: test_link.cpp ../src/LinkNode.hpp 2 | g++ -g -std=c++14 -o test_link test_link.cpp 3 | -------------------------------------------------------------------------------- /qmq-dist/bin/watchdog-env.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | 4 | JAVA_HOME="" 5 | JAVA_OPTS="-Xms512m -Xmx512m" 6 | 7 | -------------------------------------------------------------------------------- /clients/cpp/pitocin/lib/http-parser-master.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qunarcorp/qmq/HEAD/clients/cpp/pitocin/lib/http-parser-master.zip -------------------------------------------------------------------------------- /qmq-watchdog/src/main/resources/META-INF/services/qunar.tc.qmq.task.database.IDatabaseDriver: -------------------------------------------------------------------------------- 1 | qunar.tc.qmq.task.database.MysqlMMMDatabaseDriver -------------------------------------------------------------------------------- /qmq-client/src/main/resources/META-INF/spring.handlers: -------------------------------------------------------------------------------- 1 | http\://www.qunar.com/schema/qmq=qunar.tc.qmq.consumer.annotation.QmqClientNamespaceHandler -------------------------------------------------------------------------------- /qmq-dist/conf/delay.properties: -------------------------------------------------------------------------------- 1 | meta.server.endpoint=http://[:]/meta/address 2 | broker.port=20801 3 | sync.port=20802 4 | store.root=/data 5 | -------------------------------------------------------------------------------- /qmq-dist/sql/init_backup_hbase.sql: -------------------------------------------------------------------------------- 1 | create 'qmq_backup','m' 2 | create 'qmq_backup_record','i' 3 | create 'qmq_backup_dead','m' 4 | create 'qmq_backup_dead_content', 'm' -------------------------------------------------------------------------------- /qmq-server/src/main/resources/META-INF/services/qunar.tc.qmq.store.PullMessageFilter: -------------------------------------------------------------------------------- 1 | qunar.tc.qmq.store.EnvPullMessageFilter 2 | qunar.tc.qmq.store.TagPullMessageFilter -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Id/IdGenerator.cs: -------------------------------------------------------------------------------- 1 | namespace Qunar.TC.Qmq.Client 2 | { 3 | interface IdGenerator 4 | { 5 | string Generate(); 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /qmq-dist/conf/metaserver.properties: -------------------------------------------------------------------------------- 1 | #提供http服务,用于meta server的服务发现 2 | meta.server.discover.port=8080 3 | #以tcp的方式监听,供client和server访问 4 | meta.server.port=20880 5 | min.group.num=2 -------------------------------------------------------------------------------- /qmq-dist/conf/datasource.properties: -------------------------------------------------------------------------------- 1 | jdbc.driverClassName=com.mysql.jdbc.Driver 2 | jdbc.url=jdbc:mysql://:/ 3 | jdbc.username= 4 | jdbc.password= 5 | pool.size.max=10 -------------------------------------------------------------------------------- /clients/cpp/pitocin/test/test_conn.mk: -------------------------------------------------------------------------------- 1 | test_conn: test_conn.cpp ../src/Conn.hpp 2 | g++ -g -std=c++17 -I ../src -o test_conn test_conn.cpp -L /usr/lib/x86_64-linux-gnu -luv -lhttp_parser 3 | -------------------------------------------------------------------------------- /clients/cpp/pitocin/test/test_http.mk: -------------------------------------------------------------------------------- 1 | test_http: test_http.cpp ../src/Http.hpp 2 | g++ -g -std=c++17 -I ../src -o test_http test_http.cpp -L /usr/lib/x86_64-linux-gnu -luv -lhttp_parser 3 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Transport/Client.cs: -------------------------------------------------------------------------------- 1 | namespace Qunar.TC.Qmq.Client.Transport 2 | { 3 | interface Client 4 | { 5 | void Send(object request); 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /qmq-client/src/main/resources/META-INF/spring.schemas: -------------------------------------------------------------------------------- 1 | http\://www.qunar.com/schema/qmq/qmq-2.0.0.xsd=META-INF/qmq-2.0.0.xsd 2 | http\://www.qunar.com/schema/qmq/qmq.xsd=META-INF/qmq-2.0.0.xsd -------------------------------------------------------------------------------- /clients/cpp/pitocin/test/test_get_time.mk: -------------------------------------------------------------------------------- 1 | test_get_time: \ 2 | test_get_time.cpp \ 3 | ../src/TimeCalibrator.hpp 4 | g++ -g -std=c++17 test_get_time.cpp -I ../src -o test_get_time -luv 5 | 6 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Exceptions/RemoteException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Qunar.TC.Qmq.Client.Exceptions 4 | { 5 | public class RemoteException : Exception 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Transport/Sender.cs: -------------------------------------------------------------------------------- 1 | namespace Qunar.TC.Qmq.Client.Transport 2 | { 3 | interface Sender 4 | { 5 | void Send(ProducerMessageImpl message); 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Consumer/IRequestHandler.cs: -------------------------------------------------------------------------------- 1 | namespace Qunar.TC.Qmq.Client.Dubbo 2 | { 3 | internal interface IRequestHandler 4 | { 5 | object Handle(object msg); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /qmq-dist/bin/tools.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | call "%~dp0base.cmd" 5 | 6 | set MAIN=qunar.tc.qmq.tools.Tools 7 | 8 | echo on 9 | "%JAVA%" -cp "%CLASSPATH%" "%MAIN%" %* 10 | 11 | endlocal -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Exceptions/BrokerRejectException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Qunar.TC.Qmq.Client.Exceptions 4 | { 5 | public class BrokerRejectException : Exception 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /qmq-dist/bin/watchdog.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | call "%~dp0base.cmd" 5 | 6 | set MAIN=qunar.tc.qmq.task.Bootstrap 7 | 8 | echo on 9 | "%JAVA%" -cp "%CLASSPATH%" "%MAIN%" %* 10 | 11 | endlocal -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Exceptions/BrokerReadOnlyException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Qunar.TC.Qmq.Client.Exceptions 4 | { 5 | public class BrokerReadOnlyException : Exception 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /qmq-dist/bin/broker.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | call "%~dp0base.cmd" 5 | 6 | set MAIN=qunar.tc.qmq.container.Bootstrap 7 | 8 | echo on 9 | "%JAVA%" -cp "%CLASSPATH%" "%MAIN%" %* 10 | 11 | endlocal -------------------------------------------------------------------------------- /qmq-dist/bin/backup.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | call "%~dp0base.cmd" 5 | 6 | set MAIN=qunar.tc.qmq.backup.container.Bootstrap 7 | 8 | echo on 9 | "%JAVA%" -cp "%CLASSPATH%" "%MAIN%" %* 10 | 11 | endlocal -------------------------------------------------------------------------------- /qmq-dist/bin/delay.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | call "%~dp0base.cmd" 5 | 6 | set MAIN=qunar.tc.qmq.delay.container.Bootstrap 7 | 8 | echo on 9 | "%JAVA%" -cp "%CLASSPATH%" "%MAIN%" %* 10 | 11 | endlocal -------------------------------------------------------------------------------- /qmq-dist/bin/metaserver.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | call "%~dp0base.cmd" 5 | 6 | set MAIN=qunar.tc.qmq.meta.startup.Bootstrap 7 | 8 | echo on 9 | "%JAVA%" -cp "%CLASSPATH%" "%MAIN%" %* 10 | 11 | endlocal -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Codec/NewQmq/PayloadHolder.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace Qunar.TC.Qmq.Client.Codec.NewQmq 4 | { 5 | interface PayloadHolder 6 | { 7 | void Write(Stream output); 8 | } 9 | } -------------------------------------------------------------------------------- /clients/csharp/qmqclient/tag/TagType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Qunar.TC.Qmq.Client.tag 4 | { 5 | [Flags] 6 | public enum TagType 7 | { 8 | OR = 1, 9 | AND = 2 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /qmq-dist/conf/backup.properties: -------------------------------------------------------------------------------- 1 | meta.server.endpoint=http://[:]/meta/address 2 | acquire.server.meta.url=http://[:]/slave/meta 3 | store.root=/data 4 | store.type=hbase 5 | rocks.db.path=/data/rocksdb 6 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Codec/Encoder.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace Qunar.TC.Qmq.Client.Codec 4 | { 5 | interface Encoder 6 | { 7 | void Encode(object msg, Stream stream); 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Codec/Decoder.cs: -------------------------------------------------------------------------------- 1 | using Qunar.TC.Qmq.Client.Transport; 2 | 3 | namespace Qunar.TC.Qmq.Client.Codec 4 | { 5 | interface Decoder 6 | { 7 | object Decode(InputStream stream); 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /docs/cn/support.md: -------------------------------------------------------------------------------- 1 | [上一页](opensource.md) 2 | [回目录](../../README.md) 3 | [下一页](share.md) 4 | 5 | # 技术支持 6 | 7 | ### QQ群 8 | ![QQ](../images/support1.png) 9 | 10 | [上一页](opensource.md) 11 | [回目录](../../README.md) 12 | [下一页](share.md) 13 | -------------------------------------------------------------------------------- /clients/erlang/.gitignore: -------------------------------------------------------------------------------- 1 | .rebar3 2 | _* 3 | .eunit 4 | *.o 5 | *.beam 6 | *.plt 7 | *.swp 8 | *.swo 9 | .erlang.cookie 10 | ebin 11 | log 12 | erl_crash.dump 13 | .rebar 14 | logs 15 | _build 16 | .idea 17 | *.iml 18 | rebar3.crashdump 19 | *~ 20 | -------------------------------------------------------------------------------- /qmq-dist/conf/broker.properties: -------------------------------------------------------------------------------- 1 | #根据运行环境做对应修改 2 | store.root=/data 3 | meta.server.endpoint=http://[:]/meta/address 4 | messagelog.retention.hours=72 5 | log.expired.delete.enable=true 6 | 7 | #是否等待slave同步到消息才返回给producer,生产环境建议打开 8 | wait.slave.wrote=false -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Transport/Processor.cs: -------------------------------------------------------------------------------- 1 | // yuzhaohui 2 | // 2016/7/21 3 | namespace Qunar.TC.Qmq.Client.Transport 4 | { 5 | internal interface Processor 6 | { 7 | void Process(HandlerContext context, object msg); 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Transport/KeepliveStrategy.cs: -------------------------------------------------------------------------------- 1 | namespace Qunar.TC.Qmq.Client.Transport 2 | { 3 | internal interface IKeepliveStrategy 4 | { 5 | void CheckStatus(TransportClient client, long lastWrite, long lastRead, long lastConnect); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /docs/cn/opensource.md: -------------------------------------------------------------------------------- 1 | [上一页](db.md) 2 | [回目录](../../README.md) 3 | [下一页](support.md) 4 | 5 | # 开源协议 6 | QMQ采用Apache License, Version 2.0开源协议,[参见](http://www.apache.org/licenses/LICENSE-2.0.html) 7 | 8 | [上一页](db.md) 9 | [回目录](../../README.md) 10 | [下一页](support.md) 11 | -------------------------------------------------------------------------------- /qmq-dist/conf/watchdog.properties: -------------------------------------------------------------------------------- 1 | # (可选)每次扫描客户db如果超过3分钟则退出,等待下次扫描 2 | sendMessageTaskExecuteTimeout=180000 3 | #(可选) 多久刷新一次db里的客户端db记录状态 4 | refreshInterval=180000 5 | #(可选) 客户端db里的消息多久之前的认为可以重发 6 | checkInterval=60000 7 | #(可选) watchdog可以启动多个,与客户端db里的room对应 8 | namespace=default -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Codec/Flag.cs: -------------------------------------------------------------------------------- 1 | // yuzhaohui 2 | // 12/30/2018 3 | using System; 4 | namespace Qunar.TC.Qmq.Client 5 | { 6 | [Flags] 7 | internal enum Flag 8 | { 9 | Default = 0, 10 | DelayMessage = 2, 11 | TagsMessage = 4 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /qmq-store/src/main/java/qunar/tc/qmq/store/MemTableFactory.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.store; 2 | 3 | /** 4 | * Created by zhaohui.yu 5 | * 2020/6/6 6 | */ 7 | public interface MemTableFactory { 8 | MemTable create(final long tabletId, final long beginOffset, final int capacity); 9 | } 10 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/MessageSendStateListener.cs: -------------------------------------------------------------------------------- 1 | // yuzhaohui 2 | // 11/25/2016 3 | namespace Qunar.TC.Qmq.Client 4 | { 5 | internal interface MessageSendStateListener 6 | { 7 | void OnSuccess(Message message); 8 | 9 | void OnFailed(Message message); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_template.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: bug_template 3 | about: 便于贡献者复现和定位问题。 4 | title: '' 5 | labels: '' 6 | assignees: keliwang 7 | 8 | --- 9 | 10 | **问题描述** 11 | 12 | 13 | **环境配置** 14 | 15 | 16 | **复现步骤** 17 | 1. 18 | 2. 19 | 3. 20 | 21 | **实际输出结果** 22 | 23 | 24 | **期望输出结果** 25 | -------------------------------------------------------------------------------- /qmq-common/src/main/java/qunar/tc/qmq/batch/MpscLinkedQueuePad0.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.batch; 2 | 3 | /** 4 | * Created by zhaohui.yu 5 | */ 6 | abstract class MpscLinkedQueuePad0 { 7 | long p00, p01, p02, p03, p04, p05, p06, p07; 8 | long p30, p31, p32, p33, p34, p35, p36, p37; 9 | } 10 | -------------------------------------------------------------------------------- /qmq-server-common/src/main/java/qunar/tc/qmq/jdbc/DataSourceFactory.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.jdbc; 2 | 3 | import javax.sql.DataSource; 4 | 5 | import qunar.tc.qmq.configuration.DynamicConfig; 6 | 7 | public interface DataSourceFactory { 8 | DataSource createDataSource(DynamicConfig config); 9 | } 10 | -------------------------------------------------------------------------------- /qmq-server/src/main/java/qunar/tc/qmq/store/EnvRuleGetter.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.store; 2 | 3 | import java.util.Collection; 4 | 5 | /** 6 | * @author zhenwei.liu 7 | * @since 2019-08-05 8 | */ 9 | public interface EnvRuleGetter { 10 | 11 | Collection getRules(); 12 | } 13 | -------------------------------------------------------------------------------- /clients/cpp/pitocin/test/test_meta_tcp.mk: -------------------------------------------------------------------------------- 1 | test_meta_tcp: \ 2 | test_meta_tcp.cpp \ 3 | ../src/MetaTcp.hpp \ 4 | ../src/Protocol.hpp \ 5 | ../src/Conn.hpp \ 6 | ../src/StackPool.hpp \ 7 | ../src/ExiledChecker.hpp 8 | g++ -g -std=c++17 -I ../src -o test_meta_tcp test_meta_tcp.cpp -L /usr/lib/x86_64-linux-gnu -luv 9 | -------------------------------------------------------------------------------- /clients/erlang/src/qmqec.app.src: -------------------------------------------------------------------------------- 1 | {application, qmqec, 2 | [{description, "An OTP library"}, 3 | {vsn, "0.1.0"}, 4 | {registered, []}, 5 | {applications, 6 | [kernel, 7 | stdlib 8 | ]}, 9 | {env,[]}, 10 | {modules, []}, 11 | 12 | {licenses, ["Apache 2.0"]}, 13 | {links, []} 14 | ]}. 15 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Tx/MessageStore.cs: -------------------------------------------------------------------------------- 1 | namespace Qunar.TC.Qmq.Client.Tx 2 | { 3 | public interface MessageStore 4 | { 5 | void Save(ProducerMessage message); 6 | 7 | void Finish(ProducerMessage message); 8 | 9 | void Error(ProducerMessage message, int status); 10 | } 11 | } -------------------------------------------------------------------------------- /qmq-dist/bin/base.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | if not exist "%JAVA_HOME%\bin\java.exe" echo Please set the JAVA_HOME variable in your environment, run server by java 1.8 & EXIT /B 1 4 | set "JAVA=%JAVA_HOME%\bin\java.exe" 5 | 6 | set CONFDIR=%~dp0%..\conf 7 | 8 | set CLASSPATH=%CONFDIR% 9 | set CLASSPATH=%~dp0..\*;%~dp0..\lib\*;%CLASSPATH% -------------------------------------------------------------------------------- /qmq-dist/sql/init_backup.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS `qmq_dic` 2 | ( 3 | `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键', 4 | `name` varchar(100) NOT NULL default '' comment '字典名称', 5 | PRIMARY KEY (id), 6 | unique key uniq_idx_name(name) 7 | )ENGINE=InnoDB default charset=utf8mb4 comment 'qmq字典表'; -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Consumer/PulledMessageHandler.cs: -------------------------------------------------------------------------------- 1 | namespace Qunar.TC.Qmq.Client.Consumer 2 | { 3 | internal class PulledMessageHandler 4 | { 5 | public IMessageHandleTask CreateTask(PulledMessage message) 6 | { 7 | return new PulledMessageHandleTask(message); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /clients/csharp/qmqclient/MessageConsumer.cs: -------------------------------------------------------------------------------- 1 | // yuzhaohui 2 | // 2016/7/14 3 | 4 | namespace Qunar.TC.Qmq.Client 5 | { 6 | public delegate void MessageListener(Message message); 7 | 8 | public interface MessageConsumer 9 | { 10 | MessageSubscriber Subscribe(string prefix, string group); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/ProducerMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Qunar.TC.Qmq.Client 2 | { 3 | public interface ProducerMessage 4 | { 5 | Message Base 6 | { 7 | get; 8 | } 9 | 10 | object RouteKey 11 | { 12 | get; 13 | set; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Exceptions/NoWritableBrokerException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Qunar.TC.Qmq.Client.Exceptions 4 | { 5 | internal class NoWritableBrokerException : Exception 6 | { 7 | internal NoWritableBrokerException(string message) 8 | : base(message) 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Exceptions/EnqueueException.cs: -------------------------------------------------------------------------------- 1 | namespace Qunar.TC.Qmq.Client.Exceptions 2 | { 3 | class EnqueueException : MessageException 4 | { 5 | public EnqueueException() { } 6 | 7 | public EnqueueException(string messageId) : base(messageId, "message enqueue fail") 8 | { 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Consumer/ConsumeMode.cs: -------------------------------------------------------------------------------- 1 | namespace Qunar.TC.Qmq.Client.Consumer 2 | { 3 | public enum ConsumeMode 4 | { 5 | /// 6 | /// 最多一次 7 | /// 8 | AtMostOnce, 9 | 10 | /// 11 | /// 最少一次 12 | /// 13 | AtLeastOnce 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Consumer/IConsumerRegister.cs: -------------------------------------------------------------------------------- 1 | // yuzhaohui 2 | // 2016/7/15 3 | 4 | namespace Qunar.TC.Qmq.Client.Consumer 5 | { 6 | internal interface IConsumerRegister 7 | { 8 | void Registe(string prefix, string group, ExtraListenerConfig config); 9 | 10 | void Unregiste(string prefix, string group); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Consumer/IMessageHandleTask.cs: -------------------------------------------------------------------------------- 1 | using Qunar.TC.Qmq.Client.Model; 2 | 3 | namespace Qunar.TC.Qmq.Client.Consumer 4 | { 5 | internal interface IMessageHandleTask 6 | { 7 | BaseMessage Message(); 8 | 9 | object DispatchTo(MessageHandler handler); 10 | 11 | void Execute(MessageListener listener); 12 | } 13 | } -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Util/HostAndPort.cs: -------------------------------------------------------------------------------- 1 | namespace Qunar.TC.Qmq.Client.Util 2 | { 3 | class HostAndPort 4 | { 5 | public readonly string Host; 6 | 7 | public readonly int Port; 8 | 9 | public HostAndPort(string host, int port) 10 | { 11 | Host = host; 12 | Port = port; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /qmq-metaserver/src/main/java/qunar/tc/qmq/meta/model/MetaServerConst.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.meta.model; 2 | 3 | /** 4 | * @description: 5 | * @author :zhixin.zhang 6 | * @date :Created in 下午9:15 2021/12/30 7 | */ 8 | public interface MetaServerConst { 9 | 10 | 11 | interface ServiceName { 12 | 13 | String CLIENT_ALIVE = "clientAlive"; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /qmq-backup/src/main/java/qunar/tc/qmq/backup/spi/DeadMessageSpiHandler.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.backup.spi; 2 | 3 | import qunar.tc.qmq.store.MessageQueryIndex; 4 | 5 | /** 6 | * TODO completion javadoc. 7 | * 8 | * @author xiao.liang 9 | * @since 08 June 2020 10 | */ 11 | public interface DeadMessageSpiHandler { 12 | 13 | void handle(MessageQueryIndex index); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Exceptions/DuplicateMessageException.cs: -------------------------------------------------------------------------------- 1 | namespace Qunar.TC.Qmq.Client.Exceptions 2 | { 3 | class DuplicateMessageException : MessageException 4 | { 5 | public DuplicateMessageException() { } 6 | 7 | public DuplicateMessageException(string messageId) : base(messageId, "Duplicated message") 8 | { 9 | } 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /clients/cpp/pitocin/test/test_client1.mk: -------------------------------------------------------------------------------- 1 | CLIENT_C= ../src/Client.cpp 2 | 3 | CLIENT_H= ../src/Client.hpp \ 4 | ../src/Http.hpp \ 5 | ../src/Conn.hpp \ 6 | ../src/StackPool.hpp \ 7 | ../src/Protocol.hpp 8 | 9 | test_conn: test_client1.cpp ${CLIENT_C} ${CLIENT_H} 10 | g++ -g -std=c++17 -I ../src -o test_client1 test_client1.cpp ${CLIENT_C} -L /usr/lib/x86_64-linux-gnu -luv -lhttp_parser 11 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Exceptions/BlockMessageException.cs: -------------------------------------------------------------------------------- 1 | namespace Qunar.TC.Qmq.Client.Exceptions 2 | { 3 | internal class BlockMessageException : MessageException 4 | { 5 | public BlockMessageException() { } 6 | 7 | public BlockMessageException(string messageId) 8 | : base(messageId, "block by whitelist") 9 | { 10 | 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /qmq-metaserver/src/main/java/qunar/tc/qmq/meta/spi/ClientRegisterAuthService.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.meta.spi; 2 | 3 | import qunar.tc.qmq.meta.spi.pojo.ClientRegisterAuthInfo; 4 | 5 | /** 6 | * TODO completion javadoc. 7 | * 8 | * @author xiao.liang 9 | * @since 27 December 2019 10 | */ 11 | public interface ClientRegisterAuthService { 12 | 13 | boolean auth(ClientRegisterAuthInfo authInfo); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/NewQmq/IDataTransformer.cs: -------------------------------------------------------------------------------- 1 | using Qunar.TC.Qmq.Client.Codec; 2 | using Qunar.TC.Qmq.Client.Codec.NewQmq; 3 | using Qunar.TC.Qmq.Client.Metainfo; 4 | 5 | namespace Qunar.TC.Qmq.Client.NewQmq 6 | { 7 | internal interface IDataTransformer 8 | { 9 | Datagram TransformRequest(Request request); 10 | 11 | Response TransformResponse(BrokerGroup brokerGroup, Datagram datagram); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /clients/cpp/pitocin/test/test_broker_heartbeat.mk: -------------------------------------------------------------------------------- 1 | CFILE= 2 | 3 | HFILE= ../src/Conn.hpp \ 4 | ../src/StackPool.hpp \ 5 | ../src/Protocol.hpp \ 6 | ../src/BrokerTcp.hpp \ 7 | ../src/ExiledChecker.hpp \ 8 | ../src/RequestValve.hpp 9 | 10 | test_conn: test_broker_heartbeat.cpp ${CFILE} ${HFILE} 11 | g++ -g -std=c++14 -I ../src -o test_broker_heartbeat test_broker_heartbeat.cpp ${CFILE} -L /usr/lib/x86_64-linux-gnu -luv 12 | -------------------------------------------------------------------------------- /docs/cn/share.md: -------------------------------------------------------------------------------- 1 | [上一页](support.md) 2 | [回目录](../../README.md) 3 | [下一页](faq.md) 4 | 5 | # 文章 6 | 7 | * [去哪儿网消息队列设计与实现](https://www.infoq.cn/article/b4VPvP3m8DA-PM7ZqMGZ) 8 | 9 | * [消息消费模式](pattern.md) 10 | 11 | * [消息消费隔离](actor.md) 12 | 13 | * [防雪崩设计](circuitbreaker.md) 14 | 15 | # 视频 16 | 17 | * [去哪儿消息队列演进](http://www.itdks.com/Home/Course/detail?type=normal&id=9304) 18 | 19 | [上一页](support.md) 20 | [回目录](../../README.md) 21 | [下一页](faq.md) -------------------------------------------------------------------------------- /qmq-common/src/main/java/qunar/tc/qmq/batch/MpscLinkedQueuePad1.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.batch; 2 | 3 | 4 | /** 5 | * Created by zhaohui.yu 6 | * $ {DATE} 7 | */ 8 | abstract class MpscLinkedQueuePad1 extends MpscLinkedQueueHeadRef { 9 | 10 | private static final long serialVersionUID = 2886694927079691637L; 11 | 12 | long p00, p01, p02, p03, p04, p05, p06, p07; 13 | long p30, p31, p32, p33, p34, p35, p36, p37; 14 | } 15 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Cluster/ICluster.cs: -------------------------------------------------------------------------------- 1 | using Qunar.TC.Qmq.Client.Codec; 2 | using Qunar.TC.Qmq.Client.Transport; 3 | 4 | namespace Qunar.TC.Qmq.Client.Cluster 5 | { 6 | internal interface ICluster 7 | { 8 | string Name { get; } 9 | 10 | void Init(); 11 | 12 | Future Send(Request request); 13 | 14 | void Broadcast(Request request); 15 | 16 | void WaitAvailable(int mills); 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Transport/ChannelContext.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | 3 | namespace Qunar.TC.Qmq.Client.Transport 4 | { 5 | internal static class ChannelContext 6 | { 7 | private static readonly ThreadLocal Remote = new ThreadLocal(); 8 | 9 | public static string RemoteAddress 10 | { 11 | set => Remote.Value = value; 12 | 13 | get => Remote.Value; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/NewQmq/Model/AckRequest.cs: -------------------------------------------------------------------------------- 1 | namespace Qunar.TC.Qmq.Client.NewQmq.Model 2 | { 3 | internal class AckRequest 4 | { 5 | public string Subject { get; set; } 6 | public string Group { get; set; } 7 | public string ConsumerId { get; set; } 8 | 9 | public long PullOffsetBegin { get; set; } 10 | public long PullOffsetEnd { get; set; } 11 | 12 | public bool IsBroadcast { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/NewQmq/LoadBalance.cs: -------------------------------------------------------------------------------- 1 | using Qunar.TC.Qmq.Client.Metainfo; 2 | 3 | namespace Qunar.TC.Qmq.Client.NewQmq 4 | { 5 | interface LoadBalance 6 | { 7 | BrokerGroup Select(NewQmqClusterInfo cluster); 8 | 9 | void Timeout(BrokerGroup group); 10 | 11 | void NoMessage(BrokerGroup group); 12 | 13 | void FetchedMessages(BrokerGroup group); 14 | 15 | void FetchedEnoughMessages(BrokerGroup group); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # kdiff3 ignore 2 | *.orig 3 | 4 | # maven ignore 5 | target/ 6 | 7 | # eclipse ignore 8 | .settings/ 9 | .project 10 | .classpath 11 | 12 | # idea ignore 13 | .idea/ 14 | *.ipr 15 | *.iml 16 | *.iws 17 | 18 | # temp ignore 19 | *.log 20 | *.cache 21 | *.diff 22 | *.patch 23 | *.tmp 24 | 25 | # system ignore 26 | .DS_Store 27 | Thumbs.db 28 | 29 | # package ignore (optional) 30 | # *.jar 31 | # *.war 32 | # *.zip 33 | # *.tar 34 | # *.tar.gz 35 | catalina.base_IS_UNDEFINED/ -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Transport/InputStream.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace Qunar.TC.Qmq.Client.Transport 4 | { 5 | abstract class InputStream : Stream 6 | { 7 | internal abstract void MarkWriterIndex(); 8 | 9 | internal abstract void ResetWriterIndex(); 10 | 11 | internal abstract void MarkReaderIndex(); 12 | 13 | internal abstract void ResetReaderIndex(); 14 | 15 | internal abstract void Limit(int len); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /qmq-dist/conf/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | [%d{yyyy-MM-dd HH:mm:ss} %5p %c] %m%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /qmq-dist/bin/base.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | 4 | TIMESTAMP=$(date +%s) 5 | QMQ_CFG_DIR="$QMQ_BIN_DIR/../conf" 6 | QMQ_PID_DIR="$QMQ_BIN_DIR/../pid" 7 | QMQ_LOG_DIR="$QMQ_BIN_DIR/../logs" 8 | 9 | if [[ ! -w "$QMQ_PID_DIR" ]] ; then 10 | mkdir -p "$QMQ_PID_DIR" 11 | fi 12 | 13 | if [[ ! -w "$QMQ_LOG_DIR" ]] ; then 14 | mkdir -p "$QMQ_LOG_DIR" 15 | fi 16 | 17 | CLASSPATH="$QMQ_CFG_DIR" 18 | for i in "$QMQ_BIN_DIR"/../lib/* 19 | do 20 | CLASSPATH="$i:$CLASSPATH" 21 | done 22 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Model/ConsumerRejectException.cs: -------------------------------------------------------------------------------- 1 | // yuzhaohui 2 | // 2016/7/19 3 | using System; 4 | 5 | namespace Qunar.TC.Qmq.Client.Model 6 | { 7 | internal class ConsumerRejectException : Exception 8 | { 9 | private string detailMessage; 10 | 11 | public override string Message => detailMessage; 12 | 13 | public ConsumerRejectException(string msg) : base(msg) 14 | { 15 | detailMessage = msg; 16 | } 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Transport/Handler.cs: -------------------------------------------------------------------------------- 1 | // yuzhaohui 2 | // 2016/7/14 3 | 4 | namespace Qunar.TC.Qmq.Client.Transport 5 | { 6 | interface Handler 7 | { 8 | // -> 9 | void Receive(HandlerContext context, object msg); 10 | 11 | // -> 12 | void InActive(HandlerContext context); 13 | 14 | // <- 15 | void Write(HandlerContext context, object msg); 16 | 17 | // <- 18 | void Close(HandlerContext context); 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /clients/cpp/pitocin/.gitignore: -------------------------------------------------------------------------------- 1 | # kdiff3 ignore 2 | *.orig 3 | 4 | # maven ignore 5 | target/ 6 | 7 | # eclipse ignore 8 | .settings/ 9 | .project 10 | .classpath 11 | 12 | # idea ignore 13 | .idea/ 14 | *.ipr 15 | *.iml 16 | *.iws 17 | 18 | # temp ignore 19 | *.log 20 | *.cache 21 | *.diff 22 | *.patch 23 | *.tmp 24 | 25 | # system ignore 26 | .DS_Store 27 | Thumbs.db 28 | 29 | # package ignore (optional) 30 | # *.jar 31 | # *.war 32 | # *.zip 33 | # *.tar 34 | # *.tar.gz 35 | 36 | # pods ignore 37 | Pods/ -------------------------------------------------------------------------------- /qmq-client/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | [%d{yyyy-MM-dd HH:mm:ss} %5p %c] %m%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /qmq-dist/bin/tools.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | 4 | QMQ_BIN="${BASH_SOURCE-$0}" 5 | QMQ_BIN="$(dirname "${QMQ_BIN}")" 6 | QMQ_BIN_DIR="$(cd "${QMQ_BIN}"; pwd)" 7 | QMQ_TOOLS_MAIN="qunar.tc.qmq.tools.Tools" 8 | 9 | . "$QMQ_BIN_DIR/base.sh" 10 | . "$QMQ_BIN_DIR/tools-env.sh" 11 | 12 | if [[ "$JAVA_HOME" != "" ]]; then 13 | JAVA="$JAVA_HOME/bin/java" 14 | else 15 | JAVA=java 16 | fi 17 | 18 | ZOO_CMD=(exec "$JAVA") 19 | "${ZOO_CMD[@]}" -cp "$CLASSPATH" ${JAVA_OPTS} ${QMQ_TOOLS_MAIN} $@ 20 | -------------------------------------------------------------------------------- /qmq-backup/src/main/java/qunar/tc/qmq/backup/spi/impl/DefaultDeadMessageSpiHandler.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.backup.spi.impl; 2 | 3 | import qunar.tc.qmq.backup.spi.DeadMessageSpiHandler; 4 | import qunar.tc.qmq.store.MessageQueryIndex; 5 | 6 | /** 7 | * TODO completion javadoc. 8 | * 9 | * @author xiao.liang 10 | * @since 08 June 2020 11 | */ 12 | public class DefaultDeadMessageSpiHandler implements DeadMessageSpiHandler { 13 | 14 | @Override 15 | public void handle(MessageQueryIndex index) { 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /docs/cn/debug.md: -------------------------------------------------------------------------------- 1 | [上一页](backup.md) 2 | [回目录](../../README.md) 3 | [下一页](operations.md) 4 | 5 | # 在IDE里运行代码 6 | 7 | 如果想在IDE里来运行代码了解QMQ的运行原理可以按照下面的步骤进行 8 | 9 | ### clone code 10 | ``` 11 | git clone https://github.com/qunarcorp/qmq.git 12 | ``` 13 | 14 | ### init database 15 | 使用 qmq-dist\sql\init.sql 初始化数据库 16 | 17 | ### init config 18 | 按照[安装](install.md)里描述的配置对qmq-dist\conf里的配置文件进行对应的修改 19 | 20 | ### config env 21 | 以Intellij IDEA为例 22 | 23 | ![IDEA](../images/idea.png) 24 | 25 | [上一页](backup.md) 26 | [回目录](../../README.md) 27 | [下一页](operations.md) -------------------------------------------------------------------------------- /clients/csharp/qmqclient/qmqclient.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | Qunar 6 | QMQ 7 | The .Net client for QMQ 8 | Qunar 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /qmq-dist/sql/init_client.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE `qmq_produce`; 2 | CREATE TABLE `qmq_msg_queue` ( 3 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', 4 | `content` longtext NOT NULL, 5 | `status` smallint(6) NOT NULL DEFAULT '0' COMMENT '消息状态', 6 | `error` int unsigned NOT NULL DEFAULT '0' COMMENT '错误次数', 7 | `create_time` datetime NOT NULL COMMENT '创建时间', 8 | `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', 9 | PRIMARY KEY (`id`) 10 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='记录业务系统消息'; -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Exceptions/NeedRetryException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Qunar.TC.Qmq.Client.Exceptions 4 | { 5 | public class NeedRetryException : Exception 6 | { 7 | private readonly TimeSpan next; 8 | 9 | public NeedRetryException(TimeSpan next, string message) : base(message) 10 | { 11 | this.next = next; 12 | } 13 | 14 | public TimeSpan Next 15 | { 16 | get 17 | { 18 | return this.next; 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /qmq-demo/README.md: -------------------------------------------------------------------------------- 1 | qmq-demo是一个包含发送消息和消费消息的完整SprintBoot demo。你可以查看[事务消息](../docs/cn/transaction.md)文档了解更多事务消息使用细节。 2 | 3 | * 在application.properties里根据你的环境配置如下三个参数 4 | ``` 5 | # 数据库地址 6 | spring.datasource.url= 7 | # 数据库帐号 8 | spring.datasource.username= 9 | # 数据库密码 10 | spring.datasource.password= 11 | ``` 12 | 13 | * 为了发送事务消息,请在上面db的相同实例上使用qmq-dist/sql/init_client.sql创建db 14 | 15 | * 运行 SpringBootMain 16 | 17 | * 访问 http://127.0.0.1:8080/order/placeOrder 就会展示下单界面,点击提交后会发送事务消息。该操作会在上面的db的orders表里持久化一条订单数据,这个时候如果因为网络或其他原因,消息没有发送到server成功的话,在qmq_produce.qmq_msg_queue表里会有一条消息记录。 -------------------------------------------------------------------------------- /qmq-metaserver/src/main/java/qunar/tc/qmq/meta/spi/impl/DefaultClientRegisterAuthService.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.meta.spi.impl; 2 | 3 | import qunar.tc.qmq.meta.spi.ClientRegisterAuthService; 4 | import qunar.tc.qmq.meta.spi.pojo.ClientRegisterAuthInfo; 5 | 6 | /** 7 | * TODO completion javadoc. 8 | * 9 | * @author xiao.liang 10 | * @since 27 December 2019 11 | */ 12 | public class DefaultClientRegisterAuthService implements ClientRegisterAuthService { 13 | 14 | @Override 15 | public boolean auth(ClientRegisterAuthInfo authInfo) { 16 | return true; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /clients/cpp/pitocin/test/test_client2.mk: -------------------------------------------------------------------------------- 1 | CLIENT_C= ../src/Client.cpp 2 | 3 | CLIENT_H= ../src/Client.hpp \ 4 | ../src/Http.hpp \ 5 | ../src/Conn.hpp \ 6 | ../src/StackPool.hpp \ 7 | ../src/Protocol.hpp \ 8 | ../src/BrokerTcp.hpp \ 9 | ../src/ExiledChecker.hpp \ 10 | ../src/Ipv4Getter.hpp \ 11 | ../src/MetaTcp.hpp \ 12 | ../src/RequestValve.hpp \ 13 | ../src/TimeCalibrator.hpp 14 | 15 | test_conn: test_client2.cpp ${CLIENT_C} ${CLIENT_H} 16 | g++ -g -std=c++14 -I ../src -o test_client2 test_client2.cpp ${CLIENT_C} -L /usr/lib/x86_64-linux-gnu -luv -lhttp_parser 17 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Exceptions/BrokerUnassignedException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Qunar.TC.Qmq.Client.Exceptions 4 | { 5 | internal class BrokerUnassignedException : Exception 6 | { 7 | internal BrokerUnassignedException(string subject) 8 | : base($"qmq metaserver doesn't assign any broker for {subject} now") 9 | { 10 | } 11 | 12 | internal BrokerUnassignedException(string subject, string group) 13 | : base($"qmq metaserver doesn't assign any broker for {subject}/{group} now") 14 | { 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Model/ChannelState.cs: -------------------------------------------------------------------------------- 1 | // yuzhaohui 2 | // 2016/7/19 3 | namespace Qunar.TC.Qmq.Client.Model 4 | { 5 | internal class ChannelState 6 | { 7 | private readonly long currentTime; 8 | private readonly int activeCount; 9 | 10 | public ChannelState(int activeCount, long currentTime) 11 | { 12 | this.currentTime = currentTime; 13 | this.activeCount = activeCount; 14 | } 15 | 16 | public long CurrentTime => currentTime; 17 | 18 | public int ActiveCount => activeCount; 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Transport/Channel.cs: -------------------------------------------------------------------------------- 1 | // yuzhaohui 2 | // 12/5/2016 3 | 4 | using System.Net; 5 | using System.Net.Sockets; 6 | namespace Qunar.TC.Qmq.Client.Transport 7 | { 8 | interface Channel 9 | { 10 | void UpdateSocket(Socket socket); 11 | 12 | void Write(object msg); 13 | 14 | void Receive(); 15 | 16 | bool Writtable { get; } 17 | 18 | bool Closed { get; } 19 | 20 | void Close(); 21 | 22 | void Release(); 23 | 24 | ChannelPipeline Pipeline(); 25 | 26 | EndPoint RemoteEndPoint(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /qmq-common/src/main/java/qunar/tc/qmq/utils/SubjectUtils.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.utils; 2 | 3 | import static com.google.common.base.CharMatcher.BREAKING_WHITESPACE; 4 | 5 | import com.google.common.base.CharMatcher; 6 | 7 | public class SubjectUtils { 8 | private static final CharMatcher ILLEGAL_MATCHER = CharMatcher.anyOf("/\r\n"); 9 | 10 | public static boolean isInValid(String subject) { 11 | if (subject == null) return true; 12 | if (subject.length() == 0) return true; 13 | 14 | return ILLEGAL_MATCHER.matchesAnyOf(subject) || BREAKING_WHITESPACE.matchesAnyOf(subject); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /qmq-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | qmq-parent 7 | com.qunar.qmq 8 | 1.1.44-SNAPSHOT 9 | 10 | 11 | qmq-api 12 | qmq-api 13 | public api 14 | -------------------------------------------------------------------------------- /clients/cpp/pitocin/test/test_http.cpp: -------------------------------------------------------------------------------- 1 | #include "Http.hpp" 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | uv_loop_t *loop = uv_default_loop(); 8 | Pitocin::Http http(loop); 9 | http.setUrl("http://127.0.0.1:8080/meta/address"); 10 | http.setTimeout(2000); 11 | http.setCallback([](int code, std::string &&resp) { 12 | std::cout << "code:" << code << std::endl; 13 | if (code == 200) 14 | { 15 | std::cout << "resp:" << resp << std::endl; 16 | } 17 | }); 18 | http.startGetRequest(); 19 | uv_run(loop, UV_RUN_DEFAULT); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Codec/NewQmq/Datagram.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace Qunar.TC.Qmq.Client.Codec.NewQmq 4 | { 5 | class Datagram 6 | { 7 | private PayloadHolder payloadHolder; 8 | 9 | public RemotingHeader Header { get; set; } 10 | 11 | public byte[] Body { get; set; } 12 | 13 | public PayloadHolder PayloadHolder 14 | { 15 | set 16 | { 17 | this.payloadHolder = value; 18 | } 19 | } 20 | 21 | public void WriteBody(Stream output) 22 | { 23 | payloadHolder?.Write(output); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /qmq-demo/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | appCode=qmq_test 2 | metaServer=http://127.0.0.1:8080/meta/address 3 | 4 | executor.coreSize=2 5 | executor.maxSize=2 6 | executor.queueSize=100 7 | 8 | # 请在该db同一个实例上使用qmq-dist/sql/init_client.sql初始化qmq_produce db 9 | spring.datasource.url=jdbc:mysql://127.0.0.1:3306/order_db 10 | spring.datasource.username= 11 | spring.datasource.password= 12 | spring.jpa.database=MYSQL 13 | spring.jpa.show-sql=true 14 | 15 | spring.jpa.hibernate.ddl-auto=update 16 | spring.jpa.hibernate.naming.strategy=org.hibernate.cfg.ImprovedNamingStrategy 17 | spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Util/DateTimeUtils.cs: -------------------------------------------------------------------------------- 1 | // yuzhaohui 2 | // 2016/8/3 3 | using System; 4 | namespace Qunar.TC.Qmq.Client.Util 5 | { 6 | static class DateTimeUtils 7 | { 8 | private static readonly DateTime Jan1st1970 = new DateTime(1970, 1, 1, 8, 0, 0, DateTimeKind.Local); 9 | 10 | public static long ToTime(this DateTime time) 11 | { 12 | return (long)((time - Jan1st1970).TotalMilliseconds); 13 | } 14 | 15 | public static DateTime FromTime(long milliseconds) 16 | { 17 | return Jan1st1970.Add(TimeSpan.FromMilliseconds(milliseconds)); 18 | } 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /docs/cn/faq.md: -------------------------------------------------------------------------------- 1 | [上一页](share.md) 2 | [回目录](../../README.md) 3 | 4 | 5 | # FAQ 6 | 7 | # Q: QMQ Server采用的是同步刷盘还是异步刷盘 8 | A: QMQ使用的是异步刷盘,在配置文件里可以配置刷盘的间隔,QMQ依赖主从同步来提高可靠性,在生产环境上如果配置了从,那么MASTER收到消息后并不会立即返回给Producer,所有消息必须等到SLAVE确认才会回复Producer。 9 | 10 | # Q: QMQ的Message为什么提供一种简单的KeyValue API 11 | A: QMQ最开始的定位是用于业务中的消息中间件,在业务使用中我们并不推荐将所有数据都通过消息来传递,这往往会导致时序等问题,我们更推荐使用消息传输一些关键信息,而消费方使用这些关键信息查询到最新信息。 12 | 举一个例子,假设我们在订单系统中使用消息来发送订单变更事件,如果将订单所有信息都放在消息里,这样消息消费方在收到消息后因为具备所有他需要的消息很有可能就会拿这些消息去做业务处理,而订单可能有多个不同的变更方,这样一来很有可能消费方使用消息里的订单数据时订单已经发生了变更,那么消费方就使用了一个错误的数据来处理,我们这个时候更推荐消费方使用比如订单号去查询到最新版本的订单。所以这种使用key/value的方式设置消息的API是我们有意为之。 13 | 14 | [上一页](share.md) 15 | [回目录](../../README.md) -------------------------------------------------------------------------------- /clients/cpp/pitocin/test/test_client1.cpp: -------------------------------------------------------------------------------- 1 | #include "Client.hpp" 2 | #include 3 | #include 4 | #include 5 | 6 | int main() 7 | { 8 | using namespace std; 9 | uv_loop_t *loop = uv_default_loop(); 10 | cout << uv_version_string() << endl; 11 | Pitocin::Client client(loop); 12 | client.setErrCallback([](int code, string &&info) { 13 | cout << "ERR" 14 | << " code:" << code 15 | << " info:" << info << endl; 16 | }); 17 | client.setHttpUrl("http://127.0.0.1:8080/meta/address"); 18 | client.setHttpReqInterval(3000); 19 | client.start(); 20 | uv_run(loop, UV_RUN_DEFAULT); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /qmq-metaserver/src/main/java/qunar/tc/qmq/meta/exception/NoSuchServiceException.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.meta.exception; 2 | 3 | /** 4 | * @description: 5 | * @author :zhixin.zhang 6 | * @date :Created in 下午9:06 2021/12/30 7 | */ 8 | public class NoSuchServiceException extends MetaException{ 9 | 10 | private String serviceName; 11 | 12 | public NoSuchServiceException(String name) { 13 | super("No Service named '" + name + "' available"); 14 | this.serviceName = name; 15 | } 16 | 17 | public NoSuchServiceException(String name, String message) { 18 | super("No Service named '" + name + "' available: " + message); 19 | this.serviceName = name; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /docs/cn/code.md: -------------------------------------------------------------------------------- 1 | [上一页](arch.md) 2 | [回目录](../../README.md) 3 | [下一页](ha.md) 4 | 5 | # 代码模块介绍 6 | 7 | ### qmq-api 8 | 暴露给用户的一些interface 9 | 10 | ### qmq-common 11 | 一些公用的类,所有其他模块都可能引用 12 | 13 | ### qmq-server-common 14 | 公用的类,只有server side应用引用,不暴露给client side 15 | 16 | ### qmq-server 17 | 实时消息服务 18 | 19 | ### qmq-delay-server 20 | 延时/定时消息服务 21 | 22 | ### qmq-store 23 | 存储 24 | 25 | ### qmq-remoting 26 | 网络相关 27 | 28 | ### qmq-client 29 | 客户端逻辑 30 | 31 | ### qmq-metrics-prometheus 32 | 提供的prometheus监控接入 33 | 34 | ### qmq-watchdog 35 | 提供消息补偿服务,从客户端消息库扫描出发送失败的消息进行补偿 36 | 37 | ### qmq-gateway 38 | 提供其他协议转换,目前提供HTTP接入 39 | 40 | [上一页](arch.md) 41 | [回目录](../../README.md) 42 | [下一页](ha.md) 43 | -------------------------------------------------------------------------------- /qmq-metaserver/src/main/java/qunar/tc/qmq/meta/route/ExtendService.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.meta.route; 2 | 3 | /** 4 | * The interface Extend service. 5 | * 6 | * @param the type parameter 7 | * @param the type parameter 8 | * @description: 9 | * @author :zhixin.zhang 10 | * @date :Created in 下午9:30 2021/12/23 11 | */ 12 | public interface ExtendService { 13 | 14 | 15 | /** 16 | * Match list. 17 | * 18 | * @param request the request 19 | * @return the list 20 | */ 21 | boolean match(T request); 22 | 23 | /** 24 | * Route extend list. 25 | * 26 | * @param request the request 27 | * @return the list 28 | */ 29 | R extend(T request); 30 | } 31 | -------------------------------------------------------------------------------- /qmq-backup/src/test/http/FindMessageApi.http: -------------------------------------------------------------------------------- 1 | ### 2 | GET http://local.qunar.com:8082/api/message?backupQuery={"subject":"new.qmq.test","isDelay":false,"len":20} 3 | Content-Type: application/json 4 | 5 | ### 6 | GET http://local.qunar.com:8082/api/message/detail?backupQuery={"subject":"new.qmq.test","brokerGroup":"dev","sequence":0} 7 | Content-Type: application/json 8 | 9 | ### 10 | GET http://local.qunar.com:8082/api/message/records?recordQuery={"subject":"new.qmq.test","sequence":0,"brokerGroup":"dev","recordCode":0} 11 | 12 | ### 13 | GET http://local.qunar.com:8082/api/message/records?recordQuery={"subject":"new.qmq.test","messageId":"190603.153809.100.80.128.160.12812.0","recordCode":1} 14 | 15 | ### -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Util/NetUtils.cs: -------------------------------------------------------------------------------- 1 | // yuzhaohui 2 | // 2016/8/3 3 | using System; 4 | using System.Net; 5 | using System.Net.Sockets; 6 | namespace Qunar.TC.Qmq.Client.Util 7 | { 8 | static class NetUtils 9 | { 10 | public static string LocalHost() 11 | { 12 | var host = Dns.GetHostEntry(Dns.GetHostName()); 13 | foreach (var ip in host.AddressList) 14 | { 15 | if (ip.AddressFamily == AddressFamily.InterNetwork) 16 | { 17 | return ip.ToString(); 18 | } 19 | } 20 | throw new Exception("Local IP Address Not Found!"); 21 | } 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Util/StaticRandom.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace Qunar.TC.Qmq.Client.Util 5 | { 6 | internal static class StaticRandom 7 | { 8 | private static int _seed = Environment.TickCount; 9 | private static readonly ThreadLocal LocalRandom = 10 | new ThreadLocal(() => new Random(Interlocked.Increment(ref _seed))); 11 | 12 | public static int NextRand(int max) 13 | { 14 | return LocalRandom.Value.Next(max); 15 | } 16 | 17 | public static int NextRand(int min, int max) 18 | { 19 | return LocalRandom.Value.Next(min, max); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Transport/EncodeHandler.cs: -------------------------------------------------------------------------------- 1 | // yuzhaohui 2 | // 2016/7/14 3 | using System.IO; 4 | 5 | using Qunar.TC.Qmq.Client.Codec; 6 | 7 | namespace Qunar.TC.Qmq.Client.Transport 8 | { 9 | class EncodeHandler : AbstractHandler 10 | { 11 | private readonly Encoder encoder; 12 | 13 | public EncodeHandler(Encoder encoder) 14 | { 15 | this.encoder = encoder; 16 | } 17 | 18 | public override void Write(HandlerContext context, object msg) 19 | { 20 | var stream = new MemoryStream(); 21 | encoder.Encode(msg, stream); 22 | var buffer = stream.ToArray(); 23 | context.Write(buffer); 24 | } 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /docs/cn/trace.md: -------------------------------------------------------------------------------- 1 | [上一页](monitor.md) 2 | [回目录](../../README.md) 3 | [下一页](producer.md) 4 | 5 | # Trace 6 | 7 | 消息队列服务的参与方众多,生产者发出消息后,可能存在很多的consumer订阅。如果某消息驱动的业务出现问题,定位起来将非常麻烦,如果在定位问题时能有全链路跟踪埋点,将会起到事半功倍的效果,QMQ通过接入[OpenTracing](https://opentracing.io/)规范,提供了完善的trace机制。 8 | 9 | ## 接入自己的trace系统 10 | 11 | ## QMQ中的trace埋点 12 | 13 | ### Qmq.Produce.Send 14 | 生产者发消息sendMessage方法调用时会添加该埋点,该埋点携带了subject, messageId, appCode等信息,可以用于定位sendMessage方法是否调用的问题 15 | 16 | ### Qmq.QueueSender.Send 17 | 消息真正发送给server时候会添加该埋点,该埋点可以看出消息是否发送成功 18 | 19 | ### Qmq.Consume.Process 20 | 消费者处理消息逻辑会添加该埋点,该埋点可以表示消费者处理消息吞吐量及其耗时 21 | 22 | ### Qmq.Consume.Ack 23 | 消费者消费完成消息后发送ack回server时候会添加该埋点 24 | 25 | [上一页](monitor.md) 26 | [回目录](../../README.md) 27 | [下一页](producer.md) 28 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Transport/AbstractHandler.cs: -------------------------------------------------------------------------------- 1 | // yuzhaohui 2 | // 12/10/2016 3 | 4 | namespace Qunar.TC.Qmq.Client.Transport 5 | { 6 | class AbstractHandler : Handler 7 | { 8 | public virtual void Close(HandlerContext context) 9 | { 10 | context.Close(); 11 | } 12 | 13 | public virtual void InActive(HandlerContext context) 14 | { 15 | context.InActive(); 16 | } 17 | 18 | public virtual void Receive(HandlerContext context, object msg) 19 | { 20 | context.Receive(msg); 21 | } 22 | 23 | public virtual void Write(HandlerContext context, object msg) 24 | { 25 | context.Write(msg); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/NewQmq/Model/PullMessageRequest.cs: -------------------------------------------------------------------------------- 1 | namespace Qunar.TC.Qmq.Client.NewQmq.Model 2 | { 3 | internal class PullMessageRequest 4 | { 5 | public string Subject { get; set; } 6 | public string Group { get; set; } 7 | public int BatchSize { get; set; } 8 | public long TimeoutMillis { get; set; } 9 | public long Offset { get; set; } 10 | public long PullOffsetBegin { get; set; } 11 | public long PullOffsetEnd { get; set; } 12 | public string ConsumerId { get; set; } 13 | public bool IsBroadcast { get; set; } 14 | public BrokerGroupInfo BrokerGroupInfo { get; set; } 15 | public short TagType { get; set; } 16 | public string[] Tags { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Transport/EventLoop.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Qunar.TC.Qmq.Client.Transport 4 | { 5 | class EventLoop 6 | { 7 | private SingleEventLoop[] workers; 8 | 9 | private int index = 0; 10 | 11 | public EventLoop(int workerCount) 12 | { 13 | workers = new SingleEventLoop[workerCount]; 14 | for (var i = 0; i < workers.Length; ++i) 15 | { 16 | workers[i] = new SingleEventLoop(); 17 | workers[i].Start(); 18 | } 19 | } 20 | 21 | public SingleEventLoop NextWorker() 22 | { 23 | var count = workers.Length; 24 | return workers[Math.Abs((index++) % count)]; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Codec/NewQmq/SendMessageResponseCode.cs: -------------------------------------------------------------------------------- 1 | namespace Qunar.TC.Qmq.Client.Codec.NewQmq 2 | { 3 | 4 | /// 5 | /// broker处理请求返回的状态码 6 | /// 7 | class SendMessageResponseCode 8 | { 9 | //成功 10 | public const short SUCCESS = 0; 11 | //繁忙 12 | public const short BUSY = 1; 13 | //重复投递的消息 14 | public const short DUPLICATE = 2; 15 | //消息主题未注册 16 | public const short SUBJECT_NOT_ASSIGNED = 3; 17 | // 消息投递到slave broker了 18 | public const short BROKER_READ_ONLY = 4; 19 | //被broker拦截 20 | public const short BROKER_REJECT = 5; 21 | //存储失败,但broker成功接收 22 | public const short BROKER_SAVE_FAILED = 6; 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /qmq-metrics-prometheus/src/main/resources/META-INF/services/qunar.tc.qmq.metrics.QmqMetricRegistry: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018 Qunar, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | qunar.tc.qmq.metrics.prometheus.PrometheusQmqMetricRegistry -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Model/QueryRequest.cs: -------------------------------------------------------------------------------- 1 | // yuzhaohui 2 | // 2016/7/19 3 | namespace Qunar.TC.Qmq.Client.Model 4 | { 5 | internal class QueryRequest 6 | { 7 | private string prefix; 8 | private string group; 9 | private string messageId; 10 | 11 | public QueryRequest() 12 | { 13 | } 14 | 15 | public string Prefix 16 | { 17 | get => prefix; 18 | set => prefix = value; 19 | } 20 | 21 | public string Group 22 | { 23 | get => group; 24 | set => group = value; 25 | } 26 | 27 | public string MessageId 28 | { 29 | get => messageId; 30 | set => messageId = value; 31 | } 32 | 33 | 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /docs/cn/quickstart.md: -------------------------------------------------------------------------------- 1 | [回目录](../../README.md) 2 | [下一页](install.md) 3 | 4 | # 快速入门 5 | 以下示例只是表明及其简洁的API,具体详细的用法请参照后面具体文档 6 | 7 | ## 发送消息 8 | 9 | ```java 10 | MessageProducerProvider producer = new MessageProducerProvider(); 11 | producer.init(); 12 | 13 | Message message = producer.generateMessage("your subject"); 14 | message.setProperty("key", "value"); 15 | //发送延迟消息 16 | //message.setDelayTime(15, TimeUnit.MINUTES); 17 | producer.sendMessage(message); 18 | ``` 19 | 20 | ## 消费消息 21 | 22 | ```java 23 | @QmqConsumer(subject = "your subject", consumerGroup = "group", executor = "your executor") 24 | public void onMessage(Message message){ 25 | //process your message 26 | String value = message.getStringProperty("key"); 27 | } 28 | ``` 29 | 30 | [回目录](../../README.md) 31 | [下一页](install.md) 32 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Model/HandlerMismatchException.cs: -------------------------------------------------------------------------------- 1 | // yuzhaohui 2 | // 2016/7/19 3 | using System; 4 | namespace Qunar.TC.Qmq.Client.Model 5 | { 6 | class HandlerMismatchException : Exception 7 | { 8 | private readonly string prefix; 9 | private readonly string group; 10 | 11 | public HandlerMismatchException(string prefix, string group) 12 | { 13 | this.prefix = prefix; 14 | this.group = group; 15 | } 16 | 17 | public string Prefix 18 | { 19 | get 20 | { 21 | return this.prefix; 22 | } 23 | } 24 | 25 | public string Group 26 | { 27 | get 28 | { 29 | return this.group; 30 | } 31 | } 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /qmq-watchdog/src/main/java/qunar/tc/qmq/task/LeaderChangedListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.task; 18 | 19 | interface LeaderChangedListener { 20 | void own(); 21 | 22 | void lost(); 23 | } 24 | -------------------------------------------------------------------------------- /clients/erlang/README.md: -------------------------------------------------------------------------------- 1 | qmqec 2 | ===== 3 | 4 | An OTP library 5 | 6 | Build 7 | ----- 8 | 9 | $ rebar3 compile 10 | 11 | 12 | cd _build/default/lib/qmqec 13 | erl -pa ebin -s qmqec_test 14 | 15 | 16 | Usage 17 | ----- 18 | 19 | ```erlang 20 | 21 | {ok, Pid} = qmqec:start_link( "http://url-to-meta-http-server" 22 | , [{app_code, <<"gibbon">>}] 23 | ), 24 | case qmqec:publish( Pid 25 | , <<"topic">> 26 | , [ {<<"key">>, <<"value">>} 27 | , {<<"info">>, <<"gibbon is a good boy">>} 28 | ] 29 | ) of 30 | ok -> 31 | ok; 32 | {uncompleted, _FailedMsgList} -> 33 | io:format("uncompleted~n", []); 34 | error -> 35 | io:format("error~n", []) 36 | end, 37 | 38 | ``` 39 | 40 | -------------------------------------------------------------------------------- /qmq-client/src/main/java/qunar/tc/qmq/consumer/pull/PullStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.consumer.pull; 18 | 19 | interface PullStrategy { 20 | boolean needPull(); 21 | 22 | void record(boolean status); 23 | } 24 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Pull/IPullConsumer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Qunar.TC.Qmq.Client.Consumer; 4 | 5 | namespace Qunar.TC.Qmq.Client.Pull 6 | { 7 | public interface IPullConsumer 8 | { 9 | string Subject { get; } 10 | 11 | string ConsumerGroup { get; } 12 | 13 | bool IsBroadcast { get; } 14 | 15 | ConsumeMode ConsumeMode { get; } 16 | 17 | /// 18 | /// 纯拉api 19 | /// 注意:使用该api拉到消息使用方需要对每条消息调用message.Ack方法,如果不care消息是否消费成功,可以设置ConsumeMode = ConsumeMode.AtMostOnce 20 | /// 这样就不用显式调用Ack方法了 21 | /// 22 | /// 期望本次最多拉到多少条消息 23 | /// 在server端暂时没有消息时希望等待的超时时间 24 | /// 25 | List Pull(int expectNum, TimeSpan timeout); 26 | } 27 | } -------------------------------------------------------------------------------- /qmq-store/src/main/java/qunar/tc/qmq/store/FlushHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.store; 18 | 19 | /** 20 | * @author keli.wang 21 | * @since 2018/9/28 22 | */ 23 | public interface FlushHook { 24 | void beforeFlush(); 25 | } 26 | -------------------------------------------------------------------------------- /qmq-store/src/main/java/qunar/tc/qmq/store/LogVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.store; 18 | 19 | public interface LogVisitor { 20 | LogVisitorRecord nextRecord(); 21 | 22 | int visitedBufferSize(); 23 | } 24 | -------------------------------------------------------------------------------- /clients/cpp/pitocin/test/test_link.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../src/LinkNode.hpp" 5 | 6 | using namespace std; 7 | 8 | class MyClass 9 | { 10 | public: 11 | string info; 12 | MyClass(string &&_info) 13 | : info(_info) 14 | { 15 | cout << "MyClass " << info << " construct" << endl; 16 | } 17 | ~MyClass() 18 | { 19 | cout << "MyClass " << info << " destruct" << endl; 20 | } 21 | 22 | void printInfo() 23 | { 24 | cout << info << endl; 25 | } 26 | }; 27 | 28 | int main() 29 | { 30 | Pitocin::LinkStack stack; 31 | stack.emplace("number1"); 32 | stack.emplace("number2"); 33 | MyClass *my = stack.pop(); 34 | my->printInfo(); 35 | MyClass *my1 = stack.pop(); 36 | my1->printInfo(); 37 | stack.push(my); 38 | stack.push(my1); 39 | return 0; 40 | } -------------------------------------------------------------------------------- /qmq-client/src/main/java/qunar/tc/qmq/common/ClientIdProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.common; 18 | 19 | /** 20 | * Created by zhaohui.yu 21 | * 4/2/18 22 | */ 23 | public interface ClientIdProvider { 24 | String get(); 25 | } 26 | -------------------------------------------------------------------------------- /qmq-client/src/main/java/qunar/tc/qmq/producer/sender/Router.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.producer.sender; 18 | 19 | import qunar.tc.qmq.Message; 20 | 21 | public interface Router { 22 | 23 | Connection route(Message message); 24 | } 25 | -------------------------------------------------------------------------------- /qmq-metaserver/src/main/java/qunar/tc/qmq/meta/route/SubjectRouteExtend.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.meta.route; 2 | 3 | import java.util.List; 4 | 5 | import qunar.tc.qmq.meta.BrokerGroup; 6 | import qunar.tc.qmq.protocol.consumer.MetaInfoRequest; 7 | 8 | /** 9 | * The interface Subject route extend. 10 | * @description: 11 | * @author :zhixin.zhang 12 | * @date :Created in 下午4:06 2021/12/13 13 | */ 14 | public interface SubjectRouteExtend { 15 | 16 | /** 17 | * Match list. 18 | * 19 | * @param request the request 20 | * @return the list 21 | */ 22 | boolean match( final MetaInfoRequest request); 23 | 24 | /** 25 | * Route extend list. 26 | * 27 | * @param brokerGroups the broker groups 28 | * @param request the request 29 | * @return the list 30 | */ 31 | List routeExtend(List brokerGroups, final MetaInfoRequest request); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/MessageSubscriber.cs: -------------------------------------------------------------------------------- 1 | // yuzhaohui 2 | // 2016/8/8 3 | 4 | using System; 5 | using Qunar.TC.Qmq.Client.Consumer; 6 | using Qunar.TC.Qmq.Client.tag; 7 | 8 | namespace Qunar.TC.Qmq.Client 9 | { 10 | public interface MessageSubscriber 11 | { 12 | event MessageListener Received; 13 | 14 | ConsumeMode Mode 15 | { 16 | get; 17 | set; 18 | } 19 | 20 | int PullBatchSize 21 | { 22 | get; 23 | set; 24 | } 25 | 26 | TimeSpan PullBatchTimeout 27 | { 28 | get; 29 | set; 30 | } 31 | 32 | string[] Tags 33 | { 34 | set; 35 | } 36 | 37 | TagType TagType 38 | { 39 | set; 40 | } 41 | 42 | void Start(); 43 | 44 | void Stop(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /qmq-api/src/main/java/qunar/tc/qmq/BaseConsumer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq; 18 | 19 | /** 20 | * @author yiqun.fan create on 17-9-12. 21 | */ 22 | public interface BaseConsumer { 23 | 24 | String subject(); 25 | 26 | String group(); 27 | } 28 | -------------------------------------------------------------------------------- /qmq-common/src/main/java/qunar/tc/qmq/common/Disposable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.common; 18 | 19 | /** 20 | * User: zhaohuiyu 21 | * Date: 7/24/13 22 | * Time: 3:17 PM 23 | */ 24 | public interface Disposable { 25 | void destroy(); 26 | } 27 | -------------------------------------------------------------------------------- /qmq-client/src/main/java/qunar/tc/qmq/producer/sender/Route.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.producer.sender; 18 | 19 | /** 20 | * @author zhenyu.nie created on 2017 2017/7/3 12:24 21 | */ 22 | public interface Route { 23 | 24 | Connection route(); 25 | } 26 | -------------------------------------------------------------------------------- /qmq-common/src/main/java/qunar/tc/qmq/configuration/Listener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.configuration; 18 | 19 | /** 20 | * @author keli.wang 21 | * @since 2018-11-27 22 | */ 23 | public interface Listener { 24 | void onLoad(DynamicConfig config); 25 | } 26 | -------------------------------------------------------------------------------- /qmq-common/src/main/java/qunar/tc/qmq/metrics/QmqMeter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.metrics; 18 | 19 | /** 20 | * @author keli.wang 21 | * @since 2018/11/21 22 | */ 23 | public interface QmqMeter { 24 | void mark(); 25 | 26 | void mark(long n); 27 | } 28 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Codec/NewQmq/RemotingHeader.cs: -------------------------------------------------------------------------------- 1 | namespace Qunar.TC.Qmq.Client.Codec.NewQmq 2 | { 3 | internal class RemotingHeader 4 | { 5 | public const int QmqMagicCode = unchecked((int)0xdec10ade); 6 | 7 | public const short Version3 = 3; 8 | public const short Version4 = 4; 9 | public const short Version8 = 8; 10 | 11 | public const short MinHeaderSize = 16; 12 | public const short HeaderSizeLen = 2; 13 | public const short TotalSizeLen = 4; 14 | public const short LengthFieldLen = TotalSizeLen + HeaderSizeLen; 15 | 16 | public short Code { get; set; } 17 | 18 | public short Version { get; set; } 19 | 20 | public int Opaque { get; set; } 21 | 22 | public int Flag { get; set; } 23 | 24 | public short RequestCode { get; set; } 25 | 26 | public int MagicCode { get; set; } 27 | } 28 | } -------------------------------------------------------------------------------- /qmq-backup/src/main/java/qunar/tc/qmq/backup/base/Flushable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.backup.base; 18 | 19 | /** 20 | * @author xufeng.deng dennisdxf@gmail.com 21 | * @since 2018-11-27 20:40 22 | */ 23 | public interface Flushable { 24 | void flush(); 25 | } 26 | -------------------------------------------------------------------------------- /qmq-remoting/src/main/java/qunar/tc/qmq/protocol/consumer/PullFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.protocol.consumer; 18 | 19 | /** 20 | * @author keli.wang 21 | * @since 2019-01-02 22 | */ 23 | public interface PullFilter { 24 | PullFilterType type(); 25 | } 26 | -------------------------------------------------------------------------------- /qmq-client/src/main/java/qunar/tc/qmq/consumer/pull/AckHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.consumer.pull; 18 | 19 | /** 20 | * @author yiqun.fan create on 17-9-11. 21 | */ 22 | public interface AckHook { 23 | void call(PulledMessage message, Throwable throwable); 24 | } 25 | -------------------------------------------------------------------------------- /qmq-server-common/src/main/java/qunar/tc/qmq/jdbc/DefaultDataSourceFactory.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.jdbc; 2 | 3 | import javax.sql.DataSource; 4 | 5 | import com.zaxxer.hikari.HikariConfig; 6 | import com.zaxxer.hikari.HikariDataSource; 7 | import qunar.tc.qmq.configuration.DynamicConfig; 8 | 9 | public class DefaultDataSourceFactory implements DataSourceFactory { 10 | 11 | @Override 12 | public DataSource createDataSource(DynamicConfig config) { 13 | final HikariConfig cpConfig = new HikariConfig(); 14 | cpConfig.setDriverClassName(config.getString("jdbc.driverClassName", "com.mysql.jdbc.Driver")); 15 | cpConfig.setJdbcUrl(config.getString("jdbc.url")); 16 | cpConfig.setUsername(config.getString("jdbc.username")); 17 | cpConfig.setPassword(config.getString("jdbc.password")); 18 | cpConfig.setMaximumPoolSize(config.getInt("pool.size.max", 10)); 19 | 20 | return new HikariDataSource(cpConfig); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /qmq-client/src/main/java/qunar/tc/qmq/producer/idgenerator/IdGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.producer.idgenerator; 18 | 19 | /** 20 | * User: zhaohuiyu 21 | * Date: 6/4/13 22 | * Time: 10:06 AM 23 | */ 24 | public interface IdGenerator { 25 | String getNext(); 26 | } 27 | -------------------------------------------------------------------------------- /qmq-api/src/main/java/qunar/tc/qmq/MessageListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package qunar.tc.qmq; 17 | 18 | /** 19 | * @author miao.yang susing@gmail.com 20 | * @date 2012-12-26 21 | */ 22 | public interface MessageListener { 23 | 24 | void onMessage(Message msg); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /qmq-store/src/main/java/qunar/tc/qmq/store/Serde.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.store; 18 | 19 | /** 20 | * @author keli.wang 21 | * @since 2018/9/10 22 | */ 23 | public interface Serde { 24 | byte[] toBytes(final V value); 25 | 26 | V fromBytes(final byte[] data); 27 | } 28 | -------------------------------------------------------------------------------- /qmq-delay-server/src/main/java/qunar/tc/qmq/delay/EventListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.delay; 18 | 19 | /** 20 | * @author xufeng.deng dennisdxf@gmail.com 21 | * @since 2018-07-13 9:42 22 | */ 23 | public interface EventListener { 24 | 25 | void post(T event); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /qmq-metaserver/src/main/java/qunar/tc/qmq/meta/store/ClientDbConfigurationStore.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.meta.store; 18 | 19 | import qunar.tc.qmq.meta.model.ClientDbInfo; 20 | 21 | public interface ClientDbConfigurationStore { 22 | void insertDb(ClientDbInfo clientDbInfo); 23 | } 24 | -------------------------------------------------------------------------------- /qmq-metaserver/src/main/java/qunar/tc/qmq/meta/cache/CacheManagerExtend.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.meta.cache; 2 | 3 | import qunar.tc.qmq.meta.store.Store; 4 | import qunar.tc.qmq.protocol.consumer.MetaInfoRequest; 5 | 6 | /** 7 | * The interface Cache manager extend. 8 | * @description: 9 | * @author :zhixin.zhang 10 | * @date :Created in 下午4:31 2022/2/21 11 | */ 12 | public interface CacheManagerExtend { 13 | 14 | /** 15 | * Add request. 16 | * 17 | * @param request the request 18 | */ 19 | void addRequest(MetaInfoRequest request); 20 | 21 | /** 22 | * Sets store. 23 | * 24 | * @param store the store 25 | */ 26 | void setStore(Store store); 27 | 28 | /** 29 | * Match boolean. 30 | * 31 | * @param request the request 32 | * @return the boolean 33 | */ 34 | boolean match(MetaInfoRequest request); 35 | 36 | /** 37 | * Name string. 38 | * 39 | * @return the string 40 | */ 41 | String name(); 42 | } 43 | -------------------------------------------------------------------------------- /qmq-remoting/src/main/java/qunar/tc/qmq/protocol/PayloadHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.protocol; 18 | 19 | import io.netty.buffer.ByteBuf; 20 | 21 | /** 22 | * Created by zhaohui.yu 23 | * 7/21/17 24 | */ 25 | public interface PayloadHolder { 26 | void writeBody(ByteBuf out); 27 | } 28 | -------------------------------------------------------------------------------- /qmq-store/src/main/java/qunar/tc/qmq/store/CheckpointLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.store; 18 | 19 | import io.netty.buffer.ByteBuf; 20 | 21 | /** 22 | * @author keli.wang 23 | * @since 2018/10/29 24 | */ 25 | public interface CheckpointLoader { 26 | ByteBuf loadCheckpoint(); 27 | } 28 | -------------------------------------------------------------------------------- /qmq-api/src/main/java/qunar/tc/qmq/ListenerHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package qunar.tc.qmq; 17 | 18 | /** 19 | * @author miao.yang susing@gmail.com 20 | * @date 2012-12-26 21 | */ 22 | public interface ListenerHolder { 23 | void stopListen(); 24 | 25 | void resumeListen(); 26 | } 27 | -------------------------------------------------------------------------------- /qmq-backup/src/main/java/qunar/tc/qmq/backup/spi/DeadMessageHandlerFactory.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.backup.spi; 2 | 3 | import java.util.ServiceLoader; 4 | 5 | import qunar.tc.qmq.backup.spi.impl.DefaultDeadMessageSpiHandler; 6 | 7 | /** 8 | * TODO completion javadoc. 9 | * 10 | * @author xiao.liang 11 | * @since 08 June 2020 12 | */ 13 | public class DeadMessageHandlerFactory { 14 | 15 | private static DeadMessageSpiHandler INSTANCE; 16 | 17 | static { 18 | ServiceLoader services = ServiceLoader.load(DeadMessageSpiHandler.class); 19 | DeadMessageSpiHandler instance = null; 20 | for (DeadMessageSpiHandler registry : services) { 21 | instance = registry; 22 | break; 23 | } 24 | if (instance == null) { 25 | instance = new DefaultDeadMessageSpiHandler(); 26 | } 27 | 28 | INSTANCE = instance; 29 | } 30 | 31 | public static DeadMessageSpiHandler load() { 32 | return INSTANCE; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /qmq-common/src/main/java/qunar/tc/qmq/batch/Processor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.batch; 18 | 19 | import java.util.List; 20 | 21 | /** 22 | * User: zhaohuiyu 23 | * Date: 6/4/13 24 | * Time: 5:21 PM 25 | */ 26 | public interface Processor { 27 | void process(List items); 28 | } 29 | -------------------------------------------------------------------------------- /qmq-common/src/main/java/qunar/tc/qmq/broker/BrokerLoadBalance.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.broker; 18 | 19 | /** 20 | * @author yiqun.fan create on 17-8-18. 21 | */ 22 | public interface BrokerLoadBalance { 23 | BrokerGroupInfo loadBalance(BrokerClusterInfo cluster, BrokerGroupInfo lastGroup); 24 | } 25 | -------------------------------------------------------------------------------- /qmq-common/src/main/java/qunar/tc/qmq/metrics/QmqTimer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.metrics; 18 | 19 | import java.util.concurrent.TimeUnit; 20 | 21 | /** 22 | * @author keli.wang 23 | * @since 2018/11/21 24 | */ 25 | public interface QmqTimer { 26 | void update(long duration, TimeUnit unit); 27 | } 28 | -------------------------------------------------------------------------------- /qmq-delay-server/src/main/java/qunar/tc/qmq/delay/Switchable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.delay; 18 | 19 | /** 20 | * @author xufeng.deng dennisdxf@gmail.com 21 | * @since 2018-07-16 16:45 22 | */ 23 | public interface Switchable { 24 | 25 | void start(); 26 | 27 | void shutdown(); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /qmq-api/src/main/java/qunar/tc/qmq/IdempotentAttachable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq; 18 | 19 | /** 20 | * Created by zhaohui.yu 21 | * 15/12/8 22 | *

23 | * 通过这个接口可以给MessageListener添加幂等检查的功能 24 | */ 25 | public interface IdempotentAttachable { 26 | IdempotentChecker getIdempotentChecker(); 27 | } 28 | -------------------------------------------------------------------------------- /qmq-common/src/main/java/qunar/tc/qmq/configuration/DynamicConfigFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.configuration; 18 | 19 | /** 20 | * @author keli.wang 21 | * @since 2018-11-23 22 | */ 23 | public interface DynamicConfigFactory { 24 | DynamicConfig create(String name, boolean failOnNotExist); 25 | } 26 | -------------------------------------------------------------------------------- /qmq-api/src/main/java/qunar/tc/qmq/FilterAttachable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq; 18 | 19 | import java.util.List; 20 | 21 | /** 22 | * Created by zhaohui.yu 23 | * 15/12/8 24 | * 25 | * MessageListener如果实现了这个接口,则可以附加filter 26 | */ 27 | public interface FilterAttachable { 28 | List filters(); 29 | } 30 | -------------------------------------------------------------------------------- /qmq-client/src/main/java/qunar/tc/qmq/common/EnvProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.common; 18 | 19 | /** 20 | * @author xufeng.deng dennisdxf@gmail.com 21 | * @since 2019/6/10 22 | */ 23 | public interface EnvProvider { 24 | 25 | String env(String subject); 26 | 27 | String subEnv(String env); 28 | } 29 | -------------------------------------------------------------------------------- /qmq-metaserver/src/main/java/qunar/tc/qmq/meta/web/ResultStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.meta.web; 18 | 19 | /** 20 | * @author keli.wang 21 | * @since 2018-11-27 22 | */ 23 | public final class ResultStatus { 24 | public static final int OK = 0; 25 | public static final int SYSTEM_ERROR = -1; 26 | } 27 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Util/WaitHolder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace Qunar.TC.Qmq.Client.Util 5 | { 6 | internal class WaitHolder 7 | { 8 | private readonly ManualResetEventSlim _waitAvaliable = new ManualResetEventSlim(); 9 | private readonly object _updateGuard = new object(); 10 | private T _result; 11 | 12 | public bool AlreadySet => _waitAvaliable.IsSet; 13 | 14 | public T Result 15 | { 16 | get 17 | { 18 | _waitAvaliable.Wait(); 19 | lock (_updateGuard) 20 | { 21 | return _result; 22 | } 23 | } 24 | set 25 | { 26 | lock (_updateGuard) 27 | { 28 | _result = value; 29 | } 30 | _waitAvaliable.Set(); 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /qmq-metaserver/src/main/java/qunar/tc/qmq/meta/loadbalance/LoadBalanceFactory.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.meta.loadbalance; 2 | 3 | import java.util.Map; 4 | import java.util.ServiceLoader; 5 | 6 | import com.google.common.collect.Maps; 7 | 8 | /** 9 | * @description:定义loadbalance 10 | * @author :zhixin.zhang 11 | * @date :Created in 下午4:07 2021/12/13 12 | */ 13 | public class LoadBalanceFactory { 14 | 15 | private static Map loadBalances = Maps.newHashMap(); 16 | 17 | private static RandomLoadBalance defaultLoadBalance = new RandomLoadBalance(); 18 | 19 | static { 20 | ServiceLoader services = ServiceLoader.load(LoadBalance.class); 21 | for (LoadBalance instance : services) { 22 | loadBalances.put(instance.name(), instance); 23 | } 24 | } 25 | 26 | public static LoadBalance getByName(String name) { 27 | return loadBalances.containsKey(name) ? loadBalances.get(name) : defaultLoadBalance; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /qmq-remoting/src/main/java/qunar/tc/qmq/netty/client/Response.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.netty.client; 18 | 19 | /** 20 | * @author yiqun.fan create on 17-8-29. 21 | */ 22 | public interface Response { 23 | int getStatusCode(); 24 | 25 | String getHeader(String name); 26 | 27 | String getBody(); 28 | } 29 | -------------------------------------------------------------------------------- /qmq-common/src/main/java/qunar/tc/qmq/metrics/QmqCounter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.metrics; 18 | 19 | /** 20 | * @author keli.wang 21 | * @since 2018/11/21 22 | */ 23 | public interface QmqCounter { 24 | void inc(); 25 | 26 | void inc(long n); 27 | 28 | void dec(); 29 | 30 | void dec(long n); 31 | } 32 | -------------------------------------------------------------------------------- /qmq-server/src/main/java/qunar/tc/qmq/processor/filters/Invoker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.processor.filters; 18 | 19 | import qunar.tc.qmq.base.ReceivingMessage; 20 | 21 | /** 22 | * @author yunfeng.yang 23 | * @since 2017/8/7 24 | */ 25 | public interface Invoker { 26 | void invoke(ReceivingMessage message); 27 | } 28 | -------------------------------------------------------------------------------- /qmq-server/src/main/java/qunar/tc/qmq/sync/master/SyncProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.sync.master; 18 | 19 | /** 20 | * @author keli.wang 21 | * @since 2018/11/2 22 | */ 23 | interface SyncProcessor { 24 | void process(SyncRequestEntry entry); 25 | 26 | void processTimeout(SyncRequestEntry entry); 27 | } 28 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/MessageProducer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Qunar.TC.Qmq.Client 4 | { 5 | ///

6 | /// QMQ生产者接口 7 | /// 8 | public interface MessageProducer 9 | { 10 | /// 11 | /// 生成消息 12 | /// 13 | /// 指定subject 14 | /// 15 | Message GenerateMessage(string subject); 16 | 17 | /// 18 | /// 发送消息 19 | /// 20 | /// 可以使用onSuccess和onFailed回调监控消息发送状态,但是需要注意的是,如果使用的是事务或持久消息, 21 | /// onFailed触发也并不意味着消息最后丢失 22 | /// 23 | /// 使用GenerateMessage生成的消息,并设置好业务属性 24 | /// 该消息成功发送到broker时会调用,可选 25 | /// 该消息发送到broker失败时会调用,可选 26 | void Send(Message message, Action onSuccess = null, Action onFailed = null); 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /qmq-metaserver/src/main/java/qunar/tc/qmq/meta/route/SubjectRegisterService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.meta.route; 18 | 19 | /** 20 | * @author keli.wang 21 | * @since 2017/12/4 22 | */ 23 | public interface SubjectRegisterService { 24 | void register(final String subject, final String tenant, final String appCode); 25 | } 26 | -------------------------------------------------------------------------------- /qmq-store/src/main/java/qunar/tc/qmq/store/MessageFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.store; 18 | 19 | /** 20 | * Created by zhaohui.yu 21 | * 9/3/18 22 | */ 23 | interface MessageFilter { 24 | boolean filter(WithTimestamp entry); 25 | 26 | interface WithTimestamp { 27 | long getTimestamp(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /qmq-store/src/main/java/qunar/tc/qmq/store/Visitable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.store; 18 | 19 | /** 20 | * @author keli.wang 21 | * @since 2019-06-18 22 | */ 23 | public interface Visitable { 24 | AbstractLogVisitor newVisitor(long iterateFrom); 25 | 26 | long getMinOffset(); 27 | 28 | long getMaxOffset(); 29 | } -------------------------------------------------------------------------------- /qmq-backup/src/main/java/qunar/tc/qmq/backup/service/FileStore.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.backup.service; 18 | 19 | import qunar.tc.qmq.backup.base.ScheduleFlushable; 20 | 21 | /** 22 | * @author xufeng.deng dennisdxf@gmail.com 23 | * @since 2018-11-28 16:20 24 | */ 25 | public interface FileStore extends ScheduleFlushable { 26 | } 27 | -------------------------------------------------------------------------------- /qmq-client/src/main/java/qunar/tc/qmq/producer/tx/SqlStatementProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.producer.tx; 18 | 19 | /** 20 | * Created by zhaohui.yu 21 | * 1/5/19 22 | */ 23 | public interface SqlStatementProvider { 24 | String getInsertSql(); 25 | 26 | String getBlockSql(); 27 | 28 | String getDeleteSql(); 29 | } 30 | -------------------------------------------------------------------------------- /qmq-backup/src/main/java/qunar/tc/qmq/backup/store/DicStore.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.backup.store; 18 | 19 | /** 20 | * @author yiqun.fan create on 17-10-31. 21 | */ 22 | public interface DicStore { 23 | String getName(int nameId); 24 | 25 | int getNameId(String name); 26 | 27 | void insertName(int nameId, String name); 28 | } 29 | -------------------------------------------------------------------------------- /qmq-client/src/main/java/qunar/tc/qmq/common/ClientIdProviderFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.common; 18 | 19 | /** 20 | * Created by zhaohui.yu 21 | * 4/2/18 22 | */ 23 | public class ClientIdProviderFactory { 24 | public static ClientIdProvider createDefault() { 25 | return new DefaultClientIdProvider(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /qmq-remoting/src/main/java/qunar/tc/qmq/netty/client/HttpResponseCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.netty.client; 18 | 19 | /** 20 | * @author yiqun.fan create on 17-8-29. 21 | */ 22 | public interface HttpResponseCallback { 23 | V onCompleted(Response response) throws Exception; 24 | 25 | void onThrowable(Throwable t); 26 | } 27 | -------------------------------------------------------------------------------- /qmq-backup/src/main/java/qunar/tc/qmq/backup/config/BackupConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.backup.config; 18 | 19 | import qunar.tc.qmq.configuration.DynamicConfig; 20 | 21 | public interface BackupConfig { 22 | String getBrokerGroup(); 23 | 24 | void setBrokerGroup(String name); 25 | 26 | DynamicConfig getDynamicConfig(); 27 | } 28 | -------------------------------------------------------------------------------- /qmq-client/src/main/java/qunar/tc/qmq/consumer/pull/PulledMessageFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.consumer.pull; 18 | 19 | /** 20 | * @author yiqun.fan create on 17-11-2. 21 | */ 22 | interface PulledMessageFilter { 23 | 24 | /** 25 | * @return true时,保留;false时,丢弃 26 | */ 27 | boolean filter(final PulledMessage message); 28 | } 29 | -------------------------------------------------------------------------------- /qmq-server/src/main/java/qunar/tc/qmq/processor/filters/ReceiveFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.processor.filters; 18 | 19 | import qunar.tc.qmq.base.ReceivingMessage; 20 | 21 | /** 22 | * User: zhaohuiyu Date: 4/1/13 Time: 3:10 PM 23 | */ 24 | public interface ReceiveFilter { 25 | void invoke(Invoker invoker, ReceivingMessage message); 26 | } -------------------------------------------------------------------------------- /qmq-remoting/src/main/java/qunar/tc/qmq/netty/exception/RemoteBusyException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.netty.exception; 18 | 19 | /** 20 | * @author zhenyu.nie created on 2017 2017/7/6 18:16 21 | */ 22 | public class RemoteBusyException extends RemoteException { 23 | 24 | private static final long serialVersionUID = -1246238157178008281L; 25 | } 26 | -------------------------------------------------------------------------------- /qmq-store/src/main/java/qunar/tc/qmq/store/Action.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.store; 18 | 19 | /** 20 | * @author keli.wang 21 | * @since 2017/8/20 22 | */ 23 | public interface Action { 24 | ActionType type(); 25 | 26 | String subject(); 27 | 28 | String group(); 29 | 30 | String consumerId(); 31 | 32 | long timestamp(); 33 | } 34 | -------------------------------------------------------------------------------- /qmq-api/src/main/java/qunar/tc/qmq/TransactionProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package qunar.tc.qmq; 17 | 18 | /** 19 | * Created by zhaohui.yu 20 | * 10/26/16 21 | */ 22 | public interface TransactionProvider { 23 | 24 | boolean isInTransaction(); 25 | 26 | void setTransactionListener(TransactionListener listener); 27 | 28 | MessageStore messageStore(); 29 | } 30 | -------------------------------------------------------------------------------- /qmq-client/src/main/java/qunar/tc/qmq/consumer/pull/AlwaysPullStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.consumer.pull; 18 | 19 | class AlwaysPullStrategy implements PullStrategy { 20 | @Override 21 | public boolean needPull() { 22 | return true; 23 | } 24 | 25 | @Override 26 | public void record(boolean status) { 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /qmq-store/src/main/java/qunar/tc/qmq/store/AppendMessageStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.store; 18 | 19 | /** 20 | * @author keli.wang 21 | * @since 2017/7/4 22 | */ 23 | public enum AppendMessageStatus { 24 | SUCCESS, 25 | END_OF_FILE, 26 | DATA_OVERFLOW, 27 | APPEND_FAILED, 28 | MESSAGE_SIZE_EXCEEDED, 29 | UNKNOWN_ERROR 30 | } 31 | -------------------------------------------------------------------------------- /qmq-watchdog/src/main/java/qunar/tc/qmq/task/model/DataSourceInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.task.model; 18 | 19 | 20 | public class DataSourceInfo { 21 | private String url; 22 | 23 | public String getUrl() { 24 | return url; 25 | } 26 | 27 | public void setUrl(String jdbcUrl) { 28 | this.url = jdbcUrl; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /qmq-metaserver/src/main/java/qunar/tc/qmq/meta/management/MetaManagementAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.meta.management; 18 | 19 | import javax.servlet.http.HttpServletRequest; 20 | 21 | /** 22 | * @author keli.wang 23 | * @since 2017/10/20 24 | */ 25 | public interface MetaManagementAction { 26 | Object handleAction(final HttpServletRequest req); 27 | } 28 | -------------------------------------------------------------------------------- /qmq-backup/src/main/java/qunar/tc/qmq/backup/base/ScheduleFlushable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.backup.base; 18 | 19 | import qunar.tc.qmq.common.Disposable; 20 | 21 | /** 22 | * @author xufeng.deng dennisdxf@gmail.com 23 | * @since 2018-11-27 20:40 24 | */ 25 | public interface ScheduleFlushable extends Flushable, Disposable { 26 | void scheduleFlush(); 27 | } 28 | -------------------------------------------------------------------------------- /qmq-delay-server/src/main/java/qunar/tc/qmq/delay/receiver/Invoker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.delay.receiver; 18 | 19 | import qunar.tc.qmq.delay.base.ReceivedDelayMessage; 20 | 21 | /** 22 | * @author xufeng.deng dennisdxf@gmail.com 23 | * @since 2018-07-26 14:28 24 | */ 25 | public interface Invoker { 26 | void invoke(ReceivedDelayMessage message); 27 | } 28 | -------------------------------------------------------------------------------- /qmq-store/src/main/java/qunar/tc/qmq/store/ActionReaderWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.store; 18 | 19 | import java.nio.ByteBuffer; 20 | 21 | /** 22 | * @author keli.wang 23 | * @since 2017/8/20 24 | */ 25 | public interface ActionReaderWriter { 26 | int write(final ByteBuffer to, final Action action); 27 | 28 | Action read(final ByteBuffer from); 29 | } 30 | -------------------------------------------------------------------------------- /qmq-delay-server/src/main/java/qunar/tc/qmq/delay/base/AppendException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.delay.base; 18 | 19 | /** 20 | * @author xufeng.deng dennisdxf@gmail.com 21 | * @since 2018-08-03 11:01 22 | */ 23 | public class AppendException extends RuntimeException { 24 | 25 | public AppendException(String message) { 26 | super(message); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /qmq-delay-server/src/main/java/qunar/tc/qmq/delay/sync/slave/SyncLogProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.delay.sync.slave; 18 | 19 | import qunar.tc.qmq.protocol.Datagram; 20 | 21 | /** 22 | * @author yunfeng.yang 23 | * @since 2017/8/18 24 | */ 25 | public interface SyncLogProcessor { 26 | void process(Datagram syncData); 27 | 28 | T getRequest(); 29 | } 30 | -------------------------------------------------------------------------------- /qmq-demo/src/main/java/qunar/tc/qmq/demo/dao/OrderRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.demo.dao; 18 | 19 | import org.springframework.data.jpa.repository.JpaRepository; 20 | import org.springframework.stereotype.Repository; 21 | import qunar.tc.qmq.demo.model.Order; 22 | 23 | @Repository 24 | public interface OrderRepository extends JpaRepository { 25 | } 26 | -------------------------------------------------------------------------------- /docs/cn/net.md: -------------------------------------------------------------------------------- 1 | [上一页](exactlyonce.md) 2 | [回目录](../../README.md) 3 | [下一页](delay.md) 4 | 5 | # .NET Client 6 | 7 | .NET Client的API和Java Client基本类似,更详细的发送消息和消费消息流程可以参考Java Client,在这里只做简单的说明。 8 | 9 | ## 代码位置 10 | clone仓库代码后,.NET Client的代码位于clients/csharp目录下,目前没有提供编译好的dll,可以自行从代码编译,.NET Framework最低要求4.0 11 | 12 | ## 发送消息 13 | ```csharp 14 | var producer = new MessageProducerProvider("app code", "http:///meta/address"); 15 | var message = producer.GenerateMessage("your subject"); 16 | message.SetProperty("key", value); 17 | 18 | producer.Send(message, onSuccess: (m) =>{}, onFailed: (m) => { }); 19 | ``` 20 | 21 | ## 消费消息 22 | ```csharp 23 | var consumer = new MessageConsumerProvider("app code", "http:///meta/address"); 24 | var subscriber = consumer.Subscribe("your subject", "your consumer group"); 25 | subscriber.Received += (m) => { 26 | //process your message 27 | }; 28 | subscriber.Start(); 29 | ``` 30 | 31 | [上一页](exactlyonce.md) 32 | [回目录](../../README.md) 33 | [下一页](delay.md) 34 | -------------------------------------------------------------------------------- /qmq-delay-server/src/main/java/qunar/tc/qmq/delay/base/GroupSendException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.delay.base; 18 | 19 | /** 20 | * @author xufeng.deng dennisdxf@gmail.com 21 | * @since 2018-09-03 10:27 22 | */ 23 | public class GroupSendException extends RuntimeException { 24 | public GroupSendException(Throwable cause) { 25 | super(cause); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /qmq-remoting/src/main/java/qunar/tc/qmq/metainfoclient/ConsumerStateChangedListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.metainfoclient; 18 | 19 | /** 20 | * Created by zhaohui.yu 21 | * 4/2/18 22 | */ 23 | public interface ConsumerStateChangedListener { 24 | void online(String subject, String consumerGroup); 25 | 26 | void offline(String subject, String consumerGroup); 27 | } 28 | -------------------------------------------------------------------------------- /qmq-remoting/src/main/java/qunar/tc/qmq/netty/exception/RemoteResponseUnreadableException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.netty.exception; 18 | 19 | /** 20 | * @author zhenyu.nie created on 2017 2017/7/10 16:11 21 | */ 22 | public class RemoteResponseUnreadableException extends RemoteException { 23 | private static final long serialVersionUID = -4706381924995618174L; 24 | } 25 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Id/TimestampIdGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using System.Diagnostics; 4 | using System.Threading; 5 | 6 | using Qunar.TC.Qmq.Client.Util; 7 | 8 | namespace Qunar.TC.Qmq.Client 9 | { 10 | class TimestampIdGenerator : IdGenerator 11 | { 12 | private static int index; 13 | 14 | private static readonly string IP = NetUtils.LocalHost(); 15 | 16 | private static readonly int PID = Process.GetCurrentProcess().Id; 17 | 18 | public string Generate() 19 | { 20 | //time 21 | var result = new StringBuilder(DateTime.Now.ToString("yyMMdd.HHmmss")); 22 | //ip 23 | result.Append('.').Append(IP); 24 | 25 | //pid 26 | result.Append('.').Append(PID); 27 | 28 | //index 29 | var order = Interlocked.Increment(ref index) % 100000; 30 | result.Append(".").Append(order); 31 | return result.ToString(); 32 | } 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /qmq-delay-server/src/main/java/qunar/tc/qmq/delay/store/log/SegmentContainer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.delay.store.log; 18 | 19 | 20 | /** 21 | * @author xufeng.deng dennisdxf@gmail.com 22 | * @since 2018-07-19 10:03 23 | */ 24 | public interface SegmentContainer { 25 | 26 | R append(T record); 27 | 28 | boolean clean(Long key); 29 | 30 | void flush(); 31 | } 32 | -------------------------------------------------------------------------------- /qmq-store/src/main/java/qunar/tc/qmq/store/MessageAppender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.store; 18 | 19 | import java.nio.ByteBuffer; 20 | 21 | /** 22 | * @author keli.wang 23 | * @since 2017/7/5 24 | */ 25 | public interface MessageAppender { 26 | AppendMessageResult doAppend(final long baseOffset, final ByteBuffer targetBuffer, final int freeSpace, final T message); 27 | } 28 | -------------------------------------------------------------------------------- /qmq-sync/src/main/java/qunar/tc/qmq/sync/SyncLogProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.sync; 18 | 19 | import qunar.tc.qmq.base.SyncRequest; 20 | import qunar.tc.qmq.protocol.Datagram; 21 | 22 | /** 23 | * @author yunfeng.yang 24 | * @since 2017/8/18 25 | */ 26 | public interface SyncLogProcessor { 27 | void process(Datagram syncData); 28 | 29 | SyncRequest getRequest(); 30 | } 31 | -------------------------------------------------------------------------------- /qmq-client/src/main/java/qunar/tc/qmq/producer/tx/spring/RouterSelector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.producer.tx.spring; 18 | 19 | import javax.sql.DataSource; 20 | 21 | public interface RouterSelector { 22 | Object getRouteKey(DataSource dataSource); 23 | 24 | void setRouteKey(Object key, DataSource dataSource); 25 | 26 | void clearRoute(Object key, DataSource dataSource); 27 | } 28 | -------------------------------------------------------------------------------- /qmq-metaserver/src/main/java/qunar/tc/qmq/meta/store/ClientMetaInfoStore.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.meta.store; 18 | 19 | import java.util.List; 20 | 21 | import qunar.tc.qmq.meta.model.ClientMetaInfo; 22 | 23 | /** 24 | * @author keli.wang 25 | * @since 2017/12/5 26 | */ 27 | public interface ClientMetaInfoStore { 28 | List queryConsumer(final String subject); 29 | } 30 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/NewQmq/PullController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Qunar.TC.Qmq.Client.Metainfo; 3 | 4 | namespace Qunar.TC.Qmq.Client.NewQmq 5 | { 6 | internal class PullController 7 | { 8 | public PullController(string appCode, string metaServer) 9 | { 10 | BrokerGroupService = new BrokerGroupService(appCode, metaServer); 11 | var sendMessageBackService = new SendMessageBackService(BrokerGroupService); 12 | AckMessageService = new AckMessageService(BrokerGroupService); 13 | AckHandlerQueueManager = new AckHandlerQueueManager(AckMessageService, sendMessageBackService); 14 | PullMessageService = new PullMessageService(AckHandlerQueueManager); 15 | } 16 | 17 | public PullMessageService PullMessageService { get; } 18 | 19 | public AckMessageService AckMessageService { get; } 20 | 21 | public AckHandlerQueueManager AckHandlerQueueManager { get; } 22 | 23 | public BrokerGroupService BrokerGroupService { get; } 24 | } 25 | } -------------------------------------------------------------------------------- /qmq-metaserver/src/main/java/qunar/tc/qmq/meta/route/SubjectConsumerService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.meta.route; 18 | 19 | import qunar.tc.qmq.meta.model.GroupedConsumer; 20 | 21 | import java.util.List; 22 | 23 | /** 24 | * @author keli.wang 25 | * @since 2017/12/5 26 | */ 27 | public interface SubjectConsumerService { 28 | List consumers(final String subject); 29 | } 30 | -------------------------------------------------------------------------------- /qmq-backup/src/main/java/qunar/tc/qmq/backup/service/SyncLogIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.backup.service; 18 | 19 | import qunar.tc.qmq.store.LogVisitorRecord; 20 | 21 | /** 22 | * @author xufeng.deng dennisdxf@gmail.com 23 | * @since 2018-11-27 17:28 24 | */ 25 | public interface SyncLogIterator { 26 | boolean hasNext(P buf); 27 | 28 | LogVisitorRecord next(P buf); 29 | } 30 | -------------------------------------------------------------------------------- /qmq-backup/src/main/java/qunar/tc/qmq/backup/store/RocksDBStore.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.backup.store; 18 | 19 | import java.io.Closeable; 20 | import java.util.Optional; 21 | 22 | /** 23 | * @author yunfeng.yang 24 | * @since 2018/3/21 25 | */ 26 | public interface RocksDBStore extends Closeable { 27 | void put(String key, String value); 28 | 29 | Optional get(String key); 30 | } 31 | -------------------------------------------------------------------------------- /clients/cpp/pitocin/test/test_conn.cpp: -------------------------------------------------------------------------------- 1 | #include "Conn.hpp" 2 | #include 3 | #include 4 | #include 5 | 6 | int main() 7 | { 8 | using namespace std; 9 | uv_loop_t *loop = uv_default_loop(); 10 | Pitocin::Conn conn(loop); 11 | conn.setAddr("127.0.0.1", 8080); 12 | conn.setOnConnectCallback([&conn]() { 13 | cout << "on_connect" << endl; 14 | stringstream s; 15 | s << "GET /meta/address HTTP/1.1" 16 | << "\r\n"; 17 | s << "Host: 127.0.0.1" 18 | << "\r\n"; 19 | s << "Connection: close" 20 | << "\r\n"; 21 | s << "\r\n"; 22 | conn.write(s.str()); 23 | }); 24 | conn.setOnDisconnectCallback([]() { 25 | cout << "on_disconnect" << endl; 26 | }); 27 | conn.setReadCallback([](char *buf, size_t len) { 28 | string data(buf, len); 29 | // cout << "< size:" << len << endl; 30 | cout << data << endl; 31 | }); 32 | conn.connect(); 33 | uv_run(loop, UV_RUN_DEFAULT); 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/ListenerHolder.cs: -------------------------------------------------------------------------------- 1 | // yuzhaohui 2 | // 2016/7/15 3 | 4 | using System; 5 | using Qunar.TC.Qmq.Client.Consumer; 6 | using Qunar.TC.Qmq.Client.tag; 7 | 8 | namespace Qunar.TC.Qmq.Client 9 | { 10 | internal interface ListenerHolder 11 | { 12 | void Listen(ExtraListenerConfig config); 13 | 14 | void Stop(); 15 | } 16 | 17 | internal class ExtraListenerConfig 18 | { 19 | public ExtraListenerConfig(ConsumeMode mode, int pullBatchSize, TimeSpan pullBatchTimeout, TagType tagType, string[] tags) 20 | { 21 | Mode = mode; 22 | PullBatchSize = pullBatchSize; 23 | PullBatchTimeout = pullBatchTimeout; 24 | TagType = tagType; 25 | Tags = tags; 26 | } 27 | 28 | public ConsumeMode Mode { get; } 29 | 30 | public int PullBatchSize { get; } 31 | 32 | public TimeSpan PullBatchTimeout { get; } 33 | 34 | public TagType TagType { get; } 35 | 36 | public string[] Tags { get; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /qmq-backup/src/main/java/qunar/tc/qmq/backup/base/UnsupportedArgumentsException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.backup.base; 18 | 19 | /** 20 | * @author xufeng.deng dennisdxf@gmail.com 21 | * @since 2018-11-28 10:23 22 | */ 23 | public class UnsupportedArgumentsException extends QmqBackupException { 24 | public UnsupportedArgumentsException(String message) { 25 | super(message); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /qmq-backup/src/main/java/qunar/tc/qmq/backup/service/BatchBackup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.backup.service; 18 | 19 | import java.util.function.Consumer; 20 | 21 | /** 22 | * @author xufeng.deng dennisdxf@gmail.com 23 | * @since 2018-12-06 17:13 24 | */ 25 | public interface BatchBackup { 26 | void start(); 27 | 28 | void close(); 29 | 30 | void add(T t, Consumer consumer); 31 | } 32 | -------------------------------------------------------------------------------- /qmq-watchdog/src/main/java/qunar/tc/qmq/task/model/DataSourceInfoStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.task.model; 18 | 19 | /** 20 | * Created by IntelliJ IDEA. User: liuzz Date: 12-12-24 Time: 上午11:11 21 | */ 22 | public enum DataSourceInfoStatus { 23 | ONLINE(0), OFFLINE(-1); 24 | 25 | public int code; 26 | 27 | DataSourceInfoStatus(int code) { 28 | this.code = code; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Util/StateChangedArgs.cs: -------------------------------------------------------------------------------- 1 | // yuzhaohui 2 | // 8/1/2017 3 | using System; 4 | 5 | namespace Qunar.TC.Qmq.Client.Util 6 | { 7 | class StateChangedArgs : EventArgs 8 | { 9 | public static readonly StateChangedArgs Connected = new StateChangedArgs(State.Connected); 10 | 11 | public static readonly StateChangedArgs DisConnect = new StateChangedArgs(State.DisConnect); 12 | 13 | public static readonly StateChangedArgs Close = new StateChangedArgs(State.Close); 14 | 15 | public static readonly StateChangedArgs ConnectFailed = new StateChangedArgs(State.ConnectFailed); 16 | 17 | private readonly State state; 18 | 19 | public StateChangedArgs(State state) 20 | { 21 | this.state = state; 22 | } 23 | 24 | public State State 25 | { 26 | get { return this.state; } 27 | } 28 | } 29 | 30 | enum State 31 | { 32 | Connected, 33 | DisConnect, 34 | ConnectFailed, 35 | Close 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /qmq-server-common/src/main/java/qunar/tc/qmq/netty/ConnectionEventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.netty; 18 | 19 | import io.netty.channel.ChannelHandlerContext; 20 | 21 | /** 22 | * @author keli.wang 23 | * @since 2018/7/18 24 | */ 25 | public interface ConnectionEventHandler { 26 | void channelActive(ChannelHandlerContext ctx); 27 | 28 | void channelInactive(ChannelHandlerContext ctx); 29 | } 30 | -------------------------------------------------------------------------------- /qmq-watchdog/src/main/java/qunar/tc/qmq/task/database/DatasourceWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.task.database; 18 | 19 | import javax.sql.DataSource; 20 | 21 | /** 22 | * Created by zhaohui.yu 23 | * 12/6/16 24 | */ 25 | public interface DatasourceWrapper { 26 | DataSource datasource(); 27 | 28 | String select_sql(); 29 | 30 | String delete_sql(); 31 | 32 | String error_sql(); 33 | } 34 | -------------------------------------------------------------------------------- /qmq-client/src/main/java/qunar/tc/qmq/producer/RegistryResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.producer; 18 | 19 | import java.util.Set; 20 | 21 | /** 22 | * User: zhaohuiyu 23 | * Date: 10/28/14 24 | * Time: 2:30 PM 25 | */ 26 | public interface RegistryResolver { 27 | String resolve(); 28 | 29 | String resolve(String dataCenter); 30 | 31 | String dataCenter(); 32 | 33 | Set list(); 34 | } 35 | -------------------------------------------------------------------------------- /qmq-server/src/main/java/qunar/tc/qmq/utils/ConsumerGroupUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.utils; 18 | 19 | /** 20 | * @author yunfeng.yang 21 | * @since 2017/7/31 22 | */ 23 | public final class ConsumerGroupUtils { 24 | private ConsumerGroupUtils() { 25 | } 26 | 27 | public static String buildConsumerGroupKey(String subject, String group) { 28 | return subject + "-" + group; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Consumer/PullResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Qunar.TC.Qmq.Client.Consumer 5 | { 6 | internal class PullResult 7 | { 8 | private PullResult(bool success, List messages, Exception exception, string errorMessage) 9 | { 10 | Success = success; 11 | Messages = messages; 12 | Exception = exception; 13 | ErrorMessage = errorMessage; 14 | } 15 | 16 | public static PullResult Ok(List messages) 17 | { 18 | return new PullResult(true, messages, null, null); 19 | } 20 | 21 | public static PullResult Err(Exception exception, string errorMessage) 22 | { 23 | return new PullResult(false, null, exception, errorMessage); 24 | } 25 | 26 | public bool Success { get; } 27 | 28 | public List Messages { get; } 29 | 30 | public Exception Exception { get; } 31 | 32 | public string ErrorMessage { get; } 33 | } 34 | } -------------------------------------------------------------------------------- /qmq-delay-server/src/main/java/qunar/tc/qmq/delay/store/visitor/LogVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.delay.store.visitor; 18 | 19 | import java.util.Optional; 20 | 21 | /** 22 | * @author xufeng.deng dennisdxf@gmail.com 23 | * @since 2018-07-12 11:36 24 | */ 25 | public interface LogVisitor { 26 | 27 | Optional nextRecord(); 28 | 29 | long visitedBufferSize(); 30 | 31 | void close(); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /qmq-backup/src/main/java/qunar/tc/qmq/backup/store/RecordStore.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.backup.store; 18 | 19 | import qunar.tc.qmq.backup.base.RecordQuery; 20 | import qunar.tc.qmq.backup.base.RecordQueryResult; 21 | 22 | /** 23 | * @author xufeng.deng dennisdxf@gmail.com 24 | * @since 2019/5/29 25 | */ 26 | public interface RecordStore extends KvStore { 27 | RecordQueryResult findRecords(RecordQuery query); 28 | } 29 | -------------------------------------------------------------------------------- /qmq-common/src/main/java/qunar/tc/qmq/utils/ObjectUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.utils; 18 | 19 | /** 20 | * @author keli.wang 21 | * @since 2018-11-27 22 | */ 23 | public final class ObjectUtils { 24 | public static T defaultIfNull(T cond, T defaultValue) { 25 | if (cond == null) { 26 | return defaultValue; 27 | } else { 28 | return cond; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /qmq-delay-server/src/main/java/qunar/tc/qmq/delay/store/log/Log.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.delay.store.log; 18 | 19 | import qunar.tc.qmq.delay.store.model.AppendLogResult; 20 | 21 | /** 22 | * @author xufeng.deng dennisdxf@gmail.com 23 | * @since 2018-07-19 9:28 24 | */ 25 | public interface Log { 26 | AppendLogResult append(T record); 27 | 28 | boolean clean(Long key); 29 | 30 | void flush(); 31 | } 32 | -------------------------------------------------------------------------------- /qmq-backup/src/main/java/qunar/tc/qmq/backup/store/MessageStore.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.backup.store; 18 | 19 | import qunar.tc.qmq.backup.base.BackupQuery; 20 | import qunar.tc.qmq.backup.base.MessageQueryResult; 21 | 22 | /** 23 | * @author xufeng.deng dennisdxf@gmail.com 24 | * @since 2019/5/29 25 | */ 26 | public interface MessageStore extends KvStore { 27 | MessageQueryResult findMessages(BackupQuery query); 28 | } 29 | -------------------------------------------------------------------------------- /qmq-remoting/src/main/java/qunar/tc/qmq/netty/exception/EncodeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.netty.exception; 18 | 19 | /** 20 | * @author yiqun.fan create on 17-7-6. 21 | */ 22 | public class EncodeException extends Exception { 23 | 24 | public EncodeException(String s) { 25 | super(s); 26 | } 27 | 28 | public EncodeException(String s, Throwable cause) { 29 | super(s, cause); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /qmq-store/src/main/java/qunar/tc/qmq/store/GetMessageStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.store; 18 | 19 | /** 20 | * @author keli.wang 21 | * @since 2017/7/6 22 | */ 23 | public enum GetMessageStatus { 24 | SUCCESS, 25 | OFFSET_OVERFLOW, 26 | NO_MESSAGE, 27 | SUBJECT_NOT_FOUND, 28 | EMPTY_CONSUMER_LOG, 29 | 30 | 31 | SEQUENCE_TOO_SMALL, 32 | SEQUENCE_TOO_LARGE, 33 | TABLE_ALREADY_EVICTED, 34 | } 35 | -------------------------------------------------------------------------------- /qmq-delay-server/src/main/java/qunar/tc/qmq/delay/receiver/filter/Filter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.delay.receiver.filter; 18 | 19 | import qunar.tc.qmq.delay.base.ReceivedDelayMessage; 20 | import qunar.tc.qmq.delay.receiver.Invoker; 21 | 22 | /** 23 | * @author xufeng.deng dennisdxf@gmail.com 24 | * @since 2018-07-26 14:28 25 | */ 26 | public interface Filter { 27 | void invoke(Invoker invoker, ReceivedDelayMessage message); 28 | } 29 | -------------------------------------------------------------------------------- /qmq-delay-server/src/main/java/qunar/tc/qmq/delay/sender/DelayProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.delay.sender; 18 | 19 | import qunar.tc.qmq.common.Disposable; 20 | import qunar.tc.qmq.delay.ScheduleIndex; 21 | 22 | /** 23 | * @author xufeng.deng dennisdxf@gmail.com 24 | * @since 2018-08-07 13:24 25 | */ 26 | public interface DelayProcessor extends Disposable { 27 | void init(); 28 | 29 | void send(ScheduleIndex index); 30 | } 31 | -------------------------------------------------------------------------------- /qmq-delay-server/src/main/java/qunar/tc/qmq/delay/store/DelaySegmentValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.delay.store; 18 | 19 | import qunar.tc.qmq.delay.store.log.DelaySegment; 20 | 21 | import java.io.IOException; 22 | 23 | /** 24 | * @author xufeng.deng dennisdxf@gmail.com 25 | * @since 2018-07-19 13:18 26 | */ 27 | public interface DelaySegmentValidator { 28 | 29 | long validate(DelaySegment segment) throws IOException; 30 | } 31 | -------------------------------------------------------------------------------- /qmq-remoting/src/main/java/qunar/tc/qmq/netty/exception/BrokerRejectException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.netty.exception; 18 | 19 | import qunar.tc.qmq.service.exceptions.MessageException; 20 | 21 | /** 22 | * @author yiqun.fan create on 17-9-8. 23 | */ 24 | public class BrokerRejectException extends MessageException { 25 | 26 | public BrokerRejectException(String messageId) { 27 | super(messageId, "reject"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /qmq-sync/src/main/java/qunar/tc/qmq/sync/SyncType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.sync; 18 | 19 | /** 20 | * @author yunfeng.yang 21 | * @since 2017/8/18 22 | */ 23 | public enum SyncType { 24 | action(1), message(2), heartbeat(3), dispatch(4), index(5); 25 | 26 | private int code; 27 | 28 | SyncType(int code) { 29 | this.code = code; 30 | } 31 | 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /qmq-metaserver/src/main/java/qunar/tc/qmq/meta/utils/SubjectUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.meta.utils; 18 | 19 | import com.google.common.base.Objects; 20 | 21 | /** 22 | * @author keli.wang 23 | * @since 2018/7/30 24 | */ 25 | public final class SubjectUtils { 26 | private SubjectUtils() { 27 | } 28 | 29 | public static boolean isAnySubject(final String subject) { 30 | return Objects.equal(subject, "*"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /qmq-watchdog/src/main/java/qunar/tc/qmq/task/database/IDatabaseDriver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.task.database; 18 | 19 | /** 20 | * Created by IntelliJ IDEA. 21 | * User: liuzz 22 | * Date: 13-12-5 23 | * Time: 下午3:01 24 | */ 25 | public interface IDatabaseDriver { 26 | String protocol(); 27 | 28 | DatasourceWrapper makeDataSource(String url, String userName, String password); 29 | 30 | void close(DatasourceWrapper dataSource); 31 | } 32 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Model/ACKMessage.cs: -------------------------------------------------------------------------------- 1 | // yuzhaohui 2 | // 2016/7/19 3 | namespace Qunar.TC.Qmq.Client.Model 4 | { 5 | class ACKMessage 6 | { 7 | private readonly string messageID; 8 | private readonly string prefix; 9 | private readonly string group; 10 | private readonly long elapsed; 11 | private readonly string errorMessage; 12 | private long next; 13 | 14 | public ACKMessage(string messageID, string prefix, string group, long elapsed, string errorMessage, long next) 15 | { 16 | this.messageID = messageID; 17 | this.prefix = prefix; 18 | this.group = group; 19 | this.elapsed = elapsed; 20 | this.errorMessage = errorMessage; 21 | this.next = next; 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return "ACKMessage [messageID=" + this.messageID + ", prefix=" + this.prefix + ", group=" + this.group + ", elapsed=" + this.elapsed + ", errorMessage=" + this.errorMessage + "]"; 27 | } 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /qmq-metaserver/src/main/java/qunar/tc/qmq/meta/route/SubjectRouter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.meta.route; 18 | 19 | import qunar.tc.qmq.meta.BrokerGroup; 20 | import qunar.tc.qmq.protocol.consumer.MetaInfoRequest; 21 | 22 | import java.util.List; 23 | 24 | /** 25 | * @author keli.wang 26 | * @since 2017/12/4 27 | */ 28 | public interface SubjectRouter { 29 | List route(final String realSubject, final MetaInfoRequest request); 30 | } 31 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/NewQmq/MesssageAckPayloadHolder.cs: -------------------------------------------------------------------------------- 1 | using Qunar.TC.Qmq.Client.Codec; 2 | using Qunar.TC.Qmq.Client.Codec.NewQmq; 3 | using Qunar.TC.Qmq.Client.NewQmq.Model; 4 | using System.IO; 5 | 6 | namespace Qunar.TC.Qmq.Client.NewQmq 7 | { 8 | class MesssageAckPayloadHolder : PayloadHolder 9 | { 10 | private AckRequest request; 11 | 12 | public MesssageAckPayloadHolder(AckRequest request) 13 | { 14 | this.request = request; 15 | } 16 | 17 | public void Write(Stream output) 18 | { 19 | byte[] buffer = new byte[8]; 20 | ByteBufHelper.WriteString(request.Subject, buffer, output); 21 | ByteBufHelper.WriteString(request.Group, buffer, output); 22 | ByteBufHelper.WriteString(request.ConsumerId, buffer, output); 23 | ByteBufHelper.WriteInt64(request.PullOffsetBegin, buffer, output); 24 | ByteBufHelper.WriteInt64(request.PullOffsetEnd, buffer, output); 25 | ByteBufHelper.WriteByte((byte)(request.IsBroadcast ? 1 : 0), output); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/Util/FloatingParser.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Qunar.TC.Qmq.Client.Util 4 | { 5 | internal static class FloatingParser 6 | { 7 | public const string JavaPositiveInfinity = "Infinity"; 8 | public const string JavaNegativeInfinity = "-Infinity"; 9 | 10 | private static readonly HashSet Infinity = new HashSet { JavaPositiveInfinity, JavaNegativeInfinity }; 11 | 12 | public static float ParseFloat(string s) 13 | { 14 | if (!Infinity.Contains(s)) 15 | { 16 | return float.Parse(s); 17 | } 18 | 19 | return JavaPositiveInfinity.Equals(s) ? float.PositiveInfinity : float.NegativeInfinity; 20 | } 21 | 22 | public static double ParseDouble(string s) 23 | { 24 | if (!Infinity.Contains(s)) 25 | { 26 | return double.Parse(s); 27 | } 28 | 29 | return JavaPositiveInfinity.Equals(s) ? double.PositiveInfinity : double.NegativeInfinity; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /qmq-client/src/main/java/qunar/tc/qmq/consumer/pull/PushConsumer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.consumer.pull; 18 | 19 | import qunar.tc.qmq.BaseConsumer; 20 | 21 | import java.util.List; 22 | 23 | /** 24 | * @author yiqun.fan create on 17-9-12. 25 | */ 26 | interface PushConsumer extends BaseConsumer, AckHook { 27 | 28 | ConsumeParam consumeParam(); 29 | 30 | void push(List messages); 31 | 32 | boolean cleanLocalBuffer(); 33 | } 34 | -------------------------------------------------------------------------------- /qmq-server-common/src/main/java/qunar/tc/qmq/meta/BrokerRequestType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.meta; 18 | 19 | /** 20 | * @author yunfeng.yang 21 | * @since 2017/8/31 22 | */ 23 | public enum BrokerRequestType { 24 | ONLINE(0), HEARTBEAT(1), OFFLINE(2); 25 | 26 | private int code; 27 | 28 | BrokerRequestType(int code) { 29 | this.code = code; 30 | } 31 | 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /qmq-client/src/main/java/qunar/tc/qmq/producer/QueueSender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package qunar.tc.qmq.producer; 17 | 18 | 19 | import qunar.tc.qmq.ProduceMessage; 20 | 21 | /** 22 | * @author miao.yang susing@gmail.com 23 | * @date 2013-1-6 24 | */ 25 | public interface QueueSender { 26 | 27 | boolean offer(ProduceMessage pm); 28 | 29 | boolean offer(ProduceMessage pm, long millisecondWait); 30 | 31 | void send(ProduceMessage pm); 32 | 33 | void destroy(); 34 | } 35 | -------------------------------------------------------------------------------- /qmq-backup/src/main/java/qunar/tc/qmq/backup/base/QmqBackupException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.backup.base; 18 | 19 | /** 20 | * @author xufeng.deng dennisdxf@gmail.com 21 | * @since 2018-11-27 20:17 22 | */ 23 | public class QmqBackupException extends RuntimeException { 24 | public QmqBackupException(String message) { 25 | super(message); 26 | } 27 | 28 | public QmqBackupException(Throwable cause) { 29 | super(cause); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /qmq-backup/src/main/java/qunar/tc/qmq/backup/service/DicService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.backup.service; 18 | 19 | /** 20 | * @author yiqun.fan create on 17-10-31. 21 | */ 22 | public interface DicService { 23 | String SIX_DIGIT_FORMAT_PATTERN = "%06d"; 24 | 25 | String MAX_CONSUMER_GROUP_ID = "999999"; 26 | 27 | String MIN_CONSUMER_GROUP_ID = "000000"; 28 | 29 | String name2Id(String name); 30 | 31 | String id2Name(String id); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /qmq-client/src/main/java/qunar/tc/qmq/common/StatusSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.common; 18 | 19 | /** 20 | * Created by zhaohui.yu 21 | * 4/9/18 22 | */ 23 | public enum StatusSource { 24 | HEALTHCHECKER((byte) 1), 25 | OPS((byte) 2), 26 | CODE((byte) 4); 27 | 28 | private byte code; 29 | 30 | StatusSource(byte code) { 31 | this.code = code; 32 | } 33 | 34 | public int getCode() { 35 | return code; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /qmq-delay-server/src/main/java/qunar/tc/qmq/delay/store/model/RecordResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.delay.store.model; 18 | 19 | import qunar.tc.qmq.store.AppendMessageResult; 20 | import qunar.tc.qmq.store.PutMessageStatus; 21 | 22 | /** 23 | * @author xufeng.deng dennisdxf@gmail.com 24 | * @since 2018-07-19 10:44 25 | */ 26 | public interface RecordResult { 27 | 28 | PutMessageStatus getStatus(); 29 | 30 | AppendMessageResult getResult(); 31 | } 32 | -------------------------------------------------------------------------------- /qmq-store/src/main/java/qunar/tc/qmq/store/buffer/Buffer.java: -------------------------------------------------------------------------------- 1 | /* 2 | <<<<<<< HEAD 3 | * Copyright 2019 Qunar, Inc. 4 | ======= 5 | * Copyright 2018 Qunar, Inc. 6 | >>>>>>> origin/master 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | package qunar.tc.qmq.store.buffer; 22 | 23 | import java.nio.ByteBuffer; 24 | 25 | /** 26 | * @author keli.wang 27 | * @since 2019-06-10 28 | */ 29 | public interface Buffer { 30 | ByteBuffer getBuffer(); 31 | 32 | int getSize(); 33 | 34 | boolean retain(); 35 | 36 | boolean release(); 37 | } 38 | -------------------------------------------------------------------------------- /qmq-watchdog/src/main/java/qunar/tc/qmq/task/database/IDataSourceService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.task.database; 18 | 19 | import javax.sql.DataSource; 20 | 21 | /** 22 | * Created by IntelliJ IDEA. 23 | * User: liuzz 24 | * Date: 12-12-21 25 | * Time: 下午2:15 26 | */ 27 | public interface IDataSourceService { 28 | DataSource makeDataSource(String url, String driverClassName, String userName, String pwd); 29 | 30 | void close(DataSource dataSource); 31 | } 32 | -------------------------------------------------------------------------------- /qmq-backup/src/main/java/qunar/tc/qmq/backup/sync/LogSyncDispatcher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.backup.sync; 18 | 19 | import io.netty.buffer.ByteBuf; 20 | import qunar.tc.qmq.sync.SyncType; 21 | 22 | /** 23 | * @author xufeng.deng dennisdxf@gmail.com 24 | * @since 2018-11-27 16:58 25 | */ 26 | public interface LogSyncDispatcher { 27 | void dispatch(long startOffset, ByteBuf body); 28 | 29 | long getSyncLogOffset(); 30 | 31 | SyncType getSyncType(); 32 | } 33 | -------------------------------------------------------------------------------- /qmq-client/src/main/java/qunar/tc/qmq/consumer/pull/PushConsumerParam.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.consumer.pull; 2 | 3 | import qunar.tc.qmq.consumer.register.RegistParam; 4 | 5 | /** 6 | * TODO completion javadoc. 7 | * 8 | * @author xiao.liang 9 | * @since 14 January 2020 10 | */ 11 | public class PushConsumerParam { 12 | 13 | private String subject; 14 | private String group; 15 | private RegistParam registParam; 16 | 17 | public PushConsumerParam(String subject, String group, RegistParam registParam) { 18 | this.subject = subject; 19 | this.group = group; 20 | this.registParam = registParam; 21 | } 22 | 23 | public String getSubject() { 24 | return subject; 25 | } 26 | 27 | public void setSubject(String subject) { 28 | this.subject = subject; 29 | } 30 | 31 | public String getGroup() { 32 | return group; 33 | } 34 | 35 | public void setGroup(String group) { 36 | this.group = group; 37 | } 38 | 39 | public RegistParam getRegistParam() { 40 | return registParam; 41 | } 42 | 43 | public void setRegistParam(RegistParam registParam) { 44 | this.registParam = registParam; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /qmq-client/src/main/java/qunar/tc/qmq/consumer/register/ConsumerRegister.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.consumer.register; 18 | 19 | /** 20 | * User: zhaohuiyu 21 | * Date: 6/5/13 22 | * Time: 10:59 AM 23 | */ 24 | public interface ConsumerRegister { 25 | 26 | void regist(String prefix, String group, RegistParam param); 27 | 28 | void unregist(String prefix, String group); 29 | 30 | void setAutoOnline(boolean autoOnline); 31 | 32 | void destroy(); 33 | } 34 | -------------------------------------------------------------------------------- /qmq-api/src/main/java/qunar/tc/qmq/TransactionListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package qunar.tc.qmq; 17 | 18 | /** 19 | * Created by zhaohui.yu 20 | * 10/29/16 21 | */ 22 | public interface TransactionListener { 23 | 24 | void beginTransaction(MessageStore store); 25 | 26 | void addMessage(ProduceMessage message); 27 | 28 | void beforeCommit(); 29 | 30 | void afterCommit(); 31 | 32 | void afterCompletion(); 33 | 34 | void suspend(); 35 | 36 | void resume(); 37 | } 38 | -------------------------------------------------------------------------------- /qmq-common/src/main/java/qunar/tc/qmq/service/exceptions/BlockMessageException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.service.exceptions; 18 | 19 | /** 20 | * User: zhaohuiyu 21 | * Date: 12/25/12 22 | * Time: 12:30 PM 23 | */ 24 | public class BlockMessageException extends MessageException { 25 | private static final long serialVersionUID = 1068741830127606624L; 26 | 27 | public BlockMessageException(String messageId) { 28 | super(messageId, "block message"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /qmq-delay-server/src/main/java/qunar/tc/qmq/delay/container/Bootstrap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.delay.container; 18 | 19 | import qunar.tc.qmq.delay.startup.ServerWrapper; 20 | 21 | public class Bootstrap { 22 | public static void main(String[] args) { 23 | ServerWrapper wrapper = new ServerWrapper(); 24 | Runtime.getRuntime().addShutdownHook(new Thread(() -> { 25 | wrapper.destroy(); 26 | })); 27 | wrapper.start(true); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /qmq-delay-server/src/main/java/qunar/tc/qmq/delay/store/appender/LogAppender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.delay.store.appender; 18 | 19 | 20 | import qunar.tc.qmq.delay.store.model.AppendRecordResult; 21 | 22 | /** 23 | * @author xufeng.deng dennisdxf@gmail.com 24 | * @since 2018-07-13 17:34 25 | */ 26 | public interface LogAppender { 27 | 28 | AppendRecordResult appendLog(final T log); 29 | 30 | void lockAppender(); 31 | 32 | void unlockAppender(); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /qmq-metaserver/src/main/java/qunar/tc/qmq/meta/model/ClientSubjectInfo.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.meta.model; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * @description: 7 | * @author :zhixin.zhang 8 | * @date :Created in 下午7:39 2022/2/9 9 | */ 10 | public class ClientSubjectInfo implements Serializable { 11 | 12 | 13 | private static final long serialVersionUID = -8757348822377575171L; 14 | 15 | private String clientId; 16 | private String subject; 17 | 18 | public ClientSubjectInfo() { 19 | } 20 | 21 | public ClientSubjectInfo(String clientId, String subject) { 22 | this.clientId = clientId; 23 | this.subject = subject; 24 | } 25 | 26 | public static ClientSubjectInfo of(String clientId, String subject) { 27 | return new ClientSubjectInfo(clientId, subject); 28 | } 29 | 30 | public String getClientId() { 31 | return clientId; 32 | } 33 | 34 | public void setClientId(String clientId) { 35 | this.clientId = clientId; 36 | } 37 | 38 | public String getSubject() { 39 | return subject; 40 | } 41 | 42 | public void setSubject(String subject) { 43 | this.subject = subject; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /qmq-metaserver/src/main/java/qunar/tc/qmq/meta/spi/ClientRegisterAuthFactory.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.meta.spi; 2 | 3 | import java.util.ServiceLoader; 4 | 5 | import qunar.tc.qmq.meta.spi.impl.DefaultClientRegisterAuthService; 6 | import qunar.tc.qmq.meta.spi.pojo.ClientRegisterAuthInfo; 7 | 8 | 9 | /** 10 | * 11 | * @author xiao.liang 12 | * @since 27 December 2019 13 | */ 14 | public class ClientRegisterAuthFactory { 15 | 16 | private static ClientRegisterAuthService INSTANCE; 17 | 18 | static { 19 | ServiceLoader services = ServiceLoader.load(ClientRegisterAuthService.class); 20 | ClientRegisterAuthService instance = null; 21 | for (ClientRegisterAuthService registry : services) { 22 | instance = registry; 23 | break; 24 | } 25 | if (instance == null) { 26 | instance = new DefaultClientRegisterAuthService(); 27 | } 28 | 29 | INSTANCE = instance; 30 | } 31 | 32 | public static boolean auth(ClientRegisterAuthInfo authInfo) { 33 | return INSTANCE.auth(authInfo); 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /qmq-server/src/main/java/qunar/tc/qmq/store/PullMessageFilter.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.store; 2 | 3 | import java.util.List; 4 | import java.util.Objects; 5 | import qunar.tc.qmq.configuration.DynamicConfig; 6 | import qunar.tc.qmq.protocol.consumer.PullFilter; 7 | import qunar.tc.qmq.protocol.consumer.PullFilterType; 8 | import qunar.tc.qmq.protocol.consumer.PullRequest; 9 | import qunar.tc.qmq.store.buffer.Buffer; 10 | 11 | /** 12 | * @author zhenwei.liu 13 | * @since 2019-08-01 14 | */ 15 | public interface PullMessageFilter { 16 | 17 | boolean isActive(PullRequest request, Buffer message); 18 | 19 | boolean match(PullRequest request, Buffer message); 20 | 21 | void init(DynamicConfig config); 22 | 23 | @SuppressWarnings("unchecked") 24 | default T getFilter(PullRequest request, PullFilterType type) { 25 | List filterSwitches = request.getFilters(); 26 | if (filterSwitches == null) { 27 | return null; 28 | } 29 | for (PullFilter filterSwitch : filterSwitches) { 30 | if (Objects.equals(type, filterSwitch.type())) { 31 | return (T) filterSwitch; 32 | } 33 | } 34 | return null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /qmq-metaserver/src/main/java/qunar/tc/qmq/meta/exception/ServiceNotOfRequiredTypeException.java: -------------------------------------------------------------------------------- 1 | package qunar.tc.qmq.meta.exception; 2 | 3 | import org.springframework.util.ClassUtils; 4 | 5 | /** 6 | * @description: 7 | * @author :zhixin.zhang 8 | * @date :Created in 下午9:13 2021/12/30 9 | */ 10 | public class ServiceNotOfRequiredTypeException extends MetaException{ 11 | private String beanName; 12 | private Class requiredType; 13 | private Class actualType; 14 | 15 | public ServiceNotOfRequiredTypeException(String name, Class requiredType, Class actualType) { 16 | super("Service named '" + name + "' is expected to be of type '" + ClassUtils.getQualifiedName(requiredType) + "' but was actually of type '" + ClassUtils.getQualifiedName(actualType) + "'"); 17 | this.beanName = name; 18 | this.requiredType = requiredType; 19 | this.actualType = actualType; 20 | } 21 | 22 | public String getBeanName() { 23 | return this.beanName; 24 | } 25 | 26 | public Class getRequiredType() { 27 | return this.requiredType; 28 | } 29 | 30 | public Class getActualType() { 31 | return this.actualType; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /qmq-server-common/src/main/java/qunar/tc/qmq/meta/BrokerRegisterResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Qunar, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package qunar.tc.qmq.meta; 18 | 19 | import java.util.List; 20 | 21 | /** 22 | * @author yunfeng.yang 23 | * @since 2017/9/1 24 | */ 25 | public class BrokerRegisterResponse { 26 | private List subjects; 27 | 28 | public List getSubjects() { 29 | return subjects; 30 | } 31 | 32 | public void setSubjects(List subjects) { 33 | this.subjects = subjects; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /clients/csharp/qmqclient/NewQmq/Model/BrokerGroupInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Qunar.TC.Qmq.Client.NewQmq.Model 5 | { 6 | public class BrokerGroupInfo 7 | { 8 | private int groupIndex; 9 | private String groupName; 10 | private string master; 11 | private List slaves; 12 | private volatile bool available = true; 13 | 14 | public BrokerGroupInfo(int groupIndex, string groupName, string master, List slaves, bool available) 15 | { 16 | this.GroupIndex = groupIndex; 17 | this.GroupName = groupName; 18 | this.Master = master; 19 | this.Slaves = slaves; 20 | } 21 | 22 | public int GroupIndex { get => groupIndex; set => groupIndex = value; } 23 | public string GroupName { get => groupName; set => groupName = value; } 24 | public string Master { get => master; set => master = value; } 25 | public List Slaves { get => slaves; set => slaves = value; } 26 | public bool Available { get => available; set => available = value; } 27 | } 28 | } 29 | --------------------------------------------------------------------------------