Class EsbEventCodec
java.lang.Object
com.kingsrook.qqq.esb.envelope.EsbEventCodec
Reads and writes EsbEvents as CloudEvents 1.0 structured JSON (spec section
4), and as JMS TextMessages.
Written JSON always has specversion "1.0" and datacontenttype
"application/json"; subject, time, qqqcausationid (the causation id, as a
CloudEvent extension attribute) and data are left out when null. Values
inside data are written as they are, nulls included; Instants and other
java.time values are written as ISO-8601 strings.
Reading accepts any CloudEvents 1.0 JSON event whose data (if any) is a JSON
object; other attributes are ignored. Decimal numbers in data are read as
BigDecimal, so they keep their exact value. Anything else throws
EsbUnparseableMessageException.
Uses one shared, thread-safe Jackson mapper, because building one per message
is slow for bulk publishes.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String//////////////////////////////////////////////////////////static final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic EsbEventRead an event from CloudEvents 1.0 structured JSON.static EsbEventfromMessage(jakarta.jms.Message message) Read an event from a JMS message.static StringWrite an event as CloudEvents 1.0 structured JSON.static jakarta.jms.TextMessageMake a JMS TextMessage holding the event's JSON, with the ce_id, ce_type, and ce_source properties set.
-
Field Details
-
SPEC_VERSION
- See Also:
-
DATA_CONTENT_TYPE
- See Also:
-
ATTRIBUTE_SPEC_VERSION
- See Also:
-
ATTRIBUTE_ID
- See Also:
-
ATTRIBUTE_SOURCE
- See Also:
-
ATTRIBUTE_TYPE
- See Also:
-
ATTRIBUTE_SUBJECT
- See Also:
-
ATTRIBUTE_TIME
- See Also:
-
ATTRIBUTE_DATA_CONTENT_TYPE
- See Also:
-
ATTRIBUTE_CAUSATION_ID
- See Also:
-
ATTRIBUTE_DATA
- See Also:
-
ATTRIBUTE_DATA_BASE64
- See Also:
-
PROPERTY_ID
//////////////////////////////////////////////////////////- See Also:
-
PROPERTY_TYPE
- See Also:
-
PROPERTY_SOURCE
- See Also:
-
-
Constructor Details
-
EsbEventCodec
public EsbEventCodec()
-
-
Method Details
-
toJson
-
fromJson
Read an event from CloudEvents 1.0 structured JSON.- Throws:
EsbUnparseableMessageException
-
toMessage
public static jakarta.jms.TextMessage toMessage(jakarta.jms.Session session, EsbEvent event) throws jakarta.jms.JMSException Make a JMS TextMessage holding the event's JSON, with the ce_id, ce_type, and ce_source properties set.- Throws:
jakarta.jms.JMSException
-
fromMessage
public static EsbEvent fromMessage(jakarta.jms.Message message) throws jakarta.jms.JMSException, EsbUnparseableMessageException Read an event from a JMS message. Only TextMessages hold events. Throws JMSException if the broker client can't read the message, and EsbUnparseableMessageException if the message isn't an event.- Throws:
jakarta.jms.JMSExceptionEsbUnparseableMessageException
-