msa-api-regcovery

Lightweight RPC communication framework based on netty and protostuff.

License

License

GroupId

GroupId

com.github.microcmpt
ArtifactId

ArtifactId

msa-api-regcovery
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

msa-api-regcovery
Lightweight RPC communication framework based on netty and protostuff.
Project URL

Project URL

https://github.com/microcmpt/msa-api-regcovery
Source Code Management

Source Code Management

https://github.com/microcmpt/msa-rpc4j

Download msa-api-regcovery

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.microcmpt/msa-api-regcovery/ -->
<dependency>
    <groupId>com.github.microcmpt</groupId>
    <artifactId>msa-api-regcovery</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.microcmpt/msa-api-regcovery/
implementation 'com.github.microcmpt:msa-api-regcovery:1.0.2'
// https://jarcasting.com/artifacts/com.github.microcmpt/msa-api-regcovery/
implementation ("com.github.microcmpt:msa-api-regcovery:1.0.2")
'com.github.microcmpt:msa-api-regcovery:jar:1.0.2'
<dependency org="com.github.microcmpt" name="msa-api-regcovery" rev="1.0.2">
  <artifact name="msa-api-regcovery" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.microcmpt', module='msa-api-regcovery', version='1.0.2')
)
libraryDependencies += "com.github.microcmpt" % "msa-api-regcovery" % "1.0.2"
[com.github.microcmpt/msa-api-regcovery "1.0.2"]

Dependencies

compile (6)

Group / Artifact Type Version
org.codehaus.groovy : groovy-all jar 2.3.11
org.projectlombok : lombok jar 1.16.20
org.apache.zookeeper : zookeeper jar 3.4.10
com.101tec : zkclient jar 0.10
com.google.guava : guava jar 23.0
org.springframework : spring-context jar 4.3.7.RELEASE

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

msa-rpc4j

Build Status License

Introduction

msa-rpc4j是一款轻量级rpc nio通讯框架,底层通讯采用了netty nio通讯框架,rpc调用速度更快,序列化采用protostuff,序列化速度性能更优,为了保持高可用,采用zookeeper作为 服务注册中心,所以msa-rpc4j是一款具有高性能、高可用的通讯框架。

Quick Start

服务端
step1:引入msa-rpc4j-server

maven:

<dependency>
  <groupId>com.github.microcmpt</groupId>
  <artifactId>msa-rpc-server</artifactId>
  <version>1.0.1</version>
</dependency>

gradle:

compile group: 'com.github.microcmpt', name: 'msa-rpc-server', version: '1.0.1'
step2:定义一个服务端接口HelloRpc4jService
public interface HelloRpc4jService {
    /**
     * Hello string.
     *
     * @param str the str
     * @return the string
     */
    String hello(String str);
}
step3:实现服务端业务逻辑HelloRpc4jServiceImpl类
@RpcService(value = HelloRpc4jService.class)
public class HelloRpc4jServiceImpl implements HelloRpc4jService {
    /**
     * Hello string.
     *
     * @param str the str
     * @return the string
     */
    public String hello(String str) {
        return "Hello, " + str;
    }
}
消费端
step1:引入msa-rpc-client

maven:

<dependency>
  <groupId>com.github.microcmpt</groupId>
  <artifactId>msa-rpc-client</artifactId>
  <version>1.0.1</version>
</dependency>

gradle:

compile group: 'com.github.microcmpt', name: 'msa-rpc-client', version: '1.0.1'
step2:配置RpcClientFactory
ZkServiceDiscovery discovery = new ZkServiceDiscovery();
discovery.setZkAddress("localhost:2181");
RpcClient client = new RpcClient(discovery);
RpcClientFactory factory = new RpcClientFactory(new DefaultInvocationProxy(rpcClient));
step3:通过RpcClientFactory实例创建HelloRpc4jService代理类
HelloRpc4jService client = factory.newClient(HelloRpc4jService.class);
String resp = client.hello("rpc4j");
System.out.println("返回结果:" + resp);

Annotation

@RpcService

@RpcService用于标记该服务为暴露出去的API服务,服务端启动时自动注册到注册中心

com.github.microcmpt

microcmpt

Microservice architecture components.

Versions

Version
1.0.2
1.0.1
1.0.0