Java BrokerEvent from String

In the Java Broker Client 5.0 (client50.jar), you can convert any BrokerEvent to a human readable form by using BrokerEvent.toString(). Or BrokerEvent.toLocalizedString().

How do you convert the String back to a BrokerEvent object?

There is no easy way to do it. The toString() method is simplay a convenience method and is not normally used for data transformations.

However, you may want to try converting your string to as byte array and then calling BrokerEvent.fromBinData(BrokerClient client, byte data). I haven’t tried it but it seems like a logical start.


Using fromBinData and passing a byte array derived from the String returned by fromString won’t work. The byte array needs to be obtained from toBinData().

In a previous project, for debugging/tracking, I saved each event into two files, both named with the event ID an extension of .txt and .bin. The former held the output of toString while the latter held the output of toBinData.

It would indeed be nice to have a fromString method. EventTracker/DocumentTracker has one (the files that can be exported/imported are human readable strings) but for whatever reason wM has never exposed it.

You can use the from BinData to recreate the event,
and use the toString for the event.
The toBinData byte array can be stored into a database field.
This is the way that the ATC stores the data in 4.1. (probably others too).
We archive 10 days of events for research using this mechanism.