我使用postgreSQL。这是我在 myBatisMapper 中的请求:
<select id="findByStatusAndIdentityAndPrvCode" parameterType="java.lang.String" resultMap="Request">
select
from req_tab
where status in ('I', 'D', 'Q')
and identity = #{identity}
and prv_code = #{prvCode}
limit 1 for update
</select>
Run Code Online (Sandbox Code Playgroud)
这是我的错误:
org.apache.ibatis.exceptions.PersistenceException:
Error querying database. Cause: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
The error may exist in ru/infogate/dao/mapper/ReqMapper.xml
The error may involve ru.infogate.dao.mapper.ReqMapper.findByStatusAndIdentityAndPrvCode
The error occurred while handling results
SQL: select from req_tab where status in ('I', 'D', 'Q') and identity = ? and prv_code = ? limit …
Run Code Online (Sandbox Code Playgroud) 这是我的豆子:
@Bean
public Queue igSmev3ListenerQueue() {
Map<String, Object> args = new HashMap<>();
args.put("x-dead-letter-exchange", rabbitIgSmev3DlxProperties.getExchangeName());
args.put("x-dead-letter-routing-key", rabbitIgSmev3DlxProperties.getRoutingKey());
return new Queue(rabbitIgSmev3ListenerProperties.getQueueName(), true, false, false, args);
}
@Bean
public Queue igSmev3DlxQueue() {
return new Queue(rabbitIgSmev3DlxProperties.getQueueName(), true, false, false);
}
Run Code Online (Sandbox Code Playgroud)
以下是 application.yml 设置:
listener:
vhost: /
exchangeName: igSmev3Listener
queueName: igSmev3-ListenerQueue
routingKey: igSmev3-Listener
dlx:
vhost: /
exchangeName: igSmev3Dlx
queueName: igSmev3-DlxQueue
routingKey: igSmev3-Dlx
Run Code Online (Sandbox Code Playgroud)
我目前的错误:
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'x-dead-letter-exchange' for queue 'igSmev3-ListenerQueue' in vhost '/': received none but …
Run Code Online (Sandbox Code Playgroud) 这是我的简单测试代码:
class Scratch {
public static void main(String[] args) {
try {
System.out.println("Line 1");
throw new RuntimeException();
} catch (RuntimeException e) {
e.printStackTrace();
} finally {
System.out.println("Line 2");
}
}
}
Run Code Online (Sandbox Code Playgroud)
运行后我会得到这个:
Line 1
Line 2
java.lang.RuntimeException
at Scratch.main(scratch_4.java:5)
Process finished with exit code 0
Run Code Online (Sandbox Code Playgroud)
我以为“finally”代码必须最后执行,但事实并非如此。是什么原因?