JAM - examples

Printer-friendly versionPrinter-friendly version
How to use the JAM framework


We can publish a complex message with severity INFO like this:

Publish.infoMessage("message_hello", Publish.createParameter("param_world", "world"));

Complex Messages are backed by any "backend" source, e.g. properties in resource bundles, databases etc. Here "message_hello" is the identifier for the backed message

message_hello=Hello {0}!

and "param_world" is the identifier for a backed parameter and "world" is a fallback String for the case the parameter cannot be resolved or is null.

The automatically choosen topic is here RootTopic.INFO_MESSAGE.

Note: message parameters can be nested (parameters with parameters)! Nested parameters enable us to build really complex message structures without too many redundancies. Think of an engine that generates documents.


To receive messages on the side of the subscribers we have to subscribe a MessageConsumer in the same manner as we did with the TextConsumer before.


Moreover, JAM supports to use boolean expressions as identifier for messages or parameters in the backing resource to match a given value! Imagine we submit as message identifier the value "100" ...

Publish.infoMessage(new LongMessageId(100));

...which is automatically matched to the message from the backing resource...


or maybe something like


...and the message actually published is the text "hundred".


Vice versa, we can also use an object as identifier which represents a value range, e.g. we submit...

Publish.infoMessage(new LongRangeMessageId(2L, 8L));

...which is automatically matched to the messages from the backing resource...


6= world!

...and the message actually published is the concatenated text "Hello world!".


Maybe we have a use case that requires even more power and flexibility and in order to process a message individually we rather want to retrieve the message and then process that message before we publish it or we do anything else with it. JAM let us retrieve messages and values of any type easily, for instance like this:

If we have a property in a resource bundle with a numeric value...


...we retrieve it with a message query as numeric type (here a Long)...