我在XML中配置一个步骤,如下所示:
<batch:step id="slaveStep">
<batch:tasklet>
<batch:chunk
reader="reader"
processor="processor"
writer="writer"
commit-interval="10"
skip-limit="100000">
<batch:skippable-exception-classes>
<batch:include class="MyException"/>
</batch:skippable-exception-classes>
</batch:chunk>
</batch:tasklet>
</batch:step>
Run Code Online (Sandbox Code Playgroud)
在java配置中,我使用这样的StepBuilder:
@Bean
public StepBuilder stepBuilder(String stepName)
{
return new StepBuilder(stepName);
}
@Bean
Step slaveStep()
{
return stepBuilder("slaveStep")
.<Movie, Movie>chunk(10)
.reader(reader(new HashMap<>()))
.processor(processor())
.writer(writer())
.build();
}
Run Code Online (Sandbox Code Playgroud)
但我找不到配置可跳过的异常类的方法
使用消息驱动Bean时,在注释中硬编码接收消息的目标名称 @MessageDriven(mappedName = "someDestinationName")
有没有办法在运行时添加此信息?Bellow是Message Driven Bean类的示例.
package mdb.beans;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.Message;
import javax.jms.MessageListener;
@MessageDriven(mappedName = "someDestinationName", activationConfig =
{
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
})
public class MDBSample implements MessageListener
{
public MDBSample()
{
// constructor
}
@Override
public void onMessage(Message message)
{
// logic when message received
}
}
Run Code Online (Sandbox Code Playgroud) 使用定义属性时@ConfigurationProperties,可以定义特定字段的前缀而不是整个类吗?
例如,假设我们有一个Properties类
@ConfigurationProperties(prefix = "com.example")
public class MyProperties {
private String host;
private String port;
// Geters and setters...
}
Run Code Online (Sandbox Code Playgroud)
这会将字段host和绑定port到com.example.host和com.example.port。假设我要绑定port到com.example.something.port。完成此操作的方法是定义一个Inner类Something并在其中添加属性port。但是,如果我需要更多的前缀,它将变得很麻烦。我尝试添加@ConfigurationProperties设置器,因为注释的目标是ElementType.TYPE和ElementType.METHOD:
@ConfigurationProperties(prefix = "com.example.something.port")
public void setPort(int port) {...}
Run Code Online (Sandbox Code Playgroud)
但这最终没有用。除了通过内部类之外,还有另一种自定义前缀的方法吗?
在JMS文档中,我读到Message Driven Beans不支持CLIENT_ACKNOWLEDGE模式,仅DUPS_OK_ACKNOWLEDGE和AUTO_ACKNOWLEDGE.
据我所知,在AUTO_ACKNOWLEDGE模式下,当调用onMessage方法时,消息被确认(从目标中删除).我想要的是告诉我的经纪人在发生不良事件时不要从目的地(队列或主题)删除消息
必须有一些方法来做到这一点.无论如何,为什么CLIENT_ACKNOWLEDGEMessage Drven Beans不支持.
java ×4
annotations ×1
ejb-3.0 ×1
java-ee ×1
jms ×1
properties ×1
spring ×1
spring-batch ×1
spring-boot ×1