简体   繁体   English

使用JAX-WS的并发Web服务请求

[英]Concurrent Web Service Requests using JAX-WS

I need to design a solution for my problem. 我需要为我的问题设计解决方案。 So, Please help me. 所以,请帮帮我。

My Problem : 我的问题 :

We have one Web Project. 我们有一个Web项目。 There we are using four tables called A, B, C, D. For each table, we had created one front-end page and we provided a button for save the record to respective tables. 在这里,我们使用了四个表,分别称为A,B,C,D。对于每个表,我们已经创建了一个前端页面,并且提供了一个用于将记录保存到各个表的按钮。 Now we need to share this each record data to another application using Web-Service integration. 现在,我们需要使用Web服务集成将此记录数据共享到另一个应用程序。 I have the knowledge on JAX-WS web service. 我对JAX-WS Web服务有所了解。

We Identified the required fields and we created only one common WSDL for all four tables. 我们确定了必填字段,并且为所有四个表仅创建了一个通用的WSDL。 When the user will try to save the record, at the time only i need to raise the web service call.(Event Base) Here we are fallowing the Synchronous web service. 当用户尝试保存记录时,此时仅需要提出Web服务调用。(事件库)在这里,我们放弃了同步Web服务。 Ie for every request system will wait for response from other end. 即,对于每个请求系统,都将等待来自另一端的响应。

Suppose, first i am trying to save the record in table A. so, i filled all required fields in form A, and i am trying to hit the save button. 假设,首先,我尝试将记录保存在表A中。因此,我在表格A中填写了所有必填字段,然后尝试单击“保存”按钮。 record saved in database as well as raised a web service request to other end, sent an record to server and waiting for response..... If in this mean while if again i am trying to send another record for same form A (or) new record for form B. 记录保存在数据库中,并向另一端提出Web服务请求,将记录发送到服务器并等待响应..... )表格B的新记录。

Then how to handle this kind of scenario, because already a thread was busy with server for their response. 然后如何处理这种情况,因为已经有一个线程在忙于服务器的响应。 So, how to raise an multiple request concurrently as we as in synchronously. 因此,如何像我们同步地同时提出多个请求。

Please suggest me with the possible solutions that i can apply. 请给我建议我可以应用的可能解决方案。 An suggestion will be great helpful for me. 一个建议对我很有帮助。

(Sorry for my bad English) (对不起,我的英语不好)

Looking at your scenario i see that you have something like: 查看您的情况,我看到您有类似的东西:

Database -> Web JAX-WS Server -> Multiple JAX-WS Clients 数据库-> Web JAX-WS服务器->多个JAX-WS客户端

When you call from the client to the WS Server a new thread is created to handle the request and process the response for every client. 当您从客户端调用WS Server时,将创建一个新线程来处理请求并为每个客户端处理响应。 Web servers are "multithread" and support multiple clients calling at same time. Web服务器是“多线程”,并且支持同时调用多个客户端。 Your problem probably is after the WS service. 您的问题可能出在WS服务之后。

If with your WS you are trying to read the same table with two clients there is no problem but if one client tries to save when other reads or two or more clients are updating the table a Transaction lock is probably the problem. 如果使用您的WS,您尝试与两个客户端读取同一张表,则没有问题,但是,如果一个客户端在其他读取或两个或多个客户端更新表时尝试进行保存,则可能是事务锁。

Depending on the database configuration you should need to configure your transaction isolation options and handle carfully your database connections opening and closing your transactions only when is absolutly required 根据数据库配置,仅在绝对需要时,您应该需要配置事务隔离选项并巧妙地处理数据库连接的打开和关闭事务

For example if you are using MySQL with InnDB ( http://dev.mysql.com/doc/refman/5.0/es/innodb-transaction-isolation.html ) and your Transaction isolation is "SERIALIZABLE" when you perform a query al table is locked until transaction ends and any other client is waiting until the transaction is released or a timeout is raised. 例如,如果您将MySQL与InnDB一起使用( http://dev.mysql.com/doc/refman/5.0/es/innodb-transaction-isolation.html ),并且在执行查询时您的事务隔离为“ SERIALIZABLE”该表被锁定,直到事务结束,并且其他任何客户端都在等待该事务被释放或引发超时。

But if you hace "REPEATABLE READ" only the records readed by one transaction are locked to other transactions. 但是,如果您具有“ REPEATABLE READ”,则只有一个事务读取的记录被锁定到其他事务。 This can be "good" in some environments but two SQL sentences that aplies to the same row probably cause a dead lock. 在某些环境中,这可能是“好”的操作,但适用于同一行的两个SQL语句可能会导致死锁。 * Default for MySQL InnDB * MySQL InnDB的默认值

Also you should use READ COMMITED or READ UNCOMMITED to allow read all table and modify different records. 另外,您应该使用READ COMMITED或READ UNCOMMITED来读取所有表并修改不同的记录。 Also to handle the same record with minimal problems is always recommended: "Open your transactions only the minimal required time" 始终建议您以最少的问题处理同一条记录:“仅在最短的时间内打开交易记录”


Check your WS client for singleton patterns that destroys first request when you create a second request. 在创建第二个请求时,请检查您的WS客户机是否存在会破坏第一个请求的单例模式。 Also check if you are using an WS with state, preserving session or another server side objects in a user session that are the same for different requests.. 还要检查您是否正在使用带有状态,保留会话的WS或用户会话中的另一个服务器端对象,这些对象对于不同的请求是相同的。

Related to Stateles: 与Stateles相关:

Is it possible to use @WebService, @Stateless and @Singleton altogether in one EJB 3 bean? 是否可以在一个EJB 3 bean中一起使用@ WebService,@ Stateless和@Singleton?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM