问题描述
我正在尝试设置 2 个代理 (DFSearchAgent) 和另一个按类型注册服务的代理 (DFRegisteragent)。
但是,我无法启动“外围容器”或承载第二个代理的额外容器。
假设:
- 两个容器在同一台机器上,因此相同的 IP 和相同的端口。
- JADE 4.5.0 版
- 在 WSL (Windows) 上运行虚拟化 Ubuntu
- 参考文献:https://jade.tilab.com/documentation/examples/yellow-pages/ 和 https://jade.tilab.com/doc/tutorials/JADEAdmin/startJade.html
最初,我使用 JADE GUI 选项和步骤在同一个“MainController”中启动 DFSearchAgent 和 DFRegisteragent:,右键单击 MainContainer ,选择“Start New Agent”,然后从 pre 中选择 DFSearchedAgent -打包示例:
控制台输出:
INFO: ----------------------------------
This is JADE 4.5.0 - revision 6825 of 23-05-2017 10:06:04
downloaded in Open Source,under LGPL restrictions,at http://jade.tilab.com/
----------------------------------------
May 28,2021 2:01:59 PM jade.imtp.leap.LEAPIMTPManager initialize
INFO: Listening for intra-platform commands on address:
- jicp://137.79.225.104:1099
May 28,2021 2:02:00 PM jade.core.BaseService init
INFO: Service jade.core.management.AgentManagement initialized
May 28,2021 2:02:00 PM jade.core.BaseService init
INFO: Service jade.core.messaging.Messaging initialized
May 28,2021 2:02:00 PM jade.core.BaseService init
INFO: Service jade.core.resource.ResourceManagement initialized
May 28,2021 2:02:00 PM jade.core.BaseService init
INFO: Service jade.core.mobility.Agentmobility initialized
May 28,2021 2:02:00 PM jade.core.BaseService init
INFO: Service jade.core.event.Notification initialized
May 28,2021 2:02:00 PM jade.mtp.http.HTTPServer <init>
INFO: HTTP-MTP Using XML parser com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
May 28,2021 2:02:00 PM jade.core.messaging.MessagingService boot
INFO: MTP addresses:
http://XYZ-064067.xyz.abc.gov:7778/acc
May 28,2021 2:02:00 PM jade.core.AgentContainerImpl joinPlatform
INFO: --------------------------------------
Agent container Main-Container@137.79.225.104 is ready.
--------------------------------------------
Agent DFRegisteragent registering service "unkNown" of type "weather-forecast
我重复了添加 DFSearchAgent
、to the same MainContainer
的相同步骤。
Agent DFSearchAgent found the following weather-forecast services:
Service "unkNown" provided by agent DFRegisteragent@137.79.225.104:1099/JADE
问题来了...
如果我重新尝试上述步骤,但是使用两个不同的容器 1 MainContainer 和 1 个外设,那么我会收到异常(远程站点中的 dispatcherException。没有对象 ID 的框架)。
尝试 #1(使用 1 个主容器、1 个外围容器、同一台机器)步骤:
或
关闭旧容器并通过 java jade.Boot -gui
启动一个新的主容器
-
通过命令行运行启动第二个外围容器:
java jade.Boot -gui -container
或在启动时提供代理
java jade.Boot -gui -container provider:examples.yellowPages.DFRegisteragent my-forecast
控制台异常:
Exception message: dispatcher error - Caused by: dispatcherException in remote site. No skeleton for object-id 15724561
尝试 2 个步骤(使用 2 个主容器、同一台机器、GUI 命令):
步骤:
- 使用 2 个不同的 shell/命令窗口,运行
在 shell #1 java jade.Boot -gui
第一个控制台的片段:
May 28,2021 2:50:27 PM jade.core.Runtime beginContainer
INFO: ----------------------------------
This is JADE 4.5.0 - revision 6825 of 23-05-2017 10:06:04
downloaded in Open Source,2021 2:50:27 PM jade.imtp.leap.LEAPIMTPManager initialize
INFO: Listening for intra-platform commands on address:
- jicp://137.79.225.104:1099
在 shell #2 java jade.Boot -gui
第二个控制台的片段:
May 28,2021 2:50:40 PM jade.core.Runtime beginContainer
INFO: ----------------------------------
This is JADE 4.5.0 - revision 6825 of 23-05-2017 10:06:04
downloaded in Open Source,2021 2:50:40 PM jade.imtp.leap.LEAPIMTPManager initialize
INFO: Listening for intra-platform commands on address:
- jicp://137.79.225.104:1099
启动了两个 GUI,有 2 个主要容器。
第一个控制台:
代理 DFRegisteragent 注册“天气预报”类型的服务“未知”
第二个控制台:
代理 DFSearchAgent 搜索“天气预报”类型的服务 Agent DFSearchAgent 没有找到任何天气预报服务
尝试 3 个步骤(使用 1 个主容器和 1 个外围容器、同一台机器、shell 命令):
步骤:
-
启动第一个主容器
java jade.Boot -gui
控制台输出:
May 28,2021 3:02:15 PM jade.core.Runtime beginContainer
INFO: ----------------------------------
This is JADE 4.5.0 - revision 6825 of 23-05-2017 10:06:04
downloaded in Open Source,2021 3:02:15 PM jade.imtp.leap.LEAPIMTPManager initialize
INFO: Listening for intra-platform commands on address:
- jicp://137.79.225.104:1099
-
在一个新的 shell 中,尝试启动第二个外围容器
java jade.Boot -gui -container
控制台输出:
jade.core.IMTPException: jade.core.IMTPException occurred in remote container [Main container cannot reach newly starting node [Container-1,179334,jicp://137.79.225.104:1099]: dispatcher error - Caused by: dispatcherException in remote site. No skeleton for object-id 179334]
尝试 4(通过代码):
我还尝试通过设置 Java 项目并实例化 DFRegisteragent 并注册(1 个 MainContainer 中的 DFRegisteragent & 实例化 DFSearchAgent 并在 2 个 MainContainer 中注册 DFSearchAgent)来尝试相同的步骤。
package com.example.yellowpages;
import jade.util.leap.*;
import jade.core.Profile;
import jade.core.ProfileImpl;
import jade.wrapper.*;
/**
* Hello World!
*/
public final class App {
private App() {
}
/**
* Says hello to the world.
* @param args The arguments of the program.
*/
public static void main(String[] args) {
System.out.println( "Start test..." );
Properties pp = new Properties();
pp.setProperty(Profile.GUI,Boolean.TRUE.toString());
Profile p = new ProfileImpl(pp);
jade.wrapper.AgentContainer ac = jade.core.Runtime.instance().createMainContainer(p);
try {
ac.acceptNewAgent("DFRegisteragent",new DFRegisteragent()).start();
} catch (StaleProxyException e) {
throw new Error(e);
}
System.out.println( "Test is complete..." );
}
}
注册 DFSearchAgent:
package com.example.yellowpages;
import jade.util.leap.*;
import jade.core.Profile;
import jade.core.ProfileImpl;
import jade.wrapper.*;
/**
* Hello World!
*/
public final class App {
private App() {
}
/**
* Says hello to the world.
* @param args The arguments of the program.
*/
public static void main(String[] args) {
System.out.println( "Start test..." );
Properties pp = new Properties();
pp.setProperty(Profile.GUI,Boolean.TRUE.toString());
Profile p = new ProfileImpl(pp);
jade.wrapper.AgentContainer ac = jade.core.Runtime.instance().createMainContainer(p);
try {
ac.acceptNewAgent("DFSearchAgent",new DFSearchAgent()).start();
ac.acceptNewAgent("DFSubscribeAgent",new DFSubscribeAgent()).start();
} catch (StaleProxyException e) {
throw new Error(e);
}
System.out.println( "Test is complete..." );
}
}
我在 2 个单独的 shell 窗口中运行了 2 个程序(第一个运行了 DFRegisteragent,然后是 DFSearchAgent),使用:
java -cp target/demo-1.jar com.example.yellowpages.App
Agent container Main-Container@137.79.225.104 is ready.
--------------------------------------------
Test is complete...
Agent DFRegisteragent registering service "unkNown" of type "weather-forecast"
第二个控制台输出片段:
INFO: --------------------------------------
Agent container Main-Container@137.79.225.104 is ready.
--------------------------------------------
Agent DFSearchAgent searching for services of type "weather-forecast"
Test is complete...
Agent DFSearchAgent did not find any weather-forecast service
查看 GUI,两个代理都已注册。
当代理在单独的容器中注册时,代理无法相互看到,我无法启动外围容器作为解决方法。
赞赏。
解决方法
您报告的错误发生在您启动外围容器而主容器尚未处于活动状态时。 在启动带有顶部搜索代理的外围容器之前,请确保您的主要功能已启动并正在运行。
再见,
乔瓦尼