【问题标题】:springxd stream creation failed due to transform groovy script由于转换 groovy 脚本,springxd 流创建失败
【发布时间】:2016-01-11 13:54:25
【问题描述】:

[![在此处输入图像描述][1]][1]我想使用 springXD 创建流。根据流的基本定义,我有:

Source :  http

Transform script : I written one groovy script which I stored at 
/xd/modules/processor/script/transform.groovy            

Sink : cassandra

我想存储我从 http 发布到 cassandra 表的非结构化 json 数据。 我在单节点模式下运行 springXD,然后运行 ​​xd-shell。 对于流创建,我使用:

stream create --name test2 --definition "http --port=9000 | transform --   
script=insert_transform.groovy |cassandra --contactPoints=127.0.0.1 --
keyspace=db1 --ingestQuery='insert into table1 (emp_id,emp_name,amount,time)
values (?,?,?,?)'" –deploy

我收到消息: 创建并部署了新流“test2”

之后,当我通过 http 发布数据时,会出现以下错误:

500 INTERNAL_SERVER_ERROR

在xd-singlenode,出现如下错误日志:

Caused by: java.io.FileNotFoundException: class path resource [insert_transform.groovy] cannot be opened because it does not exist.

【问题讨论】:

  • 我认为/xd/modules/processor/script 应该是/xd/modules/processor/scripts(复数scripts)
  • 仍然遇到同样的错误。使用 springXD 1.3.0

标签: groovy cassandra spring-xd


【解决方案1】:

哪个版本的 Spring XD?我刚刚用 1.3.0.RELEASE 对其进行了测试,它运行良好......

xd:>stream create foo --definition "time | transform --script=test.groovy | log" --deploy

.

$ cat xd/modules/processor/scripts/test.groovy
'Time = ' + payload 

.

2016-01-11T09:45:19-0500 1.3.0.RELEASE INFO xdbus.foo.1-1 sink.foo - Time = 2016-01-11 09:45:19
2016-01-11T09:45:20-0500 1.3.0.RELEASE INFO xdbus.foo.1-1 sink.foo - Time = 2016-01-11 09:45:20
2016-01-11T09:45:21-0500 1.3.0.RELEASE INFO xdbus.foo.1-1 sink.foo - Time = 2016-01-11 09:45:21

【讨论】:

  • 我附上了一张错误日志的图片。我在本地系统上使用 springXD 1.3.0,将 xd 作为单节点运行。 OS- ubuntu14.04 lts 和 cassandra 也在我的虚拟机上的本地主机上运行。
  • 你试过我的简单(r)测试用例了吗?我刚刚注意到你说你把脚本放在/xd/...;它应该是<xd-install-dir>/spring-xd-1.3.0.RELEASE/xd/...,其中<xd-install-dir> 是您解压缩存档的位置。即$XD_HOME/xd/....
  • 我是springXD的新手,很抱歉,但我无法理解您的解释。先生,我按照以下步骤操作:- 1. 下载 springxd 1.3.0。
  • 当你下载 zip 文件时,你必须在某个地方解压它;假设/home/foo/spring-xd。解压后会有一个目录:/home/foo/spring-xd/spring-xd-1.3.0.RELEASE/。该目录有一个子目录xd,that 是您需要放置脚本的位置,位于xd/modules/processor/scripts/ 下。
  • 我也是这样做的。但仍然有错误。没有脚本,我也可以创建流并发布数据。流定义的手段 http|卡桑德拉它工作正常。但是使用 http|transformscript.groovy|cassandra 会出错。
猜你喜欢
  • 1970-01-01
  • 2021-02-18
  • 2011-05-19
  • 2010-09-20
  • 2017-12-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-14
相关资源
最近更新 更多