Using struct fields in Broker Documents from Java Client

Thanks for listening. seems as soon as I post I find my own answer

stEvent = new BrokerEvent(null,"wm::is::Samples::SampleStruct)

<doh>

Now I can publish the document, but if I look at the data in the pipeline the data is not (IMO) correct
Pipleine in WmMonitor show ???
save Pipeline from Flow Service shows high-ascii data
Not my simple strings.

eventtype wm::is::Samples::StructDoc
{ unicode_string name;
struct
{ unicode_string element01;
unicode_string element02;
unicode_string element03; }
sampStruct; }
[…]
try
{
event.setStringField(“name”,“Name is Paul”);
stEvent.setStringField(“element01”,“Name is Paul”);
stEvent.setStringField(“element02”,“e02Val”);
stEvent.setStringField(“element03”,“e03Val”);
event.setStructFieldFromEvent(“sampStruct”,stEvent);
}
[…]

see attachment for pipeline

pipeline file
structdoc.xml (2.3 k)

I put some output into the client
to getStructFieldAsEvent on the sampStruct I just built.
and I can get it back populated
System.out.println("sampStruct is "+event.getStructFieldAsEvent(“sampStruct”));

[…]
sampStruct is

event struct_value {
string element01 = “e01Val”;
string element02 = “e02Val”;
string element03 = “e03Val”;
};
[…]

Why cannot I not see this in the pipeline?

Got it.
Attached please find a sample java BrokerClient for a simple structured document and a java class to store the object.

brokerclientrequest.java
BrokerClientRequest.java (3.2 k)

sampStruct.java
sampStruct.java (0.8 k)

Paul great job. thank you for posting the answer to your own question.
just want to say
while ()
{
thank you
}

Hi Paul
I’ve been trying to reproduce what you’ve done here on a concrete example.
But, in my case, “sampStruct” is a Struct array (Struct).
Furthermore, my IS document “sampStruct” has not been declared as publishable onto the broker.

So in my case, the line
“stEvent = new BrokerEvent(null,”<any>",sampleMsgToPublish);" doesn’t seem to work out since “<any>” is not a valid reference to a document type declared on the broker.

I guess I have to make my doc “sampStruct” publishable in order to make it work correctly. I’ll try out …

Well, I’ve declared the sub-document as publishable (hopefully, it was a separate document and now it works fine.
So “<any>” can’t be “anything” like I thought, but a valid reference to a a declared doc onto the broker.
This is obvious because what if you want to fill in a document in a main document (that is, a sub-document), knowing that this subdocument is not a separate document? I guess you can’t …