[Ace-users] JacORB and TAO 1.5 notification service incompatibility
christian.galli at gmail.com
christian.galli at gmail.com
Fri Nov 9 16:21:10 CST 2007
ACE VERSION: 5.5.9 and 5.5a_p4
HOST MACHINE and OPERATING SYSTEM:
Redhat Enterprise Linux 4.2, Intel Xeon
TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
COMPILER NAME AND VERSION (AND PATCHLEVEL): GCC 3.4.4
CONTENTS OF $ACE_ROOT/ace/config.h [if you use a link to a
platform-
specific file, simply state which one]:
#include "config-linux.h"
#undef ACE_LACKS_MKSTEMP_PROTOTYPE
CONTENTS OF $ACE_ROOT/include/makeinclude/platform_macros.GNU [if
you
use a link to a platform-specific file, simply state which one
(unless this isn't used in this case, e.g., with Microsoft Visual
C++)]:
platform_linux.GNU
CONTENTS OF $ACE_ROOT/bin/MakeProjectCreator/config/
default.features
(used by MPC when you generate your own makefiles):
LEVEL OF URGENCY (LOW, MEDIUM, or HIGH): MEDIUM
AREA/CLASS/EXAMPLE AFFECTED:
Notification services
DOES THE PROBLEM AFFECT:
EXECUTION of my application
SYNOPSIS:
Sending StructuredEvent from JacORB 2.2.4 to TAO 1.5 fails to
deserialize remainder_of_body using >>= operator. Works with
TAO 1.4
DESCRIPTION:
Java test client sends StructuredEvent but C++ server fails to
deserialize the message. Test programs are included below.
This
works with TAO 1.4 but not with TAO 1.5 (tried both 5.5a_p4
and 5.5.9).
C++ client sends same StructuredEvent, which the server can
deserialize properly with either TAO version. I don't see any
exceptions on either program. The >>= operator returns false.
REPEAT BY:
---------------
IDL Definition
---------------
/*
Proxy type enum
*/
enum PROXYTYPE
{
PUB,
SUB,
CLIENT,// bidirectional subscriber
SERVER // bidirectional publisher
};
/*
Proxy location enum
*/
enum PROXYLOC
{
LOCAL_SYSTEM,
REMOTE_SYSTEM
};
/*
Used to identify individual proxy. Comprised of local machine ip,
process id
and an instance number that can be used to support multiple proxy
instances
in the future. Its use is confined to DLMProxy, Channel Manager and
TapPoint Manager.
*/
struct ProxyID
{
long process_id; // PID DLM proxy belongs to
long instance; // unique ID to distinguish between
// multiple proxies in the same process
string ip; // IP Address of proxy location
};
/**
* Header to fully identify a proxy local or remote
*/
struct ProxyHeader
{
ProxyID pID;
PROXYTYPE type;
PROXYLOC location;
};
typedef sequence<ProxyHeader> PROXYHEADERSEQ;
/**
Message from TPM to DLM to attach a publisher to a subscriber
*/
struct Attach
{
ProxyHeader publisher;
ProxyHeader subscriber;
};
---------------
C++ Server Code
---------------
#include <ace/Version.h>
#if ( ACE_MAJOR_VERSION == 5 ) && ( ACE_MINOR_VERSION > 4 )
#include <tao/AnyTypeCode/AnyTypeCode_methods.h>
#include <tao/AnyTypeCode/TypeCode.h>
#else
#include <tao/Typecode.h>
#endif
#include <tao/corba.h>
#include <tao/PortableServer/PortableServer.h>
#include <orbsvcs/Notify/Notify_EventChannelFactory_i.h>
#include <iostream>
#include <fstream>
#include "TapPointManagerC.h"
using std::cout;
using std::endl;
namespace
{
const char* g_types[] = {
"PUB",
"SUB",
"CLIENT",
"SERVER"
};
const char* g_locations[] = {
"LOCAL_SYSTEM",
"REMOTE_SYSTEM"
};
}
class TestConsumer : public POA_CosNotifyComm::StructuredPushConsumer
{
public:
virtual void push_structured_event(
const CosNotification::StructuredEvent& p_event
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
ACE_THROW_SPEC((CORBA::SystemException))
{
cout << "---------------" << endl;
cout << "StructuredEvent" << endl;
cout << "---------------" << endl;
cout << "Domain Name: '" <<
p_event.header.fixed_header.event_type.domain_name.in() << "'" <<
endl;
cout << "Type Name: '" <<
p_event.header.fixed_header.event_type.type_name.in() << "'" << endl;
cout << "Event Name: '" <<
p_event.header.fixed_header.event_name.in() << "'" << endl;
cout << "Variable Header Length: " <<
p_event.header.variable_header.length() << endl;
cout << "Filterable Data Length: " <<
p_event.filterable_data.length() << endl;
CORBA::TypeCode_var pTypeCode = p_event.remainder_of_body.type();
CORBA::String_var pTypeID = pTypeCode->id();
cout << "Body Type ID = " << pTypeID.in() << endl;
const Attach* pAttach;
if(p_event.remainder_of_body >>= pAttach)
{
cout << "Deserialized Attach Msg From Body OK" << endl;
cout << "Publisher - " << pAttach->publisher.pID.ip.in() << ":"
<< pAttach->publisher.pID.process_id << ":"
<< pAttach->publisher.pID.instance << ", "
<< g_types[pAttach->publisher.type] << ", "
<< g_locations[pAttach->publisher.location] << endl;
cout << "Subscriber - " << pAttach->subscriber.pID.ip.in() << ":"
<< pAttach->subscriber.pID.process_id << ":"
<< pAttach->subscriber.pID.instance << ", "
<< g_types[pAttach->subscriber.type] << ", "
<< g_locations[pAttach->subscriber.location] << endl;
}
else
{
cout << "Deserialize Body Failed" << endl;
}
}
virtual void offer_change(
const CosNotification::EventTypeSeq& p_added,
const CosNotification::EventTypeSeq& p_removed
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
ACE_THROW_SPEC((CORBA::SystemException))
{
}
virtual void disconnect_structured_push_consumer(
ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
ACE_THROW_SPEC((CORBA::SystemException))
{
}
};
int main(int argc, char* argv[])
{
try
{
CORBA::ORB_var pOrb = CORBA::ORB_init(argc, argv, "ServerOrb");
CORBA::Object_var pPoaObj = pOrb-
>resolve_initial_references("RootPOA");
PortableServer::POA_var pPoa =
PortableServer::POA::_narrow(pPoaObj.in());
PortableServer::POAManager_var pMgr = pPoa->the_POAManager();
pMgr->activate();
CosNotification::QoSProperties channelQoS;
CosNotification::AdminProperties channelAdmin;
CosNotifyChannelAdmin::ChannelID channelID;
CosNotifyChannelAdmin::EventChannelFactory_var pFactory =
TAO_Notify_EventChannelFactory_i::create(pPoa.in());
CosNotifyChannelAdmin::EventChannel_var pChannel =
pFactory->create_channel(channelQoS, channelAdmin, channelID);
CORBA::String_var pIOR = pOrb->object_to_string(pChannel.in());
ofstream iorFile("test.ior");
iorFile << pIOR.in() << endl;
iorFile.close();
cout << "Saved IOR = " << pIOR.in() << endl;
TestConsumer consumer;
PortableServer::ObjectId_var pConsumerID = pPoa-
>activate_object(&consumer);
CORBA::Object_var pConsumerObj = pPoa-
>id_to_reference(pConsumerID.in());
CosNotifyComm::StructuredPushConsumer_var pConsumer =
CosNotifyComm::StructuredPushConsumer::_narrow(pConsumerObj.in());
CosNotifyChannelAdmin::AdminID consumerAdminID;
CosNotifyChannelAdmin::ProxyID consumerProxyID;
CosNotifyChannelAdmin::ConsumerAdmin_var pConsumerAdmin =
pChannel->new_for_consumers(CosNotifyChannelAdmin::AND_OP,
consumerAdminID);
CosNotifyChannelAdmin::ProxySupplier_var pProxySupplier =
pConsumerAdmin->obtain_notification_push_supplier(
CosNotifyChannelAdmin::STRUCTURED_EVENT, consumerProxyID);
CosNotifyChannelAdmin::StructuredProxyPushSupplier_var
pStructuredSupplier =
CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow(pProxySupplier.in());
pStructuredSupplier-
>connect_structured_push_consumer(pConsumer.in());
cout << "Server Ready" << endl;
pOrb->run();
}
catch(const CORBA::Exception& ex)
{
cout << "Exception: " << ex._rep_id() << endl;
return 1;
}
return 0;
}
----------------
Java Client Code
----------------
import java.io.*;
import java.util.*;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.CosNotification.*;
import org.omg.CosNotifyComm.*;
import org.omg.CosNotifyChannelAdmin.*;
import idlgen.*;
public class TestClient
{
private static class TestSupplier extends StructuredPushSupplierPOA
{
public void subscription_change(EventType[] added, EventType[]
removed)
{
}
public void disconnect_structured_push_supplier()
{
}
}
public static void main(String[] args)
{
try
{
Properties props = new Properties();
props.setProperty("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
props.setProperty("org.omg.CORBA.ORBSingletonClass",
"org.jacorb.orb.ORBSingleton");
ORB orb = ORB.init(args, props);
POA poa =
POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
poa.the_POAManager().activate();
// get IOR
Scanner scanner = new Scanner(new File("test.ior"));
String ior = scanner.nextLine();
System.out.println("Got IOR = " + ior);
// get channel
EventChannel channel =
EventChannelHelper.narrow(orb.string_to_object(ior));
// create supplier
TestSupplier supplier = new TestSupplier();
poa.activate_object(supplier);
StructuredPushSupplier supplierObj =
StructuredPushSupplierHelper.narrow(
poa.servant_to_reference(supplier));
// connect supplier
IntHolder adminID = new IntHolder();
IntHolder proxyID = new IntHolder();
SupplierAdmin admin = channel.new_for_suppliers(
InterFilterGroupOperator.AND_OP, adminID);
StructuredProxyPushConsumer proxyConsumer =
StructuredProxyPushConsumerHelper.narrow(
admin.obtain_notification_push_consumer(
ClientType.STRUCTURED_EVENT, proxyID));
proxyConsumer.connect_structured_push_supplier(supplierObj);
System.out.println("Connected, Sending Attach");
// send test event
StructuredEvent event = new StructuredEvent(
new EventHeader(
new FixedEventHeader(
new EventType("DataLinkManager", "Attach"),
""),
new org.omg.CosNotification.Property[0]),
new org.omg.CosNotification.Property[0],
orb.create_any());
Attach attachMsg = new Attach();
attachMsg.publisher = new ProxyHeader();
attachMsg.publisher.pID = new ProxyID(12345, 0, "192.168.2.77");
attachMsg.publisher.type = PROXYTYPE.PUB;
attachMsg.publisher.location = PROXYLOC.LOCAL_SYSTEM;
attachMsg.subscriber = new ProxyHeader();
attachMsg.subscriber.pID = new ProxyID(12345, 1, "192.168.2.77");
attachMsg.subscriber.type = PROXYTYPE.SUB;
attachMsg.subscriber.location = PROXYLOC.LOCAL_SYSTEM;
AttachHelper.insert(event.remainder_of_body, attachMsg);
proxyConsumer.push_structured_event(event);
System.out.println("Attach Message Sent");
System.exit(0);
}
catch(Exception ex)
{
ex.printStackTrace();
System.exit(1);
}
}
}
---------------
C++ Client Code
---------------
#include <tao/corba.h>
#include <tao/PortableServer/PortableServer.h>
#include <orbsvcs/CosNotificationC.h>
#include <orbsvcs/CosNotifyCommS.h>
#include <orbsvcs/CosNotifyChannelAdminC.h>
#include <iostream>
#include <fstream>
#include "TapPointManagerC.h"
using std::cout;
using std::endl;
class TestSupplier : public POA_CosNotifyComm::StructuredPushSupplier
{
public:
virtual void subscription_change(
const CosNotification::EventTypeSeq& p_added,
const CosNotification::EventTypeSeq& p_removed
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
ACE_THROW_SPEC((CORBA::SystemException))
{
}
virtual void disconnect_structured_push_supplier(
ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
ACE_THROW_SPEC((CORBA::SystemException))
{
}
};
int main(int argc, char* argv[])
{
try
{
CORBA::ORB_var pOrb = CORBA::ORB_init(argc, argv, "ServerOrb");
CORBA::Object_var pPoaObj = pOrb-
>resolve_initial_references("RootPOA");
PortableServer::POA_var pPoa =
PortableServer::POA::_narrow(pPoaObj.in());
PortableServer::POAManager_var pMgr = pPoa->the_POAManager();
pMgr->activate();
std::string sIOR;
ifstream iorFile("test.ior");
getline(iorFile, sIOR);
iorFile.close();
cout << "Server IOR = " << sIOR << endl;
CORBA::Object_var pChannelObj = pOrb-
>string_to_object(sIOR.c_str());
CosNotifyChannelAdmin::EventChannel_var pChannel =
CosNotifyChannelAdmin::EventChannel::_narrow(pChannelObj.in());
TestSupplier supplier;
PortableServer::ObjectId_var pSupplierID = pPoa-
>activate_object(&supplier);
CORBA::Object_var pSupplierObj = pPoa-
>id_to_reference(pSupplierID.in());
CosNotifyComm::StructuredPushSupplier_var pSupplier =
CosNotifyComm::StructuredPushSupplier::_narrow(pSupplierObj.in());
CosNotifyChannelAdmin::AdminID supplierAdminID;
CosNotifyChannelAdmin::ProxyID supplierProxyID;
CosNotifyChannelAdmin::SupplierAdmin_var pSupplierAdmin =
pChannel->new_for_suppliers(CosNotifyChannelAdmin::AND_OP,
supplierAdminID);
CosNotifyChannelAdmin::ProxyConsumer_var pProxyConsumer =
pSupplierAdmin->obtain_notification_push_consumer(
CosNotifyChannelAdmin::STRUCTURED_EVENT, supplierProxyID);
CosNotifyChannelAdmin::StructuredProxyPushConsumer_var
pStructuredConsumer =
CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow(pProxyConsumer.in());
pStructuredConsumer-
>connect_structured_push_supplier(pSupplier.in());
cout << "Supplier Ready" << endl;
CosNotification::StructuredEvent event;
event.header.fixed_header.event_type.domain_name =
CORBA::string_dup("DataLinkManager");
event.header.fixed_header.event_type.type_name =
CORBA::string_dup("Attach");
Attach attachMsg;
attachMsg.publisher.pID.ip = CORBA::string_dup("192.168.2.77");
attachMsg.publisher.pID.process_id = 12345;
attachMsg.publisher.pID.instance = 0;
attachMsg.publisher.type = PUB;
attachMsg.publisher.location = LOCAL_SYSTEM;
attachMsg.subscriber.pID.ip = CORBA::string_dup("192.168.2.77");
attachMsg.subscriber.pID.process_id = 12345;
attachMsg.subscriber.pID.instance = 1;
attachMsg.subscriber.type = SUB;
attachMsg.subscriber.location = LOCAL_SYSTEM;
event.remainder_of_body <<= attachMsg;
pStructuredConsumer->push_structured_event(event);
cout << "Message Sent" << endl;
pPoa->destroy(true, true);
pOrb->destroy();
}
catch(const CORBA::Exception& ex)
{
cout << "Exception: " << ex._rep_id() << endl;
return 1;
}
return 0;
}
SAMPLE FIX/WORKAROUND:
Use TAO 1.4 version
Any help would be appreciated. If there's something I can do inside
the Java code to make this work properly that would help a lot.
More information about the Ace-users
mailing list