在多个服务器上查找相同的EJB [英] Lookup of same EJB on multiple servers

查看:65
本文介绍了在多个服务器上查找相同的EJB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用完全相同的bean实现从一个部署到另一个部署进行查找。基本上,这是一个消费者/生产者设置,在两台机器上的两个部署中都具有相同的bean。

I am trying to do a lookup from one deployment to another deployment, using exactle the same bean implementations. It is basically a consumer/producer setup with the same beans in both deployments on both machines.

ear
    ejb-api
        com.example.bean
            ConsumerBean
            ProducerBean
    ejb-jar
        com.example.bean
            ConsumerBeanRemote
            ProducerBeanRemote

ProducerBeanRemote应该查找ConsumerBeanRemote并调用其公共方法。

The ProducerBeanRemote should look up the ConsumerBeanRemote and call its public method.

我们的机器正在这样通信:

Our machines are communicating like this:

(Machine A) ProducerBeanRemote --> (Machine B) ConsumerBeanRemote
(Machine A) ProducerBeanRemote --> (Machine C) ConsumerBeanRemote
(Machine A) ProducerBeanRemote --> (Machine D) ConsumerBeanRemote

您明白了...

所以问题是,它不起作用。我尝试使用jboss-as-ejb-client库进行手动查找,但该方法不起作用,因为JBoss在启动其容器时锁定了EJB选择器(而且我敢打赌,规范对Java EE中的手动查找有话要说环境)。我尝试的下一件事是使用Spring的功能进行查找,无济于事。

So the problem is, it doesn't work. I tried to do a manual lookup using the jboss-as-ejb-client libraries, which didn't work because JBoss locks the EJB selector while starting its container (AND I bet the spec has something to say about manual lookups in a Java EE environment). The next thing I tried was doing a lookup using the feature from Spring, to no avail.

我们正在使用JBoss Application Server 7.1.1.Final。

We are using the JBoss Application Server 7.1.1.Final.

我敢打赌,必须有一种方法来完成我的设置,非常感谢社区提供的任何帮助。

I bet there has to be a way to accomplish my setup and I would greatly appreciate any help from the community.

更新:

要从ProducerBeanRemote连接到ConsumerBeanRemote,我们需要在运行时通过配置指定远程InitialContext。

To connect from ProducerBeanRemote to ConsumerBeanRemote, we need the possibility to specify the remote InitialContext at runtime via configuration.

Properties properties = new Properties();
properties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
properties.put("remote.connections", "default");
properties.put("remote.connection.default.host", "remote-host");
properties.put("remote.connection.default.port", "4447");
properties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");

EJBClientConfiguration ejbClientConfiguration = new PropertiesBasedEJBClientConfiguration(properties);
ContextSelector<EJBClientContext> ejbClientContextSelector = new ConfigBasedEJBClientContextSelector(ejbClientConfiguration);
EJBClientContext.setSelector(ejbClientContextSelector);

StatelessEJBLocator<T> locator = new StatelessEJBLocator<>(viewType, appName, moduleName, beanName, distinctName);
return EJBClient.createProxy(locator);

产生的异常是

java.lang.SecurityException: EJB client context selector may not be changed at org.jboss.ejb.client.EJBClientContext.setSelector(EJBClientContext.java:181)

我们了解,由于 https://issues.jboss.org/browse/AS7-2998 ,所以问题仍然存在:我们如何才能以一种干净且可配置的方式远程调用相同的bean?

We understand that this exception is thrown because of https://issues.jboss.org/browse/AS7-2998, so the question remains: How can we remotely call the same beans in a clean and configurable way?

推荐答案

与此处描述的问题几乎相同:从一台服务器到许多可配置服务器的JNDI查找

Nearly the same question as described here: JNDI lookup from one server to many configurable servers

似乎不可能通过EJB在多个服务器之间建立了可靠的连接,因此我们最终将JMS用于服务器到服务器的通信。也许那也是您的选择。

It seems to be impossible to get a reliant connection between multiple servers via EJB, so we ended up using JMS for our server to server communication. Maybe thats an option for you, too.

这篇关于在多个服务器上查找相同的EJB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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