find tenant opt
This commit is contained in:
parent
ac2a871d7c
commit
abdad90455
@ -7,14 +7,14 @@
|
||||
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<withJansi>true</withJansi>
|
||||
<encoder>
|
||||
<pattern>%magenta(%d{"yyyy-MM-dd HH:mm:ss,SSS"}) [%thread] %highlight(%-5level) %cyan(%logger{15}) - %msg %n</pattern>
|
||||
<pattern>%magenta(%d{"yyyy-MM-dd HH:mm:ss,SSS"}) [%thread][%X{traceId}] %highlight(%-5level) %cyan(%logger{15}) - %msg %n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="File" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.dir}/${project.artifactId}.log</file>
|
||||
<encoder>
|
||||
<pattern>%d{"yyyy-MM-dd HH:mm:ss,SSS"} [%thread] %-5level %logger{15} %msg %n</pattern>
|
||||
<pattern>%d{"yyyy-MM-dd HH:mm:ss,SSS"} [%thread][%X{traceId}] %-5level %logger{15} %msg %n</pattern>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.dir}/%d{yyyy-MM, aux}/${project.artifactId}-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
|
@ -7,14 +7,14 @@
|
||||
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<withJansi>true</withJansi>
|
||||
<encoder>
|
||||
<pattern>%magenta(%d{"yyyy-MM-dd HH:mm:ss,SSS"}) [%thread] %highlight(%-5level) %cyan(%logger{15}) - %msg %n</pattern>
|
||||
<pattern>%magenta(%d{"yyyy-MM-dd HH:mm:ss,SSS"}) [%thread][%X{traceId}] %highlight(%-5level) %cyan(%logger{15}) - %msg %n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="File" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.dir}/${project.artifactId}.log</file>
|
||||
<encoder>
|
||||
<pattern>%d{"yyyy-MM-dd HH:mm:ss,SSS"} [%thread] %-5level %logger{15} %msg %n</pattern>
|
||||
<pattern>%d{"yyyy-MM-dd HH:mm:ss,SSS"} [%thread][%X{traceId}] %-5level %logger{15} %msg %n</pattern>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.dir}/%d{yyyy-MM, aux}/${project.artifactId}-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.pudonghot.yo.fsagent.listener;
|
||||
|
||||
import com.pudonghot.yo.util.LogMDC;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -27,6 +28,7 @@ public class AgentRegister {
|
||||
condition = "#root.args[0].getName() == 'CUSTOM'"
|
||||
+ " and #root.args[0].getSubclass() == 'sofia::register'")
|
||||
public void onAgentRegister(final Event event) {
|
||||
LogMDC.setTraceId();
|
||||
log.debug("On agent register event [{}].", event.getHeaders());
|
||||
|
||||
final String realm = event.getHeader("realm");
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.pudonghot.yo.fsagent.listener;
|
||||
|
||||
import com.pudonghot.yo.util.LogMDC;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -27,6 +28,7 @@ public class AgentUnregister {
|
||||
condition = "#root.args[0].getName() == 'CUSTOM'"
|
||||
+ " and #root.args[0].getSubclass() == 'sofia::unregister'")
|
||||
public void onAgentUnregister(final Event event) {
|
||||
LogMDC.setTraceId();
|
||||
log.debug("On agent unregister event [{}].", event.getHeaders());
|
||||
|
||||
final String realm = event.getHeader("realm");
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.pudonghot.yo.fsagent.listener;
|
||||
|
||||
import com.pudonghot.yo.util.LogMDC;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.springframework.util.Assert;
|
||||
@ -48,6 +49,7 @@ public class ApplicationStartup implements ApplicationListener<ApplicationReadyE
|
||||
@Async
|
||||
@Override
|
||||
public void onApplicationEvent(final ApplicationReadyEvent event) {
|
||||
LogMDC.setTraceId();
|
||||
log.info("Application ready, will start FreeSWITCH, connect FreeSWITCH ESL, online Dubbo, online FreeSWITCH node.");
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(appReadyWaitTime);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.pudonghot.yo.fsagent.listener;
|
||||
|
||||
import com.pudonghot.yo.util.LogMDC;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.pudonghot.yo.model.domain.Agent;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -32,6 +33,7 @@ public class CampaignCallEstablishedListener {
|
||||
@Async
|
||||
@EventListener(value = CampaignCallEstablishedEvent.class)
|
||||
public void onCampaignCallEstablished(final CampaignCallEstablishedEvent event) {
|
||||
LogMDC.setTraceId();
|
||||
final Agent agent = event.getAgent();
|
||||
final DataWrapper params = event.getParams();
|
||||
final String callUuid = params.getConnId();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.pudonghot.yo.fsagent.listener;
|
||||
|
||||
import com.pudonghot.yo.util.LogMDC;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.pudonghot.yo.service.CommonCallDataService;
|
||||
@ -26,6 +27,7 @@ public class CampaignChannelDestroy {
|
||||
condition = "#root.args[0].getName() == 'CHANNEL_DESTROY'" +
|
||||
" and #root.args[0].getDialType() == 'CAMPAIGN'")
|
||||
public void onCampaignChannelDestroy(final Event event) {
|
||||
LogMDC.setTraceId();
|
||||
log.debug("On campaign channel destroy event [{}].", event.getHeaders());
|
||||
|
||||
final Integer campaignId = event.getCampaignId();
|
||||
|
@ -2,6 +2,8 @@ package com.pudonghot.yo.fsagent.listener;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.pudonghot.yo.util.LogMDC;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.pudonghot.yo.model.domain.Agent;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -38,6 +40,7 @@ public class ChannelAnswer {
|
||||
@EventListener(value = Event.class,
|
||||
condition = "#root.args[0].getName() == 'CHANNEL_ANSWER'")
|
||||
public void onChannelAnswer(final Event event) {
|
||||
LogMDC.setTraceId();
|
||||
log.debug("On channel answer event [{}].", event.getHeaders());
|
||||
|
||||
final CallStrUtils.ChannelInfo channelInfo =
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.pudonghot.yo.fsagent.listener;
|
||||
|
||||
import com.pudonghot.yo.util.LogMDC;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.pudonghot.yo.fsagent.util.CallStrUtils;
|
||||
@ -27,6 +28,7 @@ public class ChannelCreate {
|
||||
@EventListener(value = Event.class,
|
||||
condition = "#root.args[0].getName() == 'CHANNEL_CREATE'")
|
||||
public void onChannelCreate(final Event event) {
|
||||
LogMDC.setTraceId();
|
||||
log.debug("On channel create event [{}].", event.getHeaders());
|
||||
|
||||
final CallStrUtils.ChannelInfo channelInfo = CallStrUtils.getChannelInfo(event);
|
||||
|
@ -2,6 +2,8 @@ package com.pudonghot.yo.fsagent.listener;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.pudonghot.yo.util.LogMDC;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.wacai.tigon.mybatis.Search;
|
||||
import com.pudonghot.yo.model.domain.Agent;
|
||||
@ -44,6 +46,7 @@ public class ChannelDestroy {
|
||||
@EventListener(value = Event.class,
|
||||
condition = "#root.args[0].getName() == 'CHANNEL_DESTROY'")
|
||||
public void onChannelDestroy(final Event event) {
|
||||
LogMDC.setTraceId();
|
||||
log.debug("On channel destroy event [{}].", event.getHeaders());
|
||||
|
||||
final String callUuid = event.getConnId();
|
||||
|
@ -2,6 +2,8 @@ package com.pudonghot.yo.fsagent.listener;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.pudonghot.yo.util.LogMDC;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.pudonghot.yo.model.domain.Agent;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -37,6 +39,7 @@ public class ChannelHangupComplete {
|
||||
@EventListener(value = Event.class,
|
||||
condition = "#root.args[0].getName() == 'CHANNEL_HANGUP_COMPLETE'")
|
||||
public void onChannelHangupComplete(final Event event) {
|
||||
LogMDC.setTraceId();
|
||||
log.debug("On channel hangup event [{}].", event.getHeaders());
|
||||
|
||||
if (!event.isHangupNormalClearing()) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.pudonghot.yo.fsagent.listener;
|
||||
|
||||
import com.pudonghot.yo.util.LogMDC;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.pudonghot.yo.model.domain.Agent;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -35,6 +36,7 @@ public class ChannelHangupCompleteInIVR {
|
||||
@EventListener(value = Event.class,
|
||||
condition = "#root.args[0].getName() == 'CHANNEL_HANGUP_COMPLETE'")
|
||||
public void onChannelHangupComplete(final Event event) {
|
||||
LogMDC.setTraceId();
|
||||
final String strAgentId =
|
||||
event.getHeader("variable_x_ivr_agent");
|
||||
|
||||
|
@ -2,6 +2,8 @@ package com.pudonghot.yo.fsagent.listener;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.pudonghot.yo.util.LogMDC;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.pudonghot.yo.model.domain.Agent;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -36,6 +38,7 @@ public class ChannelProgress {
|
||||
@EventListener(value = Event.class,
|
||||
condition = "#root.args[0].getName() == 'CHANNEL_PROGRESS'")
|
||||
public void onChannelProgress(final Event event) {
|
||||
LogMDC.setTraceId();
|
||||
log.debug("On channel progress event [{}].", event.getHeaders());
|
||||
|
||||
final String channelName = event.getChannelName();
|
||||
|
@ -1,9 +1,6 @@
|
||||
package com.pudonghot.yo.fsagent.service.dialplan.impl;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.pudonghot.yo.fsagent.service.dialplan.Suffix;
|
||||
import com.pudonghot.yo.service.CommonAgentService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
@ -14,7 +11,9 @@ import com.wacai.tigon.sequence.IdSequence;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.springframework.util.DigestUtils;
|
||||
import com.pudonghot.yo.fsagent.util.CallStrUtils;
|
||||
import com.pudonghot.yo.service.CommonAgentService;
|
||||
import com.pudonghot.yo.fsagent.service.dialplan.Call;
|
||||
import com.pudonghot.yo.fsagent.service.dialplan.Suffix;
|
||||
import org.freeswitch.esl.client.transport.model.DataWrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.pudonghot.yo.fsagent.service.dialplan.DialplanConfig;
|
||||
@ -66,7 +65,7 @@ public abstract class BaseDialplanService implements DialplanService {
|
||||
final Call call = new Call(data,
|
||||
channelInfo,
|
||||
data.getCallerDestinationNumber(),
|
||||
getTenant(params), callerAgent);
|
||||
getTenant(data), callerAgent);
|
||||
return find(call);
|
||||
}
|
||||
|
||||
@ -118,12 +117,14 @@ public abstract class BaseDialplanService implements DialplanService {
|
||||
return dialType.name().equals(call.getParams().getDialType());
|
||||
}
|
||||
|
||||
protected String getRealm(final Map<String, String> params) {
|
||||
return params.get("Caller-Context");
|
||||
}
|
||||
protected Tenant getTenant(final DataWrapper data) {
|
||||
final Integer tenantId = data.getTenantId();
|
||||
if (tenantId != null) {
|
||||
return tenantService.find(tenantId);
|
||||
}
|
||||
|
||||
protected Tenant getTenant(final Map<String, String> params) {
|
||||
return tenantService.find(new Search(Tenant.REALM, getRealm(params)));
|
||||
return tenantService.find(
|
||||
new Search(Tenant.REALM, data.getCallerContext()));
|
||||
}
|
||||
|
||||
protected void recFile(
|
||||
|
@ -5,6 +5,7 @@ import com.pudonghot.yo.model.domain.Agent;
|
||||
import com.pudonghot.yo.fs.model.domain.Channel;
|
||||
import org.freeswitch.esl.client.inbound.Client;
|
||||
import org.apache.dubbo.config.annotation.Service;
|
||||
import com.pudonghot.yo.service.CommonAgentService;
|
||||
import com.pudonghot.yo.fsagent.api.InnerHelpService;
|
||||
import com.pudonghot.yo.service.CommonChannelService;
|
||||
import com.pudonghot.yo.fsagent.service.dialplan.Suffix;
|
||||
@ -21,9 +22,10 @@ public class InnerHelpServiceImpl implements InnerHelpService {
|
||||
@Autowired
|
||||
private Client fsClient;
|
||||
@Autowired
|
||||
private CommonAgentService commonAgentService;
|
||||
@Autowired
|
||||
private CommonChannelService commonChannelService;
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@ -61,7 +63,7 @@ public class InnerHelpServiceImpl implements InnerHelpService {
|
||||
return;
|
||||
}
|
||||
|
||||
final String realm = agentChannel.getContext();
|
||||
final String realm = commonAgentService.getRealm(agent);
|
||||
|
||||
fsClient.api("uuid_dual_transfer",
|
||||
agentChannel.getUuid(),
|
||||
@ -83,7 +85,7 @@ public class InnerHelpServiceImpl implements InnerHelpService {
|
||||
return;
|
||||
}
|
||||
|
||||
final String realm = agentChannel.getContext();
|
||||
final String realm = commonAgentService.getRealm(agent);
|
||||
|
||||
fsClient.api("uuid_dual_transfer",
|
||||
agentChannel.getUuid(),
|
||||
|
@ -8,6 +8,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import com.pudonghot.yo.fs.model.domain.Channel;
|
||||
import org.freeswitch.esl.client.inbound.Client;
|
||||
import org.apache.dubbo.config.annotation.Service;
|
||||
import com.pudonghot.yo.service.CommonAgentService;
|
||||
import com.pudonghot.yo.service.CommonChannelService;
|
||||
import com.pudonghot.yo.service.CommonCallDataService;
|
||||
import com.pudonghot.yo.fsagent.api.IvrTransferService;
|
||||
@ -25,6 +26,8 @@ public class IvrTransferServiceImpl implements IvrTransferService {
|
||||
@Autowired
|
||||
private Client fsClient;
|
||||
@Autowired
|
||||
private CommonAgentService commonAgentService;
|
||||
@Autowired
|
||||
private CommonChannelService commonChannelService;
|
||||
@Autowired
|
||||
private CommonCallDataService commonCallDataService;
|
||||
@ -39,7 +42,7 @@ public class IvrTransferServiceImpl implements IvrTransferService {
|
||||
|
||||
final String agentId = String.valueOf(agent.getId());
|
||||
final Channel agentChannel = channels.getLeft();
|
||||
final String realm = agentChannel.getContext();
|
||||
final String realm = commonAgentService.getRealm(agent);
|
||||
|
||||
fsClient.api("uuid_setvar",
|
||||
channels.getRight().getUuid(),
|
||||
@ -69,7 +72,7 @@ public class IvrTransferServiceImpl implements IvrTransferService {
|
||||
onValidChannels(agent, channels -> {
|
||||
|
||||
final Channel agentChannel = channels.getLeft();
|
||||
final String realm = agentChannel.getContext();
|
||||
final String realm = commonAgentService.getRealm(agent);
|
||||
|
||||
fsClient.api("uuid_dual_transfer",
|
||||
agentChannel.getUuid(),
|
||||
|
@ -6,14 +6,14 @@
|
||||
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<withJansi>true</withJansi>
|
||||
<encoder>
|
||||
<pattern>%magenta(%d{"yyyy-MM-dd HH:mm:ss,SSS"}) [%thread] %highlight(%-5level) %cyan(%logger{15}) - %msg %n</pattern>
|
||||
<pattern>%magenta(%d{"yyyy-MM-dd HH:mm:ss,SSS"}) [%thread][%X{traceId}] %highlight(%-5level) %cyan(%logger{15}) - %msg %n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="File" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.dir}/${project.artifactId}.log</file>
|
||||
<encoder>
|
||||
<pattern>%d{"yyyy-MM-dd HH:mm:ss,SSS"} [%thread] %-5level %logger{15} %msg %n</pattern>
|
||||
<pattern>%d{"yyyy-MM-dd HH:mm:ss,SSS"} [%thread][%X{traceId}] %-5level %logger{15} %msg %n</pattern>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.dir}/%d{yyyy-MM, aux}/${project.artifactId}-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
|
@ -15,21 +15,10 @@ import lombok.experimental.FieldNameConstants;
|
||||
@Table("channels")
|
||||
@FieldNameConstants(prefix = "")
|
||||
public class Channel extends DomainModel<String> {
|
||||
private String context;
|
||||
private String uuid;
|
||||
private String callUuid;
|
||||
private Direction direction;
|
||||
private String name;
|
||||
private String presenceId;
|
||||
private Long createdEpoch;
|
||||
|
||||
/**
|
||||
* if channel is leg A
|
||||
* @return true if channel is leg A
|
||||
*/
|
||||
public boolean isLegA() {
|
||||
return uuid.equals(callUuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@ -56,9 +45,4 @@ public class Channel extends DomainModel<String> {
|
||||
throw new UnsupportedOperationException(
|
||||
"Channel has no primary value");
|
||||
}
|
||||
|
||||
public enum Direction {
|
||||
inbound,
|
||||
outbound
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,14 @@ import com.pudonghot.yo.model.domain.Agent;
|
||||
*/
|
||||
public interface CommonAgentService {
|
||||
|
||||
/**
|
||||
* get realm of agent
|
||||
*
|
||||
* @param agent agent
|
||||
* @return realm of agent
|
||||
*/
|
||||
String getRealm(Agent agent);
|
||||
|
||||
/**
|
||||
* lock idle agent of queue
|
||||
*
|
||||
|
@ -1,11 +1,10 @@
|
||||
package com.pudonghot.yo.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.pudonghot.yo.model.domain.Agent;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import com.pudonghot.yo.fs.model.domain.Channel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Donghuang
|
||||
* @date Jul 12, 2020 16:41:18
|
||||
@ -34,5 +33,5 @@ public interface CommonChannelService {
|
||||
* @param agent agent
|
||||
* @return channels of agent
|
||||
*/
|
||||
List<Channel> list(final Agent agent);
|
||||
List<Channel> list(Agent agent);
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ public class CommonAgentServiceImpl
|
||||
implements CommonAgentService {
|
||||
private final RLock AGENT_LOCK;
|
||||
|
||||
@Autowired
|
||||
private TenantMapper tenantMapper;
|
||||
@Autowired
|
||||
private CommonDelayScheduleService delayScheduleService;
|
||||
@Autowired
|
||||
@ -35,6 +37,13 @@ public class CommonAgentServiceImpl
|
||||
AGENT_LOCK = redisson.getLock("AGENT_LOCK");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getRealm(final Agent agent) {
|
||||
return tenantMapper.find(agent.getTenantId()).getRealm();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -4,9 +4,9 @@ import java.util.List;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import com.pudonghot.yo.model.domain.Agent;
|
||||
import com.pudonghot.yo.mapper.TenantMapper;
|
||||
import com.pudonghot.yo.fs.mapper.ChannelMapper;
|
||||
import com.pudonghot.yo.fs.model.domain.Channel;
|
||||
import com.pudonghot.yo.service.CommonAgentService;
|
||||
import com.pudonghot.yo.service.CommonChannelService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@ -19,7 +19,7 @@ public class CommonChannelServiceImpl implements CommonChannelService {
|
||||
@Autowired
|
||||
private ChannelMapper channelMapper;
|
||||
@Autowired
|
||||
private TenantMapper tenantMapper;
|
||||
private CommonAgentService commonAgentService;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@ -77,10 +77,6 @@ public class CommonChannelServiceImpl implements CommonChannelService {
|
||||
}
|
||||
|
||||
private String presenceId(final Agent agent) {
|
||||
return agent.getAgent() + "@" + getRealm(agent);
|
||||
}
|
||||
|
||||
private String getRealm(final Agent agent) {
|
||||
return tenantMapper.find(agent.getTenantId()).getRealm();
|
||||
return agent.getAgent() + "@" + commonAgentService.getRealm(agent);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.pudonghot.yo.util;
|
||||
|
||||
import org.slf4j.MDC;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Donghuang <br>
|
||||
@ -28,6 +29,16 @@ public class LogMDC {
|
||||
|
||||
/**
|
||||
* set trance id
|
||||
*/
|
||||
public static void setTraceId() {
|
||||
final UUID uuid = UUID.randomUUID();
|
||||
MDC.put(TRACE_ID, Long.toHexString(uuid.getMostSignificantBits())
|
||||
+ Long.toHexString(uuid.getLeastSignificantBits()));
|
||||
}
|
||||
|
||||
/**
|
||||
* set trance id
|
||||
*
|
||||
* @param traceId trance id
|
||||
*/
|
||||
public static void setTraceId(final String traceId) {
|
||||
|
@ -29,6 +29,10 @@
|
||||
<groupId>com.wacai.tigon</groupId>
|
||||
<artifactId>tigon-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pudonghot.yo</groupId>
|
||||
<artifactId>yo-util</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.pudonghot.yo.common.listener;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.pudonghot.yo.util.LogMDC;
|
||||
import javax.servlet.ServletRequestEvent;
|
||||
import javax.servlet.ServletRequestListener;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@ -18,6 +19,7 @@ public class RequestListener implements ServletRequestListener {
|
||||
*/
|
||||
@Override
|
||||
public void requestInitialized(final ServletRequestEvent sre) {
|
||||
LogMDC.setTraceId();
|
||||
sre.getServletRequest().setAttribute(metricsKey, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
|
@ -7,14 +7,14 @@
|
||||
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<withJansi>true</withJansi>
|
||||
<encoder>
|
||||
<pattern>%magenta(%d{"yyyy-MM-dd HH:mm:ss,SSS"}) [%thread] %highlight(%-5level) %cyan(%logger{15}) - %msg %n</pattern>
|
||||
<pattern>%magenta(%d{"yyyy-MM-dd HH:mm:ss,SSS"}) [%thread][%X{traceId}] %highlight(%-5level) %cyan(%logger{15}) - %msg %n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="File" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.dir}/${project.artifactId}.log</file>
|
||||
<encoder>
|
||||
<pattern>%d{"yyyy-MM-dd HH:mm:ss,SSS"} [%thread] %-5level %logger{15} %msg %n</pattern>
|
||||
<pattern>%d{"yyyy-MM-dd HH:mm:ss,SSS"} [%thread][%X{traceId}] %-5level %logger{15} %msg %n</pattern>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.dir}/%d{yyyy-MM, aux}/${project.artifactId}-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
|
@ -7,14 +7,14 @@
|
||||
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<withJansi>true</withJansi>
|
||||
<encoder>
|
||||
<pattern>%magenta(%d{"yyyy-MM-dd HH:mm:ss,SSS"}) [%thread] %highlight(%-5level) %cyan(%logger{15}) - %msg %n</pattern>
|
||||
<pattern>%magenta(%d{"yyyy-MM-dd HH:mm:ss,SSS"}) [%thread][%X{traceId}] %highlight(%-5level) %cyan(%logger{15}) - %msg %n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="File" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.dir}/${project.artifactId}.log</file>
|
||||
<encoder>
|
||||
<pattern>%d{"yyyy-MM-dd HH:mm:ss,SSS"} [%thread] %-5level %logger{15} %msg %n</pattern>
|
||||
<pattern>%d{"yyyy-MM-dd HH:mm:ss,SSS"} [%thread][%X{traceId}] %-5level %logger{15} %msg %n</pattern>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.dir}/%d{yyyy-MM, aux}/${project.artifactId}-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
|
Loading…
x
Reference in New Issue
Block a user