【发布时间】:2014-10-09 12:26:48
【问题描述】:
我有以下 idl 结构。我想使用 opendds 发布它
#pragma DCPS_DATA_TYPE "B::CData"
#pragma DCPS_DATA_KEY "B::CData id"
module B {
struct Quote {
string skit_name;
string episode_name;
string line;
};
struct CData{
long id;
Quote payload;
};
};
我用 Java 编写了发布者和订阅者。但是在发布和订阅上述主题时,JVM 崩溃了。
有人知道吗?
下面是公共话题的java代码
public static void main(String[] args) {
DomainParticipantFactory dpf =
TheParticipantFactory.WithArgs(new StringSeqHolder(args));
if (dpf == null) {
System.err.println ("Domain Participant Factory not found");
return;
}
final int DOMAIN_ID = 42;
DomainParticipant dp = dpf.create_participant(DOMAIN_ID,
PARTICIPANT_QOS_DEFAULT.get(), null, DEFAULT_STATUS_MASK.value);
if (dp == null) {
System.err.println ("Domain Participant creation failed");
return;
}
CDataTypeSupportImpl servant = new CDataTypeSupportImpl();
if (servant.register_type(dp, "") != RETCODE_OK.value) {
System.err.println ("register_type failed");
return;
}
Topic top = dp.create_topic("data",
servant.get_type_name(),
TOPIC_QOS_DEFAULT.get(), null,
DEFAULT_STATUS_MASK.value);
Publisher pub = dp.create_publisher(
PUBLISHER_QOS_DEFAULT.get(),
null,
DEFAULT_STATUS_MASK.value);
DataWriter dw = pub.create_datawriter(
top, DATAWRITER_QOS_DEFAULT.get(), null, DEFAULT_STATUS_MASK.value);
CDataDataWriter mdw = CDataDataWriterHelper.narrow(dw);
CData cData=new CData();
int handle = mdw.register(cData);
// above statement crashes the jvm
int ret = mdw.write(msg, handle);
}
【问题讨论】:
-
我想不会——因为你没有真正展示任何相关的代码,或者它是如何崩溃的......
-
另外,一定要确认 - JVM 崩溃了?
-
通常,JVM 崩溃是 JVM 错误(除非您的 DDS 提供程序使用 JNI)。你能试试另一个JRE吗?哪个 DDS 提供商会出现这种情况?
标签: java publish-subscribe data-distribution-service