当前位置: 首页 > 知识库问答 >
问题:

是否可以明确指示JBoss EAP 6中使用哪个EJB接收器?

斜淳
2023-03-14

我正在尝试从运行在JBoss EAP 6的单独实例上的客户端服务器对运行在JBoss EAP 6的一个实例上的多个服务器进行远程调用。我已经配置了JBoss到JBoss的远程通信,并且已经阅读了范围内的EJB客户端上下文,但是两者似乎不兼容。目前,我配置了两个EJB接收器(每个远程服务器一个),但是当我尝试进行远程调用时,会出现初始化的上下文随机选择它将使用的EJB接收器。如果我有远程IP和端口,或者远程连接名称,我可以在初始化上下文时强制使用哪个EJB接收器似乎是合理的,但是唉,我不知道秘密握手。

主办xml:

<security-realm name="ejb-security-realm">
    <server-identities>
        <secret value="ZWpiUEBzc3cwcmQ="/>
    </server-identities>
</security-realm>

domain.xml:

<subsystem xmlns="urn:jboss:domain:remoting:1.2">
                <connector name="remoting-connector" socket binding="remoting" security-realm="ApplicationRealm"/>
                <outbound-connections>
                    <remote-outbound-connection name="remote-ejb-connection" outbound-socket-binding-ref="mpg1-app1" username="ejbuser" security-realm="ejb-security-realm">
                        <properties>
                            <property name="SASL_POLICY_NOANONYMOUS" value="false"/>
                            <property name="SSL_ENABLED" value="false"/>
                        </properties>
                    </remote-outbound-connection>
                    <remote-outbound-connection name="remote-ejb-connection2" outbound-socket-binding-ref="mpg2-app1" username="ejbuser" security-realm="ejb-security-realm">
                        <properties>
                            <property name="SASL_POLICY_NOANONYMOUS" value="false"/>
                            <property name="SSL_ENABLED" value="false"/>
                        </properties>
                    </remote-outbound-connection>
                </outbound-connections>
            </subsystem>
...
<socket-binding-group name="full-sockets" default-interface="public">
            ...
            <socket-binding name="remoting" port="44447"/>
            <outbound-socket-binding name="mpg1-app1">
                <remote-destination host="localhost" port="44452"/>
            </outbound-socket-binding>
            <outbound-socket-binding name="mpg2-app1">
                <remote-destination host="localhost" port="44453"/>
            </outbound-socket-binding>
</socket-binding-group>

jboss ejb客户端。xml

<jboss-ejb-client xmlns="urn:jboss:ejb-client:1.0">
    <client-context>
        <ejb-receivers>
            <remoting-ejb-receiver outbound-connection-ref="remote-ejb-connection"/>
            <remoting-ejb-receiver outbound-connection-ref="remote-ejb-connection2"/>
        </ejb-receivers>
    </client-context>
</jboss-ejb-client>

远程呼叫:

上下文ctx=null;

最终属性props=新属性();

道具。put(Context.URL\u PKG\u前缀,“org.jboss.ejb.client.naming”);

试试看{

ctx=新的初始上下文(props)
MyInterfaceObject-ourInterface=ctx。查找(“ejb:“appName”/“moduleName”/“beanName”!”viewClassName);

ourInteface。refreshProperties()//远程方法调用

}

任何帮助都将不胜感激!

共有1个答案

柴昆杰
2023-03-14

你试过集群节点选择器吗

jboss ejb客户端。xml

  <!-- if an outbound connection connect to a cluster a list of members is provided after successful connection.
To connect to this node this cluster element must be defined.
-->
   <clusters>
     <!-- cluster of remote-ejb-connection-1 -->
     <cluster name="ejb" security-realm="ejb-security-realm-1" username="test" cluster-node-selector="org.jboss.as.quickstarts.ejb.clients.selector.AllClusterNodeSelector">
        <connection-creation-options>
           <property name="org.xnio.Options.SSL_ENABLED" value="false" />
           <property name="org.xnio.Options.SASL_POLICY_NOANONYMOUS" value="false" />
        </connection-creation-options>
      </cluster>
   </clusters>
  </client-context>
</jboss-ejb-client>

选择器实现

    @Override
            public String selectNode(final String clusterName, final String[] connectedNodes, final String[] availableNodes) {
                    if (availableNodes.length == 1) {
                            return availableNodes[0];
                    }
                    // Go through all the nodes and point to the one you want
                    for (int i = 0; i < availableNodes.length; i++) {
                            if (availableNodes[i].contains("someoneYouInterestIn")) {
                                    return availableNodes[i];
                            }
                    }

                    final Random random = new Random();
                    final int randomSelection = random.nextInt(availableNodes.length);
                    return availableNodes[randomSelection];
            }

有关更多信息,您可以查看https://access.redhat.com/documentation/en/red-hat-jboss-enterprise-application-platform/7.0/developing-ejb-applications/chapter-8-clustered-enterprise-javab

 类似资料:
  • 我知道我也可以通过创建一个新文档,然后通过更新,但是这个方法需要2个写操作,而且速度也慢得多。

  • 我的配置是:Wildfly8.2.0,Weld 是否可以在CDI中注入bean而不是在其接口中注入?

  • 在C/C中,可以对SIMD(如AVX和AVX2)指令使用内部函数。有没有办法在Rust中使用SIMD?

  • 问题内容: 我想我了解什么是指针,但我不太了解何时使用它。 下面的摘录来自“ A Tour of Go”。 “ * Vertex”和“&Vertex”的目的是什么? 我用“顶点”替换了它们,并且运行良好。 问题答案: 这不是指针/值区分的特别好例子,因为在这种情况下它们是可互换的!当您需要(从另一个函数)“远程”更改数据时,指针很有用。 正如您将注意到的那样,这不会改变任何东西(严格来说,它会更改

  • 我是JBoss 7的新手。我面临着奇怪的行为。有时,当我试图调用会话bean时,会遇到以下异常: 这通常发生在从Eclipse运行GWT应用程序时。异常并不总是发生。有时它比其他情况发生得少。有时每次我调用会话bean时都会发生这种情况,这很痛苦。我阅读了教程(https://docs.jboss.org/author/display/AS71/EJB使用JNDI从远程客户端调用_sscc=t),