Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6184723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:35:09+00:00 2026-05-24T01:35:09+00:00

I have one spring batch application which can be run from command line. The

  • 0

I have one spring batch application which can be run from command line. The flow of the batch job is when it starts , it reads the message from queue and transform then and write to db. Now for this i am using JmsItemReader from spring batch and inside read() method I have my logic. Now question is there might be a chance that when this process start, there is no message exist on the queue, in this scenario I want to stop processing whole batch.

How can this be achieved in spring batch? Basically what happens when you use JmsItemReader, it continuously ping jms broker and to read message and then sleep for a period of time. Now if there is no message to process then why should we keep the batch process running and let it consume CPU. I want it to run again next day as per schedule.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:35:10+00:00Added an answer on May 24, 2026 at 1:35 am

    this behaviour comes from the default configuration for the jmstemplate which is provided by spring-jms

    default value for timeOut is indefinite

    private long receiveTimeout = RECEIVE_TIMEOUT_INDEFINITE_WAIT;
    

    with this value, messageconsumer.receive() will be used

    Receives the next message produced for this message consumer. This
    call blocks indefinitely
    until a message is produced or until this
    message consumer is closed.

    so you need to set a timeout value for the jmstemplate

    <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
         (...)
         <property name="receiveTimeout" value="someLongValueForMilliseconds" />
         (...)
    </bean>
    

    then receive(long timeOut) will be used

    This call blocks until a message arrives, the timeout expires, or this
    message consumer is closed. A timeout of zero never expires, and the
    call blocks indefinitely.

    if you use a value of -1 the call happens immediately

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background I have a Spring batch program that reads a file (example file I
I have a Spring application (Spring Batch not web application). In a test class,
I have a standalone testcase for spring batch to copy data form one table
With Spring, you can define an array property and have Spring inject one of
I wish someone can help me with this one. I have a Spring MVC
I have a function which parses one string into two strings. In C# I
I'm using .NET 3.5. I have two string arrays, which may share one or
Please help! Background info I have a WPF application which accesses a SQL Server
I am experienced with Spring, but new to Spring Batch. Now I have the
I have cells that look like this, one per line: Duffy,John: 'Heritage: Civilization and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.