/** * Extracts a {@link DeadlineMessage} from provided {@code jobDataMap}. * * <b>Note</b> that this function is able to retrieve two different formats of DeadlineMessage. The first being * a now deprecated solution which used to serialized the entire {@link DeadlineMessage} into the * {@link JobDataMap}. This is only kept for backwards compatibility. The second is the new solution which * stores all the required deadline fields separately, only de-/serializing the payload and metadata of a * DeadlineMessage instead of the entire message. * * @param serializer the {@link Serializer} used to deserialize the contents of the given {@code} jobDataMap} * into a {@link DeadlineMessage} * @param jobDataMap the {@link JobDataMap} which should contain a {@link DeadlineMessage} * @return the {@link DeadlineMessage} pulled from the {@code jobDataMap} */ public static DeadlineMessage deadlineMessage(Serializer serializer, JobDataMap jobDataMap) { if (jobDataMap.containsKey(SERIALIZED_DEADLINE_MESSAGE)) { SimpleSerializedObject<byte[]> serializedDeadlineMessage = new SimpleSerializedObject<>( (byte[]) jobDataMap.get(SERIALIZED_DEADLINE_MESSAGE), byte[].class, (String) jobDataMap.get(SERIALIZED_DEADLINE_MESSAGE_CLASS_NAME), null ); return serializer.deserialize(serializedDeadlineMessage); } return new GenericDeadlineMessage<>((String) jobDataMap.get(DEADLINE_NAME), (String) jobDataMap.get(MESSAGE_ID), deserializeDeadlinePayload(serializer, jobDataMap), deserializeDeadlineMetaData(serializer, jobDataMap), retrieveDeadlineTimestamp(jobDataMap)); }
/** * Extracts a {@link DeadlineMessage} from provided {@code jobDataMap}. * * <b>Note</b> that this function is able to retrieve two different formats of DeadlineMessage. The first being * a now deprecated solution which used to serialized the entire {@link DeadlineMessage} into the * {@link JobDataMap}. This is only kept for backwards compatibility. The second is the new solution which * stores all the required deadline fields separately, only de-/serializing the payload and metadata of a * DeadlineMessage instead of the entire message. * * @param serializer the {@link Serializer} used to deserialize the contents of the given {@code} jobDataMap} * into a {@link DeadlineMessage} * @param jobDataMap the {@link JobDataMap} which should contain a {@link DeadlineMessage} * @return the {@link DeadlineMessage} pulled from the {@code jobDataMap} */ public static DeadlineMessage deadlineMessage(Serializer serializer, JobDataMap jobDataMap) { if (jobDataMap.containsKey(SERIALIZED_DEADLINE_MESSAGE)) { SimpleSerializedObject<byte[]> serializedDeadlineMessage = new SimpleSerializedObject<>( (byte[]) jobDataMap.get(SERIALIZED_DEADLINE_MESSAGE), byte[].class, (String) jobDataMap.get(SERIALIZED_DEADLINE_MESSAGE_CLASS_NAME), null ); return serializer.deserialize(serializedDeadlineMessage); } return new GenericDeadlineMessage<>((String) jobDataMap.get(DEADLINE_NAME), (String) jobDataMap.get(MESSAGE_ID), deserializeDeadlinePayload(serializer, jobDataMap), deserializeDeadlineMetaData(serializer, jobDataMap), retrieveDeadlineTimestamp(jobDataMap)); }
/** * Extracts a {@link DeadlineMessage} from provided {@code jobDataMap}. * * <b>Note</b> that this function is able to retrieve two different formats of DeadlineMessage. The first being * a now deprecated solution which used to serialized the entire {@link DeadlineMessage} into the * {@link JobDataMap}. This is only kept for backwards compatibility. The second is the new solution which * stores all the required deadline fields separately, only de-/serializing the payload and metadata of a * DeadlineMessage instead of the entire message. * * @param serializer the {@link Serializer} used to deserialize the contents of the given {@code} jobDataMap} * into a {@link DeadlineMessage} * @param jobDataMap the {@link JobDataMap} which should contain a {@link DeadlineMessage} * @return the {@link DeadlineMessage} pulled from the {@code jobDataMap} */ public static DeadlineMessage deadlineMessage(Serializer serializer, JobDataMap jobDataMap) { if (jobDataMap.containsKey(SERIALIZED_DEADLINE_MESSAGE)) { SimpleSerializedObject<byte[]> serializedDeadlineMessage = new SimpleSerializedObject<>( (byte[]) jobDataMap.get(SERIALIZED_DEADLINE_MESSAGE), byte[].class, (String) jobDataMap.get(SERIALIZED_DEADLINE_MESSAGE_CLASS_NAME), null ); return serializer.deserialize(serializedDeadlineMessage); } return new GenericDeadlineMessage<>((String) jobDataMap.get(DEADLINE_NAME), (String) jobDataMap.get(MESSAGE_ID), deserializeDeadlinePayload(serializer, jobDataMap), deserializeDeadlineMetaData(serializer, jobDataMap), retrieveDeadlineTimestamp(jobDataMap)); }