- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在多线程上下文中使用 TcpOutboundGateway 和 CachingClientConnectionFactory 时遇到虚假关联错误。
日志消息是:2015-05-26 14:50:38.406 错误 3320 --- [pool-2-thread-2] o.s.i.ip.tcp.TcpOutboundGateway:无法关联响应 - 没有待处理的回复
从单线程发送时没有出现错误,并且我已经测试了 2 台物理机 - Windows 7 和 Fedora 20。我使用的是 Spring boot
这会导致未收到响应的发送超时错误。
下面是我的简化代码:请注意,它并不总是产生错误 - 它是虚假的该代码使用了 TcpOutboundGateway 和 TcpInboundGateway,但在我的实际应用程序中,服务器是遗留(不是 Spring)Java 代码,因此我使用 CachingClientConnectionFactory 来增强性能
@Configuration
@ComponentScan
@EnableAutoConfiguration
public class Test {
//**************** Client **********************************************
@Bean
public MessageChannel replyChannel() {
return new DirectChannel();
}
@Bean
public MessageChannel sendChannel() {
MessageChannel directChannel = new DirectChannel();
return directChannel;
}
@Bean
AbstractClientConnectionFactory tcpNetClientConnectionFactory() {
AbstractClientConnectionFactory tcpNetClientConnectionFactory = new TcpNetClientConnectionFactory("localhost", 9003);
CachingClientConnectionFactory cachingClientConnectionFactory = new CachingClientConnectionFactory(tcpNetClientConnectionFactory, 4);
return cachingClientConnectionFactory;
}
@Bean
@ServiceActivator(inputChannel = "sendChannel")
TcpOutboundGateway tcpOutboundGateway() {
TcpOutboundGateway tcpOutboundGateway = new TcpOutboundGateway();
tcpOutboundGateway.setConnectionFactory(tcpNetClientConnectionFactory());
tcpOutboundGateway.setReplyChannel(replyChannel());
return tcpOutboundGateway;
}
//******************************************************************
//**************** Server **********************************************
@Bean
public MessageChannel receiveChannel() {
return new DirectChannel();
}
@Bean
TcpNetServerConnectionFactory tcpNetServerConnectionFactory() {
TcpNetServerConnectionFactory tcpNetServerConnectionFactory = new TcpNetServerConnectionFactory(9003);
tcpNetServerConnectionFactory.setSingleUse(false);
return tcpNetServerConnectionFactory;
}
@Bean
TcpInboundGateway tcpInboundGateway() {
TcpInboundGateway tcpInboundGateway = new TcpInboundGateway();
tcpInboundGateway.setConnectionFactory(tcpNetServerConnectionFactory());
tcpInboundGateway.setRequestChannel(receiveChannel());
return tcpInboundGateway;
}
//******************************************************************
@Bean
@Scope("prototype")
Worker worker() {
return new Worker();
}
public volatile static int lc = 4;
public volatile static int counter = lc;
public volatile static long totStartTime = 0;
public volatile static int messageCount = 0;
public static synchronized int incMessageCount(){
return ++messageCount;
}
public static void main(String args[]) {
//new LegaServer();
ConfigurableApplicationContext applicationContext = SpringApplication.run(Test.class, args);
totStartTime = System.currentTimeMillis();
for (int z = 0; z < lc; z++) {
new Thread((Worker) applicationContext.getBean("worker")).start();
}
try {
Thread.currentThread().sleep(20000);
} catch (InterruptedException e) {
e.printStackTrace();
}
applicationContext.stop();
}
}
@MessageEndpoint
class RequestHandler {
@ServiceActivator(inputChannel = "receiveChannel")
public String rxHandler(byte [] in) {
String s = new String(in);
System.out.println("rxHandler:"+s);
return "Blah blah " + s;
}
}
@MessageEndpoint
class ResponseHandler {
@ServiceActivator(inputChannel = "replyChannel")
public void replyHandler(byte [] in) {
System.out.println("replyHandler:"+new String(in));
}
}
class Worker implements Runnable {
@Autowired
@Qualifier("sendChannel")
MessageChannel dc;
@Override
public void run() {
Test.counter--;
int locMessageCount=0;
long startTime = System.currentTimeMillis();
for (int t = 0; t < 20; t++) {
locMessageCount = Test.incMessageCount();
Map hs = new HashMap<String, String>();
hs.put("context", new Integer(Test.counter));
GenericMessage message = new GenericMessage("this is a test message " + locMessageCount, hs);
try {
boolean sent = dc.send(message);
} catch (Exception e) {
//e.printStackTrace();
System.out.println("locMessageCount:"+locMessageCount);
}
}
if (locMessageCount == (Test.lc*20)) {
long totfinTime = System.currentTimeMillis();
System.out.println("Tot. Time taken: " + (totfinTime - Test.totStartTime));
System.out.println("Tot. TPS: " + (1000 * 20* Test.lc) / (totfinTime - Test.totStartTime));
System.out.println("Tot. messages: " + Test.messageCount);
}
}
}
任何建议以及我迄今为止收到的帮助都将不胜感激。 TY
最佳答案
谢谢;这是出站网关和缓存连接工厂组合的错误;请打开JIRA Issue .
问题在于,在第一个线程 (Thread-5) 删除挂起的回复之前,连接已添加回池中(并重用);他最终删除了新的待处理回复(对于线程 2)而不是他自己的。
不幸的是,我没有一个简单的解决方法可以供您使用;它需要在网关中更改代码来修复它。
关于java - 使用 TcpOutboundGateway 和 CachingClientConnectionFactory 出现虚假错误 "Cannot correlate response - no pending reply",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30459804/
在我的论坛中,我有话题和回复。 一个线程有多个回复。但是,回复可以是回复的回复(如 google wave)。因此,回复必须有一列“reply_id”,以便它可以指向父回复。但是,“顶级”回复(直接在
enter image description here 在调用中出现一个额外的参数“reply”:reply: { ( success, error) - 我能做什么,因为我无法在模拟器中构建应用程
我已将应用程序配置为在 Azure 门户上使用 Skype for Business Web SDK。我已在 AAD 上成功注册并完成了其他必要的步骤。 我在本地计算机上的默认 IIS 端口(即 80
当我运行部署到 Azure 应用服务的应用程序时,出现此错误 请求中指定的回复 URL 与为应用程序配置的回复 URL 不匹配。快把我逼疯。我不知道回复 URL 应该是什么。 最佳答案 当真实的red
我正在使用 msal 来验证用户身份。 我的userAgentApplication看起来像这样: var userAgentApplication = new UserAgentApplicatio
我试图找出我在 OAuth 流程中遇到的某个错误的原因(使用 login.microsoftonline.com 作为 IDP)以便访问页面。 错误是: AADSTS50011 (The reply
我想编写一个简单的代码示例,它将消息发送到交换器,使用监听器接收消息并发回消息。 这就是我发送消息的方式: private static void pingpong(Object messageLis
好的,我正在制作这个 Apple Watch 应用程序,在我的 Watch 应用程序中,我有一个按钮。当您触摸按钮时,它会执行以下操作: [WKInterfaceController openPare
我创建了一个 API 应用程序并将其部署到 Azure。该应用程序使用 Active Directory 身份验证。 我收到以下错误 AADSTS50011: The reply url specif
我正在用这个拔掉我的头发。 我的后端有一个 .Net Core 2.1 应用程序,前端有 Angular 7。 我已经完成了与 Azure Active Directory 集成并正常工作的所有困难工
我尝试按照 this tutorial 创建一个使用 Microsoft Graph API 的应用,但当我单击“使用 Microsoft 登录”按钮时收到以下错误: AADSTS50011: The
尝试让 Oauth2.0 在我的 Azure 空间中与 APIM 配合使用。 我已经导入并设置了 2.0 Open API 作为后端。我使用 APIM 开发人员门户作为客户端来调用此后端 API。我将
我正在遵循此说明:https://github.com/Azure-Samples/ms-identity-python-webapp之后,我收到以下错误: AADSTS50011:请求中指定的回复
我不断收到此错误: AADSTS50011: The reply URL specified in the request does not match the reply URLs configur
我正在尝试在 PowerApps 中创建自定义连接器,以便可以连接到我们的 Jira 服务器。 我正在尝试使用 OAuth 身份验证,但无法正确配置它。我得到这个: AADSTS50011: The
我正在遵循此说明:https://github.com/Azure-Samples/ms-identity-python-webapp之后,我收到以下错误: AADSTS50011:请求中指定的回复
我不断收到此错误: AADSTS50011: The reply URL specified in the request does not match the reply URLs configur
我正在尝试在 PowerApps 中创建自定义连接器,以便可以连接到我们的 Jira 服务器。 我正在尝试使用 OAuth 身份验证,但无法正确配置它。我得到这个: AADSTS50011: The
我关注了this用于设置 Microsoft Auth 系统的文档,但遇到错误 aadsts50011 ( here is azure portal URI )(here is my settings
我关注了this用于设置 Microsoft Auth 系统的文档,但遇到错误 aadsts50011 ( here is azure portal URI )(here is my settings
我是一名优秀的程序员,十分优秀!