Could someone help me on this,
i have created simple webservices and it has a queue that keeps xml files send from a client, so whenever webservice client call a method on webserbice , webserbice load this xml to its queue, no开发者_Python百科w i want to have a thread running on webserbice which monitors this queue if there items on the queue take other actions.
But my problem is , webservice only invoke if client calls one of the methods in ws interface. so but i need this thread to be running on webserbice. so could someone tell me is there are a way to do this
You have to run your web service (server) inside a web application, which means that you probably have a web.xml somewhere. You can create a servlet, and initialize (starting) the processing thread on its init method, stopping it on the destroy method of the servlet. Be aware, thought, that by using this model you may lose unprocessed messages if the web application is stopped. You should perhaps be looking at JMS or something like WebSphere MQ, they both can act as messaging systems - you receive the message, queue it in a different queue, and then when the processing application is ready, it pulls the next message, processes it, and informs the calling process back.
精彩评论