Chapter 18. Polling for events 297
CWConnectorUtil.logMsg(e.getMessage());
e.printStackTrace();
// Update the event status to ERROR_PROCESSING_EVENT
evts.updateEventStatus(
evtObj,
CWConnectorEventStatusConstants
.ERROR_PROCESSING_EVENT);
if (arcProcessed
.equalsIgnoreCase(CWConnectorAttrType.TRUESTRING)) {
// Archive the event in the application’s archive store
evts.archiveEvent(evtObj.getEventID());
// Delete the event from the event store
evts.deleteEvent(evtObj.getEventID());
}
continue;
} catch (AttributeNullValueException e) {
CWConnectorUtil.generateAndLogMsg(
10536,
CWConnectorLogAndTrace.XRD_ERROR,
0,
2,
"getBO",
"AttributeNullValueException");
CWConnectorUtil.logMsg(e.getMessage());
e.printStackTrace();
// Update the event status to ERROR_PROCESSING_EVENT
evts.updateEventStatus(
evtObj,
CWConnectorEventStatusConstants
.ERROR_PROCESSING_EVENT);
if (arcProcessed
.equalsIgnoreCase(CWConnectorAttrType.TRUESTRING)) {
// Archive the event in the application’s archive store
evts.archiveEvent(evtObj.getEventID());
// Delete the event from the event store
evts.deleteEvent(evtObj.getEventID());
}
continue;
}
// Log a fatal error in case the object is not found.
if (evtObj.getStatus()
== CWConnectorEventStatusConstants
.ERROR_OBJECT_NOT_FOUND) {
CWConnectorUtil.generateAndLogMsg(
10543,
CWConnectorLogAndTrace.XRD_FATAL,
0,
0);
298 WebSphere Business Integration Adapters
// Update the event status to ERROR_OBJECT_NOT_FOUND
evts.updateEventStatus(
evtObj,
CWConnectorEventStatusConstants
.ERROR_OBJECT_NOT_FOUND);
if (arcProcessed
.equalsIgnoreCase(CWConnectorAttrType.TRUESTRING)) {
// Archive the event in the application’s archive store
evts.archiveEvent(evtObj.getEventID());
// Delete the event from the event store
evts.deleteEvent(evtObj.getEventID());
}
continue;
}
// In case the business object is null, the retrieve call
// returned an error.
if (bo == null) {
CWConnectorUtil.generateAndLogMsg(
10335,
CWConnectorLogAndTrace.XRD_ERROR,
0,
0);
// Update the event status to ERROR_PROCESSING_EVENT
evts.updateEventStatus(
evtObj,
CWConnectorEventStatusConstants
.ERROR_PROCESSING_EVENT);
if (arcProcessed
.equalsIgnoreCase(CWConnectorAttrType.TRUESTRING)) {
// Archive the event in the application’s archive store
evts.archiveEvent(evtObj.getEventID());
// Delete the event from the event store
evts.deleteEvent(evtObj.getEventID());
}
continue;
}
// Set the processing verb on the business object.
try {
bo.setVerb(evtObj.getVerb());
} catch (InvalidVerbException e) {
CWConnectorUtil.generateAndLogMsg(
10536,
CWConnectorLogAndTrace.XRD_ERROR,
0,
2,
"setVerb",
"InvalidVerbException");
CWConnectorUtil.logMsg(e.getMessage());
e.printStackTrace();
Chapter 18. Polling for events 299
// Update the event status to ERROR_PROCESSING_EVENT
evts.updateEventStatus(
evtObj,
CWConnectorEventStatusConstants
.ERROR_PROCESSING_EVENT);
if (arcProcessed
.equalsIgnoreCase(CWConnectorAttrType.TRUESTRING)) {
// Archive the event in the application’s archive store
evts.archiveEvent(evtObj.getEventID());
// Delete the event from the event store
evts.deleteEvent(evtObj.getEventID());
}
continue;
}
// Check again for subscription.
if (isSubscribed(bo.getName(), bo.getVerb())) {
// Send the event to integration broker.
int stat = gotApplEvent(bo);
if (stat == CWConnectorConstant.CONNECTOR_NOT_ACTIVE) {
CWConnectorUtil.generateAndTraceMsg(
CWConnectorLogAndTrace.LEVEL3,
10551,
CWConnectorLogAndTrace.XRD_INFO,
0,
0);
evts.updateEventStatus(
evtObj,
CWConnectorEventStatusConstants.READY_FOR_ROLL);
// No need to archive the event, as the status is reset
// to READY_FOR_POLL. It is as if this event never
//reached the
// connector for processing.
return CWConnectorConstant.SUCCEED;
}
if (stat
== CWConnectorConstant.NO_SUBSCRIPTION_FOUND) {
CWConnectorUtil.generateAndLogMsg(
10552,
CWConnectorLogAndTrace.XRD_ERROR,
0,
0);
// Update the event status to UNSUBSCRIBED.
evts.updateEventStatus(
evtObj,
CWConnectorEventStatusConstants.UNSUBSCRIBED);
if (arcProcessed
.equalsIgnoreCase(
CWConnectorAttrType.TRUESTRING)) {
// Archive the event in the application’s archive
300 WebSphere Business Integration Adapters
//store
evts.archiveEvent(evtObj.getEventID());
// Delete the event from the event store
evts.deleteEvent(evtObj.getEventID());
}
continue;
}
if (stat == CWConnectorConstant.SUCCEED) {
// Update the event status to SUCCESS.
evts.updateEventStatus(
evtObj,
CWConnectorEventStatusConstants.SUCCESS);
if (arcProcessed
.equalsIgnoreCase(
CWConnectorAttrType.TRUESTRING)) {
// Archive the event in the application’s archive
//store
evts.archiveEvent(evtObj.getEventID());
// Delete the event from the event store
evts.deleteEvent(evtObj.getEventID());
}
continue;
} else // gotApplEvent returned FAIL
{
CWConnectorUtil.generateAndLogMsg(
10532,
CWConnectorLogAndTrace.XRD_ERROR,
0,
0);
// Update the event status to ERROR_POSTING_EVENT.
evts.updateEventStatus(
evtObj,
CWConnectorEventStatusConstants
.ERROR_POSTING_EVENT);
// Archive the event if ArchiveProcessed is set
// to true.
if (arcProcessed
.equalsIgnoreCase(
CWConnectorAttrType.TRUESTRING)) {
// Archive the event in the application’s
// archive store.
evts.archiveEvent(evtObj.getEventID());
// Delete the event from the event store.
evts.deleteEvent(evtObj.getEventID());
}
return CWConnectorConstant.FAIL;
}
} else // Event unsubscribed.
{
Chapter 18. Polling for events 301
CWConnectorUtil.generateAndLogMsg(
10552,
CWConnectorLogAndTrace.XRD_ERROR,
0,
0);
// Update the event status to UNSUBSCRIBED.
evts.updateEventStatus(
evtObj,
CWConnectorEventStatusConstants.UNSUBSCRIBED);
// Archive the event if ArchiveProcessed is set
// to true.
if (arcProcessed
.equalsIgnoreCase(CWConnectorAttrType.TRUESTRING)) {
// Archive the event in the application’s
// archive store.
evts.archiveEvent(evtObj.getEventID());
// Delete the event from the event store.
evts.deleteEvent(evtObj.getEventID());
}
continue;
}
} else {
CWConnectorUtil.generateAndLogMsg(
10552,
CWConnectorLogAndTrace.XRD_ERROR,
0,
0);
// Update the event status to UNSUBSCRIBED.
evts.updateEventStatus(
evtObj,
CWConnectorEventStatusConstants.UNSUBSCRIBED);
// Archive the event if ArchiveProcessed is set
// to true.
if (arcProcessed
.equalsIgnoreCase(CWConnectorAttrType.TRUESTRING)) {
// Archive the event in the application’s
// archive store. evts.archiveEvent(evtObj.getEventID());
// Delete the event from the event store.
evts.deleteEvent(evtObj.getEventID());
}
continue;
}
} //For loop
}
} catch (StatusChangeFailedException e) {
CWConnectorUtil.generateAndLogMsg(
10536,
CWConnectorLogAndTrace.XRD_ERROR,
0,

Get WebSphere Business Integration Adapters: An Adapter Development and WebSphere Business Integration Solution now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.