123
This commit is contained in:
@@ -12,7 +12,8 @@ import java.util.concurrent.*;
|
||||
*/
|
||||
public class ExecutorConstant {
|
||||
|
||||
private final static int CPU_NUM = Runtime.getRuntime().availableProcessors();
|
||||
// private final static int CPU_NUM = Runtime.getRuntime().availableProcessors();
|
||||
private final static int CPU_NUM = 6;
|
||||
|
||||
public static Executor SYNC_EXECUTOR;
|
||||
|
||||
@@ -48,6 +49,10 @@ public class ExecutorConstant {
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(6 << 2);
|
||||
}
|
||||
|
||||
private static ThreadFactory init(String nameFormat){
|
||||
return new ThreadFactoryBuilder().setNameFormat(nameFormat).build();
|
||||
}
|
||||
|
||||
@@ -10,13 +10,14 @@ import org.springframework.context.annotation.Configuration;
|
||||
public class RabbitMqConfig {
|
||||
|
||||
//并发数量
|
||||
public static final int DEFAULT_CONCURRENT = Runtime.getRuntime().availableProcessors();
|
||||
// public static final int DEFAULT_CONCURRENT = Runtime.getRuntime().availableProcessors();
|
||||
public static final int DEFAULT_CONCURRENT = 6;
|
||||
|
||||
@Bean("customContainerFactory")
|
||||
public SimpleRabbitListenerContainerFactory containerFactory(SimpleRabbitListenerContainerFactoryConfigurer configurer,
|
||||
ConnectionFactory connectionFactory) {
|
||||
SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
|
||||
factory.setConcurrentConsumers(DEFAULT_CONCURRENT*2);
|
||||
factory.setConcurrentConsumers(DEFAULT_CONCURRENT);
|
||||
factory.setMaxConcurrentConsumers(DEFAULT_CONCURRENT*2);
|
||||
configurer.configure(factory, connectionFactory);
|
||||
return factory;
|
||||
|
||||
@@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -35,8 +36,8 @@ public class Agora {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
headers.set("Authorization", getAuthorizationHeader());
|
||||
HttpEntity httpEntity = new HttpEntity<>(headers);
|
||||
JSONObject jsonobject = RestTemplateUtil.restTemplate.getForObject(url,JSONObject.class,httpEntity);
|
||||
HttpEntity request = new HttpEntity<>(headers);
|
||||
JSONObject jsonobject = RestTemplateUtil.restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class).getBody();
|
||||
// "success":true,"data":{"channel_exist":true,"mode":2,"broadcasters":[1001,1025],"audience":[],"audience_total":0}}
|
||||
if(jsonobject == null){
|
||||
return Collections.emptyList();
|
||||
@@ -45,8 +46,25 @@ public class Agora {
|
||||
return jsonArray.toJavaList(String.class);
|
||||
}
|
||||
|
||||
|
||||
public void closeChannelByUser(Long roomId,Long uid){
|
||||
String url = "https://api.sd-rtn.com/dev/v1/kicking-rule";
|
||||
Map<String,Object> bodyData = new HashMap<>();
|
||||
bodyData.put("appid",agoraProperties.getAppId());
|
||||
bodyData.put("cname",roomId);
|
||||
bodyData.put("uid",uid);
|
||||
bodyData.put("time",0);
|
||||
bodyData.put("privileges", Collections.singletonList("join_channel"));
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
headers.set("Authorization", getAuthorizationHeader());
|
||||
HttpEntity httpEntity = new HttpEntity<>(bodyData, headers);
|
||||
JSONObject jsonObject = RestTemplateUtil.restTemplate.exchange(url,HttpMethod.POST, httpEntity, JSONObject.class).getBody();
|
||||
log.info("执行关闭房间号操作:roomId={},response={}",roomId, JSON.toJSONString(jsonObject));
|
||||
}
|
||||
|
||||
public void closeChannel(Long roomId){
|
||||
String url = "http://api.sd-rtn.com/dev/v1/kicking-rule";
|
||||
String url = "https://api.sd-rtn.com/dev/v1/kicking-rule";
|
||||
Map<String,Object> bodyData = new HashMap<>();
|
||||
bodyData.put("appid",agoraProperties.getAppId());
|
||||
bodyData.put("cname",roomId);
|
||||
@@ -56,7 +74,7 @@ public class Agora {
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
headers.set("Authorization", getAuthorizationHeader());
|
||||
HttpEntity httpEntity = new HttpEntity<>(bodyData, headers);
|
||||
JSONObject jsonObject = RestTemplateUtil.restTemplate.postForObject(url, httpEntity, JSONObject.class);
|
||||
JSONObject jsonObject = RestTemplateUtil.restTemplate.exchange(url,HttpMethod.POST, httpEntity, JSONObject.class).getBody();
|
||||
log.info("执行关闭房间号操作:roomId={},response={}",roomId, JSON.toJSONString(jsonObject));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user