NotificationListener getEventBody is null

Hello all

I'm implementing notification handler and event body values are null.

notificationHandler = new NotificationHandler();
BusinessUnitListing buList = apiInstance.getWorkforcemanagementBusinessunitsDivisionviews(Arrays.asList());
Iterator<BusinessUnitListItem> buListItems = buList.getEntities().iterator();
while(buListItems.hasNext()) {
	BusinessUnitListItem buLi = buListItems.next();
	notificationHandler.addSubscription(new AgentScheduleListener(buLi.getId()));
}
notificationHandler.connect(true);

and Listener code:

public class AgentScheduleListener implements NotificationListener<WfmAgentScheduleUpdateTopicWfmAgentScheduleUpdateNotification> {

	private String buId;
	public AgentScheduleListener(String businessUnitId) {
		buId = businessUnitId;
	}
	
	@Override
	public String getTopic() {
		return "v2.workforcemanagement.businessunits." + buId + ".schedules";
	}

	@Override
	public Class<?> getEventBodyClass() {
		return WfmAgentScheduleUpdateTopicWfmAgentScheduleUpdateNotification.class;
	}

	@Override
	public void onEvent(NotificationEvent<?> event) {
		log.debug("onEvent Topic=[{}] getEventBodyRaw={} getEventBody={}", getTopic(), event.getEventBodyRaw(), event.getEventBody().toString());
		WfmAgentScheduleUpdateTopicWfmAgentScheduleUpdateNotification ev = (WfmAgentScheduleUpdateTopicWfmAgentScheduleUpdateNotification)event.getEventBody();
	}
}

the log shows following:

2020-07-31 12:29:42.522 DEBUG 21964 --- [ ReadingThread] c.e.b.s.n.l.AgentScheduleListener : onEvent Topic=[v2.workforcemanagement.businessunits.c91f6138-209b-4321-bc3e-8c1b7afb9029.schedules] getEventBodyRaw={"topicName":"v2.workforcemanagement.businessunits.c91f6138-209b-4321-bc3e-8c1b7afb9029.schedules","version":"2","eventBody":{"status":"Complete","operationId":"734b1d51-81af-479b-a285-1f308ae5654c","eventType":"Update","result":{"id":"297bbf5e-6e7d-4692-b615-a99647f117bb","weekDate":"2020-07-27","weekCount":1,"description":"","published":true,"managementUnits":[{"managementUnit":{"id":"7d181473-f327-4bb1-a84e-03b61e7ab1e4"},"startDate":"2020-07-26T22:00:00.000Z","endDate":"2020-07-31T15:00:00.000Z","agents":[{"id":"e0c6139e-e87f-44d0-84b9-e652aebecbad"}],"agentCount":1}],"metadata":{"version":2,"modifiedBy":{"id":"09c2ffa0-47ed-4345-a4d5-2a26f7fd48c8"},"dateModified":"2020-07-31T10:29:40.968Z"}}},"metadata":{"CorrelationId":"ce4ce1c8-5c8a-47e4-982a-c1d832f7b38a"}} getEventBody=class WfmAgentScheduleUpdateTopicWfmAgentScheduleUpdateNotification {
user: null
startDate: null
endDate: null
shifts: []
fullDayTimeOffMarkers: []
updates: []
}

The WfmAgentScheduleUpdateTopicWfmAgentScheduleUpdateNotification contains all null values.

Am I doing something wrong?
Thank you
Robert

Hello

I think, I found an root cause of null content of event body.
It is because I do use wrong type "WfmAgentScheduleUpdateTopicWfmAgentScheduleUpdateNotification" to handle wfm notification event.

based on documentation and my analyses, it should be "WfmBuScheduleTopicBuScheduleNotification" because this one is matching the event structure explained in documentation.
Is there any documentation, where I can find mapping of [topics] (https://developer.mypurecloud.com/api/rest/v2/notifications/available_topics.html) to Java Classes to be used in notification handler or vice-versa?

But after changing my code to:

public void onEvent(NotificationEvent<?> event) {
		log.debug("onEvent Topic=[{}] getEventBodyRaw={} getEventBody={}", getTopic(), event.getEventBodyRaw(), event.getEventBody().toString());
		WfmBuScheduleTopicBuScheduleNotification ev = (WfmBuScheduleTopicBuScheduleNotification)event.getEventBody();
	}

I'm getting an error:

2020-08-04 09:24:28.372 ERROR 12244 --- [ ReadingThread] c.m.s.v.e.n.NotificationHandler : Cannot construct instance of com.mypurecloud.sdk.v2.model.WfmBuScheduleTopicLocalDate (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('2020-07-27')
at [Source: (String)"{"topicName":"v2.workforcemanagement.businessunits.c91f6138-209b-4321-bc3e-8c1b7afb9029.schedules","version":"2","eventBody":{"status":"Complete","operationId":"cf5213e9-ef42-4920-8ca7-c7a01342b699","eventType":"Update","result":{"id":"297bbf5e-6e7d-4692-b615-a99647f117bb","weekDate":"2020-07-27","weekCount":1,"description":"","published":true,"managementUnits":[{"managementUnit":{"id":"7d181473-f327-4bb1-a84e-03b61e7ab1e4"},"startDate":"2020-07-26T22:00:00.000Z","endDate":"2020-07-31T15:00:00.0"[truncated 275 chars]; line: 1, column: 286] (through reference chain:

It seems to be failing on deserialization of weekDate. Any ideas?
I did update to latest API version 98.0.0 and same issue occurred.

Thank you
Robert

yep. https://github.com/MyPureCloud/platform-client-sdk-java/blob/master/notificationMappings.json

It appears this is an issue with the documented schemas for the notification topics. The v2.users.{id}.workforcemanagement.schedules topic's schema describes the weekDate property as a custom type urn:jsonschema:wfm:bu:schedule:topic:LocalDate, which is an object with its own properties. This is incorrect because the value that's sent in the notification is in fact a string, not a complex object as the schema describes. This causes deserialization to fail. The notification's schema will have to be updated to reflect the correct type.

Please open a case with Genesys Cloud Care to report this problem with the schema; reporting via Care comes with SLAs and various contractual commitments that the forum doesn't. I would suggest copying my above paragraph into the case to help guide the engineer to the cause of the problem.

Hello Tim

Thank you. I'll ask colleagues to open ticket.

br
Robert

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.