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

  • Home
  • SEARCH
  • 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 8908589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:13:09+00:00 2026-06-15T03:13:09+00:00

I am having a java process called qoute running on linux server1 and server2

  • 0

I am having a java process called qoute running on linux server1 and server2 independantly.

This qoute process is used to creates a QuotingThread using Spring Rmi and in that thread update ‘quotableSet’ collection and PriorityBlockingQueue ‘addSymQ’ with a set of symbols.

<bean id="quotes-core" class="com.process.quotes.QuotesHandler" scope="singleton" init-method="init">
      <constructor-arg>
         <bean id="continuousQuotingThread" class="com.process.quotes.QuotingThread" scope="singleton" >
            <property name="futureTaskUtil" ref="futureTaskUtil" />
            <property name="continueToProcess" ref="continueToProcess" />
            <property name="addSymQ" ref="addSymQ" />
         </bean>
      </constructor-arg>
   </bean>

   <bean class="org.springframework.remoting.rmi.RmiServiceExporter">
      <property name="serviceName" value="Quotes-Core" />
      <property name="service" ref="quotes-core" />
      <property name="serviceInterface" value="com.remote.QuotesHandlerIF" />
      <property name="registryPort" value="${${quotes-processor-port}}" />
   </bean>

The QuotingThread updates the ‘quotableSet’ and ‘addSymQ’ based on the symbols from the QuotesClient which is configured this way.

<bean id="quotes" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
        <property name="serviceUrl" value="rmi://${${quotes-processor-host}}:${${quotes-processor-port}}/Quotes-Core" />
        <property name="serviceInterface" value="com.remote.QuotesHandlerIF" />
        <property name="refreshStubOnConnectFailure" value="true" />
        <property name="lookupStubOnStartup" value="false" />
</bean>

As 2 seperate QuotingThread’s are created by each quote process using Spring Rmi ,

For example, symbols a,b,c are added to ‘quotableSet’,’addSymQ’ by quote process1 and symbols e,f,g are added to ‘quotableSet’,’addSymQ’ by quote process2.

And addition is done this way.

QuotingThread:
--------------------------------
    public void addSymbols(String commaDelimSymbolsList) {
        if (null != commaDelimSymbolsList && commaDelimSymbolsList.length() > 0) {
            String[] symAr = commaDelimSymbolsList.split(",");
            for (int i = 0; i < symAr.length; i++) {
                    addSymQ.add(sec.getUniqueSymbol());             
            }
        }
    }

public void run() {

        while (continueToProcess.get()) {
            try {
                while (addSymQ.peek() != null) {
                    String symbol = addSymQ.poll();
                    quotableSet.add(symbol);                    
                    // some usage with quotable set                                         
                }
                Iterator<String> ite = quotableSet.iterator();
                while (ite.hasNext()) {
                    String symbol = ite.next();
                    if (symbol != null && symbol.trim().length() > 0) {
                        // some usage with quotable set 
                    }
                }
                Thread.sleep(2000);
            } catch (Exception e) {
                logger.error("Exception : ", e);
            }
        }
    }

‘quotableSet’ and ‘addSymQ’ is declared this way,

private Set<String> quotableSet = Collections.synchronizedSet(new HashSet<String>(Arrays.asList("DJ!DJI,NQ!COMP,CX!SPX,RU!RUT,CX!VIX,CX!TNX");




 private PriorityBlockingQueue<String> addSymQ;

What i need is symbols should be replicated on both thread’s ‘quotableSet’ and ‘addSymQ’ collections .

I mean symbols a,b,c,e,f,g should be added to both threads ‘quotableSet’ and ‘addSymQ’ collections equally.

So, that if one server goes down, second server can server the application..

can anyone help me on this issue?

  • 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-15T03:13:10+00:00Added an answer on June 15, 2026 at 3:13 am

    Let me see if I understand this correctly.

    You have two servers, each one running a single instance of the quote process. There are 2 threads in the quote process that service these collections. Now where I get confused is you say “should be replicated on both thread’s ‘quotableSet’ and ‘addSymQ’ collections” does that mean you want to have the collections shared between the 2 threads in the quote process? If so that is WAY easier than what I get from this – “if one server goes down, second server can server the application” which indicates that you want to have the collections synchronized between the two servers, not the 2 threads.

    Or are you asking for both threads and processes to be synchronized? Or can the two threads have difference values in the collections as long as the collections themselves are replicated across the servers?

    Here are some hints on each:

    1) Synchronized across threads. Simply make the collections available in a shared resource across the two threads, ensure you have synchronized the collections. And there you go.

    2) Synchronized across processes. You will need to have some connection like a socket between your two processes that allow them to send and receive each others collections values. This will require an additional thread on in the quote process to handle this.

    Good Luck.

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

Sidebar

Related Questions

Using Linux environment with java,I'm having the config file which should be configured before
I'm running a program in Java which performs a long process. Obviously this causes
Given a Java Servlet (running on a Windows server) which creates a new process
Using a Java based image uploader and having problems, seems my controller action is
I am having trouble running a Java program with Windows Powershell 2.0. Any help
I just started using java so sorry if this question's answer is obvious. I
I'm actually trying doing this in Java, but I'm in the process of teaching
I'm in the process of making a captcha in Java but I'm having trouble
I'm having a lot of difficulty running vmrun through ProcessBuilder in Java. I have
I am in the process of writing a Java web app and am having

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.