Giter Site home page Giter Site logo

msgpack-rpc-jersey-blank's Introduction

msgpack-rpc-jersey-blank

Maven archetype to create a modern Java RPC stack using Jetty + Jersey + Jackson + MessagePack on Spring Boot

Build Status

How to use

with Bash

mvn archetype:generate\
 -DarchetypeGroupId=am.ik.archetype\
 -DarchetypeArtifactId=msgpack-rpc-jersey-blank-archetype\
 -DarchetypeVersion=1.0.7

with CommandPrompt (Windows)

mvn archetype:generate^
 -DarchetypeGroupId=am.ik.archetype^
 -DarchetypeArtifactId=msgpack-rpc-jersey-blank-archetype^
 -DarchetypeVersion=1.0.7

Example

Create a project

$ mvn archetype:generate -B\
  -DarchetypeGroupId=am.ik.archetype\
  -DarchetypeArtifactId=msgpack-rpc-jersey-blank-archetype\
  -DarchetypeVersion=1.0.7\
  -DgroupId=com.example\
  -DartifactId=hello-modern-rpc\
  -Dversion=1.0.0-SNAPSHOT
$ find . | sort | sed '1d;s,[^/]*/,|    ,g;s/..//;s/[^ ]*$/|-- &/'
   |-- hello-modern-rpc
   |    |-- pom.xml
   |    |-- src
   |    |    |-- main
   |    |    |    |-- java
   |    |    |    |    |-- com
   |    |    |    |    |    |-- example
   |    |    |    |    |    |    |-- App.java
   |    |    |    |    |    |    |-- AppConfig.java
   |    |    |    |    |    |    |-- CalcEndpoint.java
   |    |    |    |-- resources
   |    |    |    |    |-- application.yml
   |    |    |-- test
   |    |    |    |-- java
   |    |    |    |    |-- com
   |    |    |    |    |    |-- example
   |    |    |    |    |    |    |-- CalcEndpointTest.java
   |    |    |    |-- resources
   |    |    |    |    |-- .gitkeep
$ cd hello-modern-rpc

Run

$ mvn spring-boot:run
$ curl -v -H "Accept: application/x-msgpack" "localhost:8080/calc?left=100&right=300"
> GET /calc?left=100&right=300 HTTP/1.1
> User-Agent: curl/7.30.0
> Host: localhost:8080
> Accept: application/x-msgpack
>
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Content-Type: application/x-msgpack;charset=UTF-8
< Content-Length: 26
< Date: Fri, 16 Jan 2015 16:32:05 GMT
<
��leftd�right�,�answer��

Content negotiation is supported.

$ curl -v -H "Accept: application/json" "localhost:8080/calc?left=100&right=300"
> GET /calc?left=100&right=300 HTTP/1.1
> User-Agent: curl/7.30.0
> Host: localhost:8080
> Accept: application/json
>
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Content-Type: application/json;charset=UTF-8
< Content-Length: 37
< Date: Fri, 16 Jan 2015 16:32:52 GMT
<
{"left":100,"right":300,"answer":400}

You can change server port like as mvn spring-boot:run -Drun.arguments="--server.port=8888"

Test

$ mvn test

Build executable jar

$ mvn clean package
$ java -jar target/*.jar

Write your RPC

See a sample CalcEndpint

License

Licensed under the Apache License, Version 2.0.

msgpack-rpc-jersey-blank's People

Contributors

making avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.