Esper异步http adapter集成

2017-04-12  本文已影响0人  wpb

添加http adapter相关的jar包依赖

mkdir lib-io
cp httpcore-4.0.1.jar lib-io/
cp httpcore-nio-4.0.1.jar lib-io/
cp httpclient-4.0.1.jar lib-io/
## 添加如下依赖
LIB_IO=$BASEDIR/lib-io
# Esper io
#
CLASSPATH=$CLASSPATH:$LIB/esperio-http-6.0.1.jar
CLASSPATH=$CLASSPATH:$LIB_IO/httpcore-4.0.1.jar
CLASSPATH=$CLASSPATH:$LIB_IO/httpclient-4.0.1.jar
CLASSPATH=$CLASSPATH:$LIB_IO/httpcore-nio-4.0.1.jar
##可以试下
##CLASSPATH=$CLASSPATH:$LIB_IO/*

部署epl(2选1)

直接部署epl

module cn.wanda.tech.esper.quickstart;

@Name('Request')
create schema Request(uuid string,msg string);

@Name('Response')
create schema Response(uuid string,msg string);

@Name('Process')
On Request insert into Response select *;

@Name('Display')
select * from Response
cp echo.epl hotdeploy/

通过war包部署(方便统一管理依赖的各种udf等)

git clone https://git.oschina.net/wangpeibin/esper-job.git
mvn package
cp target/xxxxx.war hotdeploy/

配置输出

<plugin-loader name="EsperIOHTTPAdapter" class-name="com.espertech.esperio.http.EsperIOHTTPAdapterPlugin">
  <config-xml>
    <esperio-http-configuration>
      <!-- 输入 -->
      <service name="myservice" port="8079" nio="true"/>
      <get service="myservice" pattern="*"/>
      <!-- 输出 -->
      <request stream="Response" uri="http://127.0.0.1:8080/callback"/>
    </esperio-http-configuration>
  </config-xml>
</plugin-loader>
sh bin/esperee.sh stop
# 可能需要等一阵 等待完全退出
sh bin/esperee.sh start

接受http adapter的输出

@Controller
public class EventController {
    private static Logger log = LoggerFactory.getLogger(EventController.class);
    
    @ResponseBody
    @RequestMapping(value = "/callback", method = RequestMethod.GET)
    public void callback(HttpServletRequest request) {
        log.info("callback {} {}", request.getRequestURI(), request.getQueryString());
    }
}
mvn spring-boot:run

往http adapter 发送请求

wget http://127.0.0.1:8079/sendevent?stream=Request&msg=Joe

验证结果

上一篇下一篇

猜你喜欢

热点阅读