Tag Archives: Spring Batch

Spring Boot: Integration Platform Properties and Default Value


These are Spring Boot Integration properties that can be configured with any Spring Boot Application. These properties are already configured in Spring Boot with the given default value.

Note: In your application, You don’t need to add all these values in your application.proprties/application.yaml file. You just need to add only those values which you want to change/override.

See Also:

ActiveMQ Configuration Properties

Spring Boot load these properties in ActiveMQProperties class.

Name Default Value Description
spring.activemq.broker-url URL of the ActiveMQ broker.For Default instance `tcp://localhost:61616`
spring.activemq.in-memory true Required if the default broker URL should be in memory. Ignored if an explicit brokerspecified.
spring.activemq.password Login password of the broker.
spring.activemq.user Login user of the broker.
spring.activemq.packages.trust-all false Trust all packages.
spring.activemq.packages.trusted Comma-separated packages to trust use when not trusting all packages.
spring.activemq.pool.configuration.* See PooledConnectionFactory.
spring.activemq.pool.enabled false Set when PooledConnectionFactory need to create instead of a regular ConnectionFactory.
spring.activemq.pool.expiry-timeout 0 Connection expiration timeout.(millieconds)
spring.activemq.pool.idle-timeout 30000 Connection idle timeout. (millieconds)
spring.activemq.pool.max-connections 1 Maximum number of pooled connections.

ARTEMIS Configuration Properties

Spring Boot load these properties in ArtemisProperties class.

Name Default Value Description
spring.artemis.embedded.cluster-password Cluster password. Randomly generated on startup by default.
spring.artemis.embedded.data-directory Journal file directory. Not necessary if persistence is turned off.
spring.artemis.embedded.enabled true Enable embedded mode, In case Artemis server APIs are available.
spring.artemis.embedded.persistent false Enable persistent store.
spring.artemis.embedded.queues Comma-separated queues to create on startup.
spring.artemis.embedded.server-id Server id. By default, an auto-incremented counter is used.
spring.artemis.embedded.topics Comma-separated topics to create on startup.
spring.artemis.host localhost Artemis broker host.
spring.artemis.mode Artemis deployment mode, auto-detected by default.
spring.artemis.password Login password of the broker.
spring.artemis.port 61616 Artemis broker port.
spring.artemis.user Login user of the broker.

Spring Batch Configuration Properties

Spring Boot load these properties in BatchProperties class.

Name Default Value Description
spring.batch.initializer.enabled Create the required batch tables on startup if needed. Enabled automatically, if custom schema is configured or no custom table prefix is set.
spring.batch.job.enabled true Execute all Spring Batch jobs on context startup.
spring.batch.job.names Comma-separated job names to execute on startup. By default, all Jobs in the context are executed.
spring.batch.schema classpath:org/
springframework/batch
/core/schema
-@@platform@@.sql
SQL file path to use to initialize the database schema.
spring.batch.table-prefix Table prefix for all batch meta-data tables.

HornetQ Configuration Properties

Spring Boot load these properties in HornetQProperties class.

Name Default Value Description
spring.hornetq.embedded.cluster-password Cluster password. Randomly generated on startup by default.
spring.hornetq.embedded.data-directory Journal file directory. Not necessary if persistence is turned off.
spring.hornetq.embedded.enabled true Enable embedded mode In case HornetQ server APIs are available.
spring.hornetq.embedded.persistent false Enable persistent store.
spring.hornetq.embedded.queues Comma-separated queues to create on startup.
spring.hornetq.embedded.server-id Server id. By default, an auto-incremented counter is used.
spring.hornetq.embedded.topics Comma-separated topics to create on startup.
spring.hornetq.host localhost HornetQ broker host.
spring.hornetq.mode HornetQ deployment mode, auto-detected by default.
spring.hornetq.password Login password of the broker.
spring.hornetq.port 5445 HornetQ broker port.
spring.hornetq.user Login user of the broker.

JMS Configuration Properties

Spring Boot load these properties in JmsProperties class.

Name Default Value Description
spring.jms.jndi-name Connection factory JNDI name. When configured, take precedence from others connection factory auto-configurations.
spring.jms.listener.acknowledge-mode Acknowledge mode for conainer. By default, the listener transcted to automatic acknowledgment.
spring.jms.listener.auto-startup true Start the container automatically on startup.
spring.jms.listener.concurrency Minimum number of concurrent consumers.
spring.jms.listener.max-concurrency Maximum number of concurrent consumers.
spring.jms.pub-sub-domain false Specify if the default destination type is topic.

Rabbit Configuration Properties

Spring Boot load these properties in RabbitProperties class.

Name Default Value Description
spring.rabbitmq.addresses Comma-separated addresses to which the client should connect.
spring.rabbitmq.cache.channel.checkout-timeout Waiting time to obtain a channel In case cache size has been reached.(in Millisecond)
spring.rabbitmq.cache.channel.size Number of channels to retain in the cache.
spring.rabbitmq.cache.connection.mode CHANNEL Connection factory cache mode.
spring.rabbitmq.cache.connection.size Number of connections to cache.
spring.rabbitmq.connection-timeout Connection timeout, in milliseconds; zero for infinite.
spring.rabbitmq.dynamic true Create an AmqpAdmin bean.
spring.rabbitmq.host localhost RabbitMQ host.
spring.rabbitmq.listener.acknowledge-mode Acknowledge mode of container
spring.rabbitmq.listener.auto-startup true Start the container automatically on startup.
spring.rabbitmq.listener.concurrency Minimum number of consumers.
spring.rabbitmq.listener.default-requeue-rejected Default true. Set to requeue delivery failures.
spring.rabbitmq.listener.max-concurrency Maximum number of consumers.
spring.rabbitmq.listener.prefetch Number of messages handled in a single request. For good performance, It should be greater than or equal to the transaction size (if configured).
spring.rabbitmq.listener.retry.enabled false Whether or not publishing retries are enabled.
spring.rabbitmq.listener.retry.initial-interval 1000 Interval between the two subsquent attempt to deliver a message.
spring.rabbitmq.listener.retry.max-attempts 3 Maximum attempts to deliver a message.
spring.rabbitmq.listener.retry.max-interval 10000 Maximum interval between attempts.
spring.rabbitmq.listener.retry.multiplier 1.0 Muliplier apply on previous delivery retry interval.
spring.rabbitmq.listener.retry.stateless true Whether or not retry is stateless or stateful.
spring.rabbitmq.listener.transaction-size Number of messages processed in each transaction. For good performnace, it should be less than or equal to the prefetch count.
spring.rabbitmq.password Login to authenticate against the broker.
spring.rabbitmq.port 5672 RabbitMQ port.
spring.rabbitmq.publisher-confirms false Enable publisher confirms.
spring.rabbitmq.publisher-returns false Enable publisher returns.
spring.rabbitmq.requested-heartbeat Requested heartbeat timeout, in seconds; zero for none.
spring.rabbitmq.ssl.enabled false Enable SSL support.
spring.rabbitmq.ssl.key-store key store path that holds the SSL certificate.
spring.rabbitmq.ssl.key-store-password Password used to access the key store.
spring.rabbitmq.ssl.trust-store Trust store that holds SSL certificates.
spring.rabbitmq.ssl.trust-store-password Password used to access the trust store.
spring.rabbitmq.ssl.algorithm SSL algorithm to use. By default configure by the rabbit client library.
spring.rabbitmq.template.mandatory false Enable mandatory messages.
spring.rabbitmq.template.receive-timeout 0 Timeout for `receive()` methods.
spring.rabbitmq.template.reply-timeout 5000 Timeout for `sendAndReceive()` methods.
spring.rabbitmq.template.retry.enabled false Set to true, for enable retries in the `RabbitTemplate`.
spring.rabbitmq.template.retry.initial-interval 1000 Interval between two subsquent attempt to publish a message.
spring.rabbitmq.template.retry.max-attempts 3 Maximum attempts to publish a message.
spring.rabbitmq.template.retry.max-interval 10000 Maximum attempts to publish a message.
spring.rabbitmq.template.retry.multiplier 1.0 Multiplier apply on previous publishing retry interval.
spring.rabbitmq.username Login user to authenticate broker.
spring.rabbitmq.virtual-host Virtual host to while connecting to the broker.

References

https://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html

Spring Scheduling Annotations List


After Spring Boot, Spring enhanced with scheduling and Asynchronous annotations which added with methods along with some information about to execute it, and Spring takes care of rest.

These annotations are from the org.springframework.scheduling.annotation package. Below are most common annotations which we use at time of development:

See Also :

Spring Scheduling Annotations

@EnableAsync

@EnableAsync annotation enable asynchronous functionality in Spring. It must use with @Configuration.

@Configuration
@EnableAsync
class VehicleFactoryConfig {}

Now, that we enabled asynchronous calls, we can use @Async to define the methods supporting it.

@EnableScheduling

@EnableScheduling annotation enable scheduling in the application. We should always use it in conjunction with @Configuration:

@Configuration
@EnableScheduling
class VehicleFactoryConfig {}

Now we are enabled with Schedule, we can now run methods periodically with @Scheduled.

@Async

@Async apply on methods which we want to execute on a different thread, hence run them asynchronously.

@Async
void repairCar() {
    // ...
}

If we apply @Aynch annotation to a class, then all methods will be called asynchronously.

Note: Before applying @Async on method first we need to enabled the asynchronous calls for this annotation to work, with @EnableAsync or XML configuration.

@Scheduled

@Scheduled annotation use to execute a method periodically at fixed interval or by Cron like expressions.

For Example : The first execution of the task will be delayed by 5 seconds and then it will be executed normally at a fixed interval of 2 seconds.

@Scheduled(fixedRate = 2000 , initialDelay=5000)
void checkVehicle() {
    // ...
}

After Java 8 with repeating annotations feature, @Scheduled can mark multiple times on a method with different period or Cron expressions.

For Example : The first execution of the task will be delayed by 5 seconds and then it will be executed normally at a fixed interval of 2 seconds and cron expression will execute on Monday to Saturday on 12 PM.

@Scheduled(fixedRate = 2000)
@Scheduled(cron = "0 * * * * MON-SAT")
void checkVehicle() {
    // ...
}

Note:

  • Before applying @Scheduled on method first we need to enabled the scheduling calls by applying @EnableScheduling configuration. that the method annotated with @Scheduled should have a void return type.
  • The method having @Scheduled should have a void return type.

@Schedules

@Schedules annotation use to specify multiple @Scheduled rules.

@Schedules({
  @Scheduled(fixedRate = 2000),
  @Scheduled(cron = "0 * * * * MON-SAT")
})
void checkVehicle() {
    // ...
}

Note: Same feature can achieve  since Java 8 with repeating annotations as described above.