调整Http调用采用SWHttpClient插件
This commit is contained in:
parent
d19b0fe709
commit
5826dcdbe5
|
|
@ -155,6 +155,13 @@
|
|||
<artifactId>jdbc-plugin</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- -->
|
||||
<dependency>
|
||||
<groupId>com.ai.cloud</groupId>
|
||||
<artifactId>httpClient-plugin</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -37,14 +37,10 @@ public class AccountMaintainImpl implements IAccountMaintain {
|
|||
commonsHttpResult.setErrorCode("99999");
|
||||
commonsHttpResult.setMessage("Create account failed");
|
||||
} else {
|
||||
Map<String, String> headParameters = new HashMap<String, String>();
|
||||
headParameters.put("SkyWalking-TRACING-NAME", new RPCBuriedPointSender().beforeSend(Identification.newBuilder().
|
||||
spanType('W').viewPoint(MAIL_APPLICATION_DEPLOY_ADDRESS + SEND_MAIL_URL).build()).toString());
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
parameters.put("recipientAccount", accountInfo.getMail());
|
||||
String mailResult = HttpClientUtil.sendPostRequest(MAIL_APPLICATION_DEPLOY_ADDRESS + SEND_MAIL_URL,
|
||||
parameters, headParameters);
|
||||
new RPCBuriedPointSender().afterSend();
|
||||
parameters);
|
||||
|
||||
CommonsHttpResult commonsHttpResult1 = gson.fromJson(mailResult, CommonsHttpResult.class);
|
||||
if ("000000".equals(commonsHttpResult1.getErrorCode())) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.ai.cloud.skywalking.example.account.util;
|
||||
|
||||
import com.ai.cloud.skywalking.plugin.httpclient.SWTracingHttpClient;
|
||||
import com.ai.cloud.skywalking.plugin.spring.Tracing;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
|
@ -8,7 +9,6 @@ import org.apache.http.HttpResponse;
|
|||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
|
@ -24,17 +24,14 @@ public class HttpClientUtil {
|
|||
private static final Log logger = LogFactory.getLog(HttpClientUtil.class);
|
||||
|
||||
@Tracing
|
||||
public static String sendPostRequest(String url, Map<String, String> parametersMap, Map<String, String>
|
||||
headerParameter) throws IOException, URISyntaxException {
|
||||
HttpClient httpclient = new DefaultHttpClient();
|
||||
public static String sendPostRequest(String url, Map<String, String> parametersMap) throws IOException, URISyntaxException {
|
||||
HttpClient httpclient = new SWTracingHttpClient();
|
||||
HttpPost httpPost = new HttpPost(new URL(url).toURI());
|
||||
List formparams = new ArrayList();
|
||||
for (Map.Entry<String, String> entry : parametersMap.entrySet()) {
|
||||
formparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
for (Map.Entry<String, String> entry : headerParameter.entrySet()) {
|
||||
httpPost.setHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
httpPost.setEntity(new UrlEncodedFormEntity(formparams, "UTF-8"));
|
||||
HttpResponse response = httpclient.execute(httpPost);
|
||||
if (response.getStatusLine().getStatusCode() == 200) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue