- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
好的。这又是一个行业惯例问题。
Spring 不需要像 JBoss 这样的应用服务器。如果我们使用 JMS 等企业服务,我们可以使用 RabbitMQ、ApacheMQ 等独立系统。
最佳答案
实际上我会说监听 JMS 可能是应用服务器的最佳理由。独立的消息代理不能解决问题,因为您仍然需要一个正在监听消息的组件。最好的方法是使用 MDB。理论上你可以使用 Springs MessageListenerContainer。然而,这有几个缺点,比如 JMS 只支持阻塞读取,因此 Spring 需要启动它自己的线程,这完全不支持(即使在 Tomcat 中),并且可能会破坏事务、安全性、命名(JNDI)和类加载(这反过来会破坏远程)。 JCA 资源适配器可以随意做任何事情,包括通过 WorkManager 启动线程。除了 JMS(或其他目的地)之外,可能还使用了一个数据库,此时您需要 XA 事务和 JTA,换句话说,一个应用程序服务器。是的,您可以将其修补到 servlet 容器中,但此时它与应用服务器无法区分。
恕我直言,反对应用服务器的最大原因是规范发布后需要数年时间(这反过来也需要数年时间),直到服务器实现规范并消除最严重的错误。直到现在,就在 EE 7 即将发布之前,我们是否有 EE 6 服务器开始出现,它们并没有完全充满错误。一些供应商不再修复其 EE 6 产品线中的错误,因为他们已经忙于即将推出的 EE 7 产品线,这变得可笑了。
编辑
最后一段的详细解释:
Java EE 在很多地方都依赖于所谓的上下文信息。未作为参数从服务器/容器显式传递给应用程序但隐式“存在”的信息。例如当前用户进行安全检查。当前事务或连接。当前用于查找类以延迟加载代码或反序列化对象的应用程序。或者用于进行 JNDI 查找的当前组件(servlet、EJB、...)。所有这些信息都在服务器/容器在调用组件(servlet、EJB、...)之前设置的线程局部变量中。如果您创建自己的线程,则服务器/容器不知道它们,并且依赖此信息的所有功能都不再起作用。您可能会通过在您生成的线程中不使用任何这些功能来解决这个问题。
一些链接
http://www.oracle.com/technetwork/java/restrictions-142267.html#threads http://www.ibm.com/developerworks/websphere/techjournal/0609_alcott/0609_alcott.html#spring-4
如果我们检查 Servlet 3.0 规范,我们会发现:
2.3.3.3 Asynchronous processing
Java Enterprise Edition features such as Section 15.2.2, “Web Application Environment” on page 15-174 and Section 15.3.1, “Propagation of Security Identity in EJBTM Calls” on page 15-176 are available only to threads executing the initial request or when the request is dispatched to the container via the AsyncContext.dispatch method. Java Enterprise Edition features may be available to other threads operating directly on the response object via the AsyncContext.start(Runnable) method.
这是关于异步处理,但同样的限制适用于自定义线程。
public void start(Runnable r) - This method causes the container to dispatch a thread, possibly from a managed thread pool, to run the specified Runnable. The container may propagate appropriate contextual information to the Runnable.
同样,异步处理,但同样的限制适用于自定义线程。
15.2.2 Web Application Environment
This type of servlet container should support this behavior when performed on threads created by the developer, but are not currently required to do so. Such a requirement will be added in the next version of this specification. Developers are cautioned that depending on this capability for application-created threads is not recommended, as it is non-portable.
不可移植意味着它可以在一个服务器上但不能在另一个服务器上。
如果您想在 MDB 之外使用 JMS 接收消息,您可以在 javax.jms.MessageConsumer
上使用四种方法:
#receiveNoWait()
你可以在容器线程中对此进行处理,它不会阻塞,但它就像偷看一样。如果没有消息,它只返回 null
。这不太适合收听消息。#receive(long)
您可以在容器线程中对此进行处理,它确实会阻塞。您通常不希望在容器线程中进行阻塞等待。同样不太适合收听消息。#receive()
,这可能会无限期地阻塞。同样不太适合收听消息。#setMessageListener()
这就是你想要的,当消息到达时你会得到一个回调。但是,除非库可以连接到应用程序服务器,否则它不会是容器线程。应用服务器的 Hook 只能通过 JCA 提供给资源适配器。所以是的,它可能会起作用,但不能保证,而且有很多东西可能会损坏。
关于java - Spring MVC with JBoss vs Tomcat - 优点/实践,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15277356/
我是 JBoss 的新手,发现了很多不同的术语 - JBoss EAP、JBoss Server、Wildfly、Jboss Web,以及很多不是最新的或针对旧版本的文档。 我从哪里开始了解 JBos
JBoss ESB 服务器之间有什么区别(可在此处获得:http://jbossesb.jboss.org/downloads/) 和 JBoss fuse ( http://www.jboss.or
我在我的 PC 上安装了 JBoss 4 到目录 C:\JBoss4 并将环境变量 JBOSS_HOME 设置为此目录: JBOSS_HOME=C:\JBoss4 我需要在同一台 PC 上安装 JB
我有一个 JBoss 服务器正在运行并且想要部署一个服务。 该服务连接到在以下 xml 文件中配置的数据库 jdbc:postgresql://localhost:543
jboss 中的超时是如何工作的?网络应用程序如何知道何时重定向到登录页面? 只是为了澄清! -我知道如何在 jboss 上配置超时。我的问题是,Jboss 如何知道 session 已超时以及何时超
使用JBoss Forge启动新项目时,默认情况下该项目是使用Maven构建系统创建的。我如何利用Forge 2. *的Gradle插件使用Gradle而不是Maven创建项目? % forge Us
当前配置: 正在运行的16个Pod,基于JBoss TCP的集群以及google ping发现。容器作为状态集部署在Kubernetes集群上。 没有负载的初始群集按预期运行,没有任何单个问题,但是当
我以为这将是一个 JBoss 常见问题解答,但我找不到它。 我想同时运行 JBoss 4 和 JBoss 5。我通过将端口的前导数字更改为 9 手动更改了 JBoss 5 服务器/默认实例上的所有端口
我们在 JBoss AS 6 上实现了一些服务作为我们希望迁移到 JBoss AS 7 的单例服务。 这些服务在 jboss-service.xml 文件中声明,该文件位于 EJB 包中,类似于以下代
例如,如何确定我的简单 JBoss 4.2.3 服务器正在监听端口 8080? 这是我最接近的一次,但这不起作用: MBeanServerConnection server = (MBeanServe
我正在尝试找到从语法上确定我的程序是在 Jboss 5 还是 Jboss 7 (eap-6.1) 上运行的最佳方法。到目前为止,我找到的方法是特定于 jboss 5 或 jboss 7 的,这不起作用
我在域模式下使用 JBoss 6.4.8 版本。我想通过 CLI 添加这 4 个系统属性: 1- /host=myserver/server-config=node/system-property=j
在 JBoss 4 中,您可以在文件中设置对象的部署顺序( .jar 、 .war 、 .sar 等...): conf/xmdesc/org.jboss.deployment.MainDeploye
概括地说,JBoss 5 的关闭有什么作用?如果我只是杀死 java 进程而不是优雅地关闭 JBoss,可能会出现什么问题? 对于我的应用程序来说,正常的 JBoss 5 关闭大约需要 6 分钟,这个
我最近在 CentOS 6.7 服务器上安装了 JBoss AS 7。 jboss as 工作正常。为了测试,我部署了一个 .war 文件并对其进行了测试,效果很好!但现在我尝试从我的台式电脑访问相同
我有 jboss 应用程序。并想自动测试部署。并希望将此任务作为项目添加到 Hudson 我的愿景基于以下阶段: 将我的应用程序放到 JBoss(复制耳朵、配置、库等) 运行 JBoss 我有一台 L
我对 JBoss 很陌生。目前我有一个需求,我需要在 JBoss 上部署应用程序(已经在 Tomcat 上运行)。我下载了 JBoss,但是版本 7 中的目录结构不同。 我正在运行 bin\stand
我是 JBoss AS 7 的新手。我尝试在 JBoss AS 7 上部署我的 war 文件,这似乎工作正常。我的问题是在哪里可以看到部署的内容。 我希望它像 Tomcat 一样,它应该有一个探索的
我使用多播方法在两个不同的 JBoss 服务器之间配置了集群。 当我启动两个 JBoss 服务器时,两个服务器都将连接。 一天后,我收到以下消息 server.log 中的群集开始显示错误 05:28
为了打开/关闭我们产品的跟踪-“类别”或“记录器”标签,我们应该在jboss-log4j.xml中使用什么? 默认情况下,JBoss在jboss-log4j.xml中使用“类别”。 但据我所知,不赞成
我是一名优秀的程序员,十分优秀!