第一次调用通常会成功,但随后我会收到如下消息:
io.grpc.StatusRuntimeException:DEADLINE_EXCEEDED:超出截止日期后开始 ClientCall:从现在开始-175.597476157s
为什么秒数是负数?我如何解决它?
我的 grpc 配置:
public class MyAppLibGrpcSenderConfig {
@Value("${grpc.client.host:localhost}")
private String host;
@Value("${grpc.client.port:9090}")
private int port;
@Value("${grpc.client.negotiationType:PLAINTEXT}")
private String negotiationType;
@Value("${grpc.client.deadline:300000}")
private long deadline;
@Autowired
private Tracer tracer;
@Bean
public ManagedChannel managedChannel() {
ManagedChannelBuilder<?> builder = ManagedChannelBuilder.forAddress(host, port);
if ("PLAINTEXT".equals(negotiationType)) {
builder.usePlaintext();
}
return builder.build();
}
@Bean
public TracingClientInterceptor tracingClientInterceptor(Tracer tracer) {
return TracingClientInterceptor
.newBuilder()
.withTracer(this.tracer)
.build();
}
@Bean
public MyAppSenderServiceGrpc.MyAppSenderServiceBlockingStub myAppSenderServiceBlockingStub(
TracingClientInterceptor tracingClientInterceptor,
ManagedChannel managedChannel) {
return MyAppSenderServiceGrpc
.newBlockingStub(tracingClientInterceptor.intercept(managedChannel))
.withDeadlineAfter(deadline, TimeUnit.MILLISECONDS);
}
@Bean
public MyAppCodeLoaderServiceGrpc.MyAppCodeLoaderServiceBlockingStub myAppCodeLoaderServiceBlockingStub( …Run Code Online (Sandbox Code Playgroud) 我想从 jmsTemplate.sendAndReceive 获取同步响应:
Message responseMessage = producer.produceAndReceive(gzip, mestype, uploadFile.getName(), uploadFile.getAbsolutePath());
Run Code Online (Sandbox Code Playgroud)
它在另一个类中调用 ProduceAndReceive :
@Override
public Message produceAndReceive(final byte[] data, final String type, final String name, final String archivePath) {
jmsTemplate.setReceiveTimeout(20000);
return jmsTemplate.sendAndReceive(SAPPI_EXPORT_QUEUE, new MessageCreator() {
@Override
public Message createMessage(Session session) throws JMSException {
String msgId = UUIDGen.getUUID();
BytesMessage message = session.createBytesMessage();
message.writeBytes(data);
message.setStringProperty(ISapProducer.IDOC_TYPE, type);
message.setStringProperty(ISapProducer.ORIGIN_FILE_NAME, name);
message.setStringProperty(ISapProducer.MESSAGE_ID, msgId);
message.setStringProperty(ISapProducer.ARCHIVE_PATH, archivePath);
message.setJMSReplyTo(session.createTemporaryQueue());
message.setJMSCorrelationID(msgId);
return message;
}
});
}
Run Code Online (Sandbox Code Playgroud)
在这一步之后,我认为该消息已经放入队列中。我有 @JmsListener 方法,可以“监听”这个队列:
@Override
@JmsListener(destination = "myqueue.export")
public void consume(final Message message) throws …Run Code Online (Sandbox Code Playgroud)