|
|
@@ -44,19 +44,20 @@ public class RestTaskInvoke implements ITaskInvoke {
|
|
|
|
|
|
@Override
|
|
|
public void invokeMethod(SysJob sysJob) throws TaskException {
|
|
|
- try {
|
|
|
- String executePath = sysJob.getExecutePath();
|
|
|
- String resolvedUrl = resolveUrl(executePath);
|
|
|
+ String executePath = sysJob.getExecutePath();
|
|
|
+ String resolvedUrl = resolveUrl(executePath);
|
|
|
|
|
|
- HttpRequest request = HttpUtil.createPost(resolvedUrl);
|
|
|
- addExtraHeaders(request, sysJob);
|
|
|
+ HttpRequest request = HttpUtil.createPost(resolvedUrl);
|
|
|
+ addExtraHeaders(request, sysJob);
|
|
|
|
|
|
- String methodParams = sysJob.getMethodParamsValue();
|
|
|
- if (StrUtil.isNotBlank(methodParams)) {
|
|
|
- Map<String, Object> formData = new HashMap<>();
|
|
|
- formData.put("params", methodParams);
|
|
|
- request.form(formData);
|
|
|
- }
|
|
|
+ String methodParams = sysJob.getMethodParamsValue();
|
|
|
+ if (StrUtil.isNotBlank(methodParams)) {
|
|
|
+ Map<String, Object> formData = new HashMap<>();
|
|
|
+ formData.put("params", methodParams);
|
|
|
+ request.form(formData);
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
HttpResponse response = request.execute();
|
|
|
int status = response.getStatus();
|
|
|
String body = response.body();
|
|
|
@@ -88,12 +89,10 @@ public class RestTaskInvoke implements ITaskInvoke {
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- // 提取服务名和路径,例如: http://hnqz-upms-biz/admin/schedule-task/xxx
|
|
|
String path = executePath.substring(7);
|
|
|
int slashIndex = path.indexOf('/');
|
|
|
-
|
|
|
if (slashIndex == -1) {
|
|
|
- return executePath;
|
|
|
+ slashIndex = executePath.length();
|
|
|
}
|
|
|
|
|
|
String serviceName = path.substring(0, slashIndex);
|
|
|
@@ -105,11 +104,9 @@ public class RestTaskInvoke implements ITaskInvoke {
|
|
|
return instance.getUri().toString() + servicePath;
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- log.warn("[QUARTZ] 服务名解析失败, 使用原路径: {}", executePath, e);
|
|
|
+ log.error("[QUARTZ] 服务名解析失败, 使用原路径: {}", executePath, e);
|
|
|
}
|
|
|
-
|
|
|
- // host:port 模式直接返回原路径
|
|
|
- return executePath;
|
|
|
+ throw new RuntimeException("[QUARTZ] 服务名解析失败:" + executePath);
|
|
|
}
|
|
|
|
|
|
/**
|