0 votes
1.0k views
by (240 points)
Message is coming From Message Queue.

1 Answer

0 votes
by (30.6k points)

A message with only headers and an empty body is a normal message; the UCA / inbound integration still fires, the payload simply is empty. Two things to handle:

  1. Make the UCA robust: in the UCA's service (the one invoked by the JMS / MQ inbound event) treat an empty body as a valid case - use the header values as the business key:
// UCA service: input tw.local.message (String, the body) and tw.local.headers (NameValuePair list on BAW 20+ event message with headers; older: the "event" String)
var body = (tw.local.message || "").trim();
if (body === "") {
  // header-only message: take the key from the JMS properties
  var key = null;
  for (var i = 0; i < tw.local.headers.listLength; i++) if (tw.local.headers[i].name === "orderId") key = tw.local.headers[i].value;
  if (key == null) throw new Error("Empty message without orderId header - ignored");
  tw.local.orderId = key; tw.local.payload = null;
} else {
  var parsed = JSON.parse(body); tw.local.orderId = parsed.orderId; tw.local.payload = parsed;
}
  1. Correlate on the header, not the body: the UCA's correlation key (the value that matches the waiting intermediate message event or the start event) can be mapped from any output of the UCA service - map tw.local.orderId to the correlation parameter; the BPD's message event correlates on its own variable (tw.local.orderId == key).

If the messages come through the JMS / MQ inbound integration of BAW (Message Driven Bean > event manager), the JMS properties are available as the eventmsg attributes for JMS messages that BAW itself formats; for foreign messages use a Java integration reading javax.jms.Message.getStringProperty(...) in a small MDB / Java listener, or put a message flow (IIB / ACE) in front that copies headers into the body - the common enterprise pattern.

References

Related questions

+1 vote
1 answer 1.3k views
0 votes
1 answer 2.6k views

723 questions

807 answers

98 comments

4.9k users

Join BPM Community Discord Channel

Welcome to BPM Tips Q&A, Community wiki/forum where you can ask questions and receive answers from other IBM BPM experts and members of the community. Users with 2000 points will automatically be promoted to expert level.
Created by Dosvak LLC
Our Youtube Channel
...