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 8180455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:13:06+00:00 2026-06-07T00:13:06+00:00

I have a standalone java application that fires up several JMS consumers using the

  • 0

I have a standalone java application that fires up several JMS consumers using the spring-jms tags in my spring config:

ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");

Here is what the bean definitions look like:

<bean id="fooConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="${foo_broker_url}" />
</bean>

<jms:listener-container connection-factory="fooConnectionFactory" acknowledge="client" client-id="fooService">
    <jms:listener destination="${foo_queue_name}" ref="fooListener" selector="${foo_selector}" />
</jms:listener-container>
...

I plan to write a Windows batch file to start up the consumer, and a separate batch file that will shut it down (for the moment I have been starting it up using the command line).

My problem is two-fold:
1. How would the shut-down batch file actually go about shutting down the connections?
2. If the startup batch file is executed while the queues are already connected, I don’t want the application to create a second connection. Any ideas how to prevent this?

Regarding question number 2: I understand that attempting to send a message to the queue and waiting for a response or failure might work, but it seems like overkill and there must be a better way. I read this in the API documentation for the javax.jms.Connection class:

“If another connection with the same clientID is already running when this method is called, the JMS provider should detect the duplicate ID and throw an InvalidClientIDException.”

However, specifying a clientID on the listener container (see bean definitions above) does not seem to prevent a second connection.

Update

I’ve determined that the easiest solution may be to run this application as a webapp under Tomcat. I will leave the question open, however, under the hopes that someone will provide a viable solution to either of the questions posed.

The first question could be rephrased/clarified as the following:
How would I terminate an application/thread that is running by executing a separate application/script?

The second question could be elaborated on by asking:
Is there a piece of data relating to the JMS producer connection to a queue that would make it unique? Based on this unique data could it be established that “this” connection already exists?

  • 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-06-07T00:13:06+00:00Added an answer on June 7, 2026 at 12:13 am

    I have determined that the easiest way to handle these problems is to convert my standalone to a webapp and deploy under Tomcat. This way I will be able to more easily manage starting/stopping the application, and I will be able to ensure that only one instance of the application is running at a given time.

    I’ll be monitoring this question going forward, so feel free to post your own solution and I would be willing to change the accepted answer to yours!

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

Sidebar

Related Questions

Let's say that you have a standalone application (a Java application in my case)
I have a standalone Java application that uses EclipseLink 2.0.1. It is configured by
I have standalone Java application ,in that i have various modules Application starts from
I have a standalone Java application below that is: Generating a random line Applied
I am developing a standalone application, in Java using NetBeans, that gets and sends
I have developed a standalone application using java, in which I am executing an
I have written a standalone Java application that I've packaged into a jar file
I have a standalone Java application that gets data from a database and displays
I have a Component which I am using both in a standalone Java application
I am using jboss5.1, EJB3.0 and standalone java application as a 'subscriber' I have

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.