从java Web服务到.net应用程序的异步调用 [英] Asynchronous call from java web service to .net application

查看:232
本文介绍了从java Web服务到.net应用程序的异步调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景:

有一个java库可以帮助异步监听一些
系统事件。我打算使用vb.net项目中已经实现的asynch
功能。
我计划通过以下方式解决这个问题:

There is a java library that helps asynchronously listen to some system events. I am planning to use the already implemented asynch functionality from a vb.net project. I have planned to address it in the following way :


  1. 围绕java库编写Web服务

  1. Write a web service around the java library

将该服务的引用添加到.net应用程序。

Add reference of that service to the .net app.

Web服务将作为.net应用程序在tomcat上本地运行。我面临的问题是如何使Web服务异步与.net应用程序通信? .net应用程序应该阻止并等待Web服务,如果是这样的话?

The web service will run locally on a tomcat as the .net app. The problem i am faced with is how do i make the web service communicate to the .net app asynchronously ? Should the .net app block and wait on a web service and if so how ?


推荐答案

我认为首先需要一种异步服务通信的设计模式,以更好地满足您的系统要求。

I believe that firstly you need a design pattern for asynchronous services communication t better address your system requirements.

1 - 异步响应处理程序

应用程序创建一个独立的线程来处理服务器响应,让主线程可以自由执行其他任务。当响应到达时,通知主线程接收响应。有两种实现策略:池化和回调。使用池时,主线程会检查第二个线程中的响应,直到响应可用。使用回调,第二个线程使用回调方法通知主线程。

The application creates a separated thread to process server response leaving main thread free for other tasks. When response arrives main thread is notified to receive the response. There are two implementation strategies: pooling and callback. With pooling, the main thread checks for response in the second thread until the response is available. With callback, the second thread notifies the main thread using a callback method.

2 - 请求/确认

此模式基于服务器参与实现异步通信。该进程不是将进程拆分为两个客户端线程,而是分为客户端和服务器之间的两个不同的事务。这种模式需要某种相关性识别来关联请求和响应事务。消息传递子系统用于实现更高的可伸缩性和可用性。

This patterns is based on the server participation to achieve asynchronous communication. Instead of splitting the process into two client threads, the process divided into two different transactions between client and server. This patterns needs some kind of correlation identification to associate request and response transactions. A messaging subsystem is used to achieve more scalability and availability.

可以使用异步响应处理程序/回调策略实现一个简单的解决方案。为此,服务提供者(java)可以是一个简单的jax-ws Web服务。服务使用者(.net)实现可以使用AsyncCallback Delegate。有一个例子这里

A simple solution could be implemented using Asynchronous Response Handler/Callback Strategy. To do that, the service provider (java) could be a simple jax-ws web service.The service consumer(.net) implementation could use the AsyncCallback Delegate. There is a example here.

参考文献:

http://www.servicedesignpatterns.com/WebServiceInfrastructures/AsyncResponseHandler
http://www.servicedesignpatterns.com/ClientServiceInteractions/RequestAcknowledge
http://msdn.microsoft.com/pt-br/library/system.asynccallback(v = vs.110).aspx (AsyncCallback Delegate)
http:/ /msdn.microsoft.com/en-us/library/wyd0d1e5(v=vs.100).aspx (服务消费者)
http://java.dzone.com/articles/jax-ws-hello-world (服务提供商)

http://www.servicedesignpatterns.com/WebServiceInfrastructures/AsyncResponseHandler http://www.servicedesignpatterns.com/ClientServiceInteractions/RequestAcknowledge http://msdn.microsoft.com/pt-br/library/system.asynccallback(v=vs.110).aspx (AsyncCallback Delegate) http://msdn.microsoft.com/en-us/library/wyd0d1e5(v=vs.100).aspx (service consumer) http://java.dzone.com/articles/jax-ws-hello-world (service producer)

这篇关于从java Web服务到.net应用程序的异步调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆