通过 rest 接口创建流定义的问题
Issue creating stream definitions via rest interface
我想确保自己在正确的轨道上。
我在尝试创建流时收到以下响应:
015-11-23T08:59:12-0800 1.3.0.RELEASE ERROR qtp1260026681-23 rest.RestControllerAdvice - Caught exception while handling a request
org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported
at org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.handleNoMatch(RequestMappingInfoHandlerMapping.java:204) ~[spring-webmvc-4.2.2.RELEASE.jar:4.2.2.RELEASE]
这是我的示例代码:
HttpEntity<String> requestEntity;
ResponseEntity<String> responseEntity;
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
map.add("name", "testStream");
map.add("definition", "file | log");
map.add("deploy", "true");
requestEntity = new HttpEntity<MultiValueMap>(map, headers);
String url = "http://localhost:9393/streams/definitions"
try
{
responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class);
body = responseEntity.getBody();
statusCode = responseEntity.getStatusCode();
}
catch (Exception e)
{
String test = e.getMessage();
}
这是 returns 的代码:异常是 java.util.regex.PatternSyntaxException:索引 0 附近的悬挂元字符“*”
*
^
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
def streamName = "TEST";
def url= "http://localhost:9393/streams/definitions";
String definition = "dod-file-source --dir='zxcv' --dir='([^\s]+(\.(?i)(tar))$)' | transform --script=dod.file.transform.groovy --variables='hotfolderId=1' > queue:StorageStream";
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>()
map.add("name", streamName)
map.add("definition", definition)
map.add("deploy", 'true')
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>(map, headers);
ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class);
String body = responseEntity.getBody();
HttpStatus statusCode = responseEntity.getStatusCode();
这是一个自定义源模块 dod-file-source 但它只是向文件源模块添加了一些附加功能
我只是 运行 您的代码(稍微修改过的版本)并且没有遇到任何问题...
HttpEntity<MultiValueMap<String, String>> requestEntity;
ResponseEntity<String> responseEntity;
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
map.add("name", "testStream");
map.add("definition", "time | log");
map.add("deploy", "true");
requestEntity = new HttpEntity<MultiValueMap<String, String>>(map, headers);
String url = "http://localhost:9393/streams/definitions";
try
{
responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class);
String body = responseEntity.getBody();
HttpStatus statusCode = responseEntity.getStatusCode();
}
catch (Exception e)
{
e.printStackTrace();
}
2015-11-23T13:00:44-0500 1.3.0.RELEASE INFO task-scheduler-1 sink.testStream - 2015-11-23 13:00:44
2015-11-23T13:00:45-0500 1.3.0.RELEASE INFO task-scheduler-1 sink.testStream - 2015-11-23 13:00:45
2015-11-23T13:00:46-0500 1.3.0.RELEASE INFO task-scheduler-1 sink.testStream - 2015-11-23 13:00:46
2015-11-23T13:00:47-0500 1.3.0.RELEASE INFO task-scheduler-1 sink.testStream - 2015-11-23 13:00:47
我想确保自己在正确的轨道上。
我在尝试创建流时收到以下响应:
015-11-23T08:59:12-0800 1.3.0.RELEASE ERROR qtp1260026681-23 rest.RestControllerAdvice - Caught exception while handling a request org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported at org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.handleNoMatch(RequestMappingInfoHandlerMapping.java:204) ~[spring-webmvc-4.2.2.RELEASE.jar:4.2.2.RELEASE]
这是我的示例代码:
HttpEntity<String> requestEntity;
ResponseEntity<String> responseEntity;
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
map.add("name", "testStream");
map.add("definition", "file | log");
map.add("deploy", "true");
requestEntity = new HttpEntity<MultiValueMap>(map, headers);
String url = "http://localhost:9393/streams/definitions"
try
{
responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class);
body = responseEntity.getBody();
statusCode = responseEntity.getStatusCode();
}
catch (Exception e)
{
String test = e.getMessage();
}
这是 returns 的代码:异常是 java.util.regex.PatternSyntaxException:索引 0 附近的悬挂元字符“*” * ^
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
def streamName = "TEST";
def url= "http://localhost:9393/streams/definitions";
String definition = "dod-file-source --dir='zxcv' --dir='([^\s]+(\.(?i)(tar))$)' | transform --script=dod.file.transform.groovy --variables='hotfolderId=1' > queue:StorageStream";
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>()
map.add("name", streamName)
map.add("definition", definition)
map.add("deploy", 'true')
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>(map, headers);
ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class);
String body = responseEntity.getBody();
HttpStatus statusCode = responseEntity.getStatusCode();
这是一个自定义源模块 dod-file-source 但它只是向文件源模块添加了一些附加功能
我只是 运行 您的代码(稍微修改过的版本)并且没有遇到任何问题...
HttpEntity<MultiValueMap<String, String>> requestEntity;
ResponseEntity<String> responseEntity;
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
map.add("name", "testStream");
map.add("definition", "time | log");
map.add("deploy", "true");
requestEntity = new HttpEntity<MultiValueMap<String, String>>(map, headers);
String url = "http://localhost:9393/streams/definitions";
try
{
responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class);
String body = responseEntity.getBody();
HttpStatus statusCode = responseEntity.getStatusCode();
}
catch (Exception e)
{
e.printStackTrace();
}
2015-11-23T13:00:44-0500 1.3.0.RELEASE INFO task-scheduler-1 sink.testStream - 2015-11-23 13:00:44
2015-11-23T13:00:45-0500 1.3.0.RELEASE INFO task-scheduler-1 sink.testStream - 2015-11-23 13:00:45
2015-11-23T13:00:46-0500 1.3.0.RELEASE INFO task-scheduler-1 sink.testStream - 2015-11-23 13:00:46
2015-11-23T13:00:47-0500 1.3.0.RELEASE INFO task-scheduler-1 sink.testStream - 2015-11-23 13:00:47