English 中文(简体)
Atmosphere/Jersey bidirecting
原标题:Atmosphere/Jersey bidirectional conversation

我看到了一些大气例子,包括公共-次。 我想做一些事情,例如出版商(客户订阅该客户独有的渠道;服务器定期出版该频道),但客户也将向服务器发送数据。 客户将根据服务器发送的数据发送数据,在其他情况下,当服务器需要了解(服务器不需要承认)客户的情况发生重大事件时。

甚至有可能在大气中做到这一点?

它不妨研究这样的问题:

@Stateless
@Path("/id/{clientId}/key/{clientKey}")
public class MyService {
    @POST
    @Produces("application/xml")
    @Consumes("application/xml")
    @Suspend
    public StreamingOutput subscribe(@PathParam("clientId") String clientId,
                                     @PathParam("clientKey") String clientKey,
                                     @Context Broadcaster broadcaster,
                                     InputStream body) {
        if (!authenticate(clientId, clientKey) {
            throw new WebApplicationException(401);
        }
        broadcaster.setID(clientId);

        // Do something here... Not sure what
    }
}

但这里存在几个问题:

  1. The incoming connection will suspend, so it won t be able to send anything to the server except when resumed via broadcast;
  2. Any usage of the InputStream will result in blocking I/O, which kind of defeats the purpose of using Atmosphere.

这些问题都可以通过删除<条码>@Suspend来解决,但随后,在现成的连接状态下,可以解决。

我感到,电离层不会成为这方面的适当技术,而我可能不得不做的只是略微低的。 但我不相信如何去做。 设想?

<><>Edit>:

我可以找到一条直截了当的教 parXML的做法,这样一来,我们就看不到可以轻松地做的事情。

问题回答

进行公正的广播,可以执行你神圣的XML教区。 检查这一样本:

TwitterFeed





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签