How can I call externalApplication based on Activemq message using JMS

前端 未结 1 591
夕颜
夕颜 2021-01-25 16:23

I build 3 Applications,each Application takes more than 20 min for evaluation.I placed 3 files in the following directories

 ProjectcContextPath/WEB-INF/classes/         


        
相关标签:
1条回答
  • 2021-01-25 16:53

    Based on these requirements

    • When data in the database is changed, a message will be posted on a queue.
    • Based on the message content you call another service dynamically.
    • That service does some computation, but it's result is not intended for an end-user. It takes 20min.

    you could implement a stand-alone application which receives messages synchronously like this (pseudo code):

    while (true) {
      Message message = queueReceiver.receive();
      TextMessage textmsg = (TextMessage) message;
    
      if (textmsg.getText().equals("service1")) {
        new Service1().execute();
      } else if (textmsg.getText().equals("service2")) {
        new Service2().execute();
      } else {
        // Show error
      }
      message.acknowledge();
    }
    

    This job runs continuously.


    The differences to your proposal

    • Using a stand-alone program (with a main method) instead of a servlet. A servlet is not suitable (because it does not run continuously)
    • Implement your services as normal Java classes; calling JSPs or servlets for processing is not useful. They are intended to implement the presentation layer

    Update

    If your services are only reachable over HTTP (this is the case with servlets/JSP), then you could implement these as a web service.

    0 讨论(0)
提交回复
热议问题