本文整理匯總了Java中org.kuali.rice.kcb.bo.MessageDeliveryStatus類的典型用法代碼示例。如果您正苦於以下問題:Java MessageDeliveryStatus類的具體用法?Java MessageDeliveryStatus怎麽用?Java MessageDeliveryStatus使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MessageDeliveryStatus類屬於org.kuali.rice.kcb.bo包,在下文中一共展示了MessageDeliveryStatus類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: lockAndTakeMessageDeliveries
import org.kuali.rice.kcb.bo.MessageDeliveryStatus; //導入依賴的package包/類
public Collection<MessageDelivery> lockAndTakeMessageDeliveries(Long messageId, MessageDeliveryStatus[] statuses) {
LOG.debug("========>> ENTERING LockAndTakeMessageDeliveries: " + Thread.currentThread());
// DO WITHIN TRANSACTION: get all untaken messagedeliveries, and mark as "taken" so no other thread/job takes them
// need to think about durability of work list
QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create();
List<Predicate> predicates = new ArrayList<Predicate>();
predicates.add(isNull(MessageDelivery.LOCKED_DATE));
if (messageId != null) {
predicates.add(equal(MessageDelivery.MESSAGEID_FIELD + ".id", messageId));
}
predicates.add(lessThan(MessageDelivery.PROCESS_COUNT, maxProcessAttempts));
Collection<String> statusCollection = new ArrayList<String>(statuses.length);
for (MessageDeliveryStatus status: statuses) {
statusCollection.add(status.name());
}
predicates.add(in(MessageDelivery.DELIVERY_STATUS, statusCollection));
criteria.setPredicates(predicates.toArray(new Predicate[predicates.size()]));
List<MessageDelivery> messageDeliveries = dataObjectService.findMatching(MessageDelivery.class, criteria.build()).getResults();
List<MessageDelivery> lockedMsgDels = new ArrayList<MessageDelivery>();
// mark messageDeliveries as taken
for (MessageDelivery delivery: messageDeliveries) {
LOG.debug("Took: " + delivery);
delivery.setLockedDate(new Timestamp(System.currentTimeMillis()));
delivery = dataObjectService.save(delivery);
lockedMsgDels.add(delivery);
}
LOG.debug("<<======= LEAVING LockAndTakeMessageDeliveries: " + Thread.currentThread());
return lockedMsgDels;
}
示例2: takeAvailableWorkItems
import org.kuali.rice.kcb.bo.MessageDeliveryStatus; //導入依賴的package包/類
@Override
protected Collection<MessageDelivery> takeAvailableWorkItems() {
MessageDeliveryStatus[] statuses;
switch (mode) {
case DELIVER: {
statuses = new MessageDeliveryStatus[] { MessageDeliveryStatus.UNDELIVERED };
break;
}
case REMOVE: {
if (messageId == null) {
throw new IllegalStateException("Message id must be specified for message removal mode");
}
statuses = new MessageDeliveryStatus[] { MessageDeliveryStatus.DELIVERED, MessageDeliveryStatus.UNDELIVERED };
break;
}
default:
throw new RuntimeException("Invalid mode: " + mode);
}
for (MessageDeliveryStatus status: statuses) {
LOG.debug("Taking message deliveries with status: " + status);
}
Collection<MessageDelivery> ds = messageDeliveryService.lockAndTakeMessageDeliveries(messageId, statuses);
LOG.debug("Took " + ds.size() + " deliveries");
for (MessageDelivery md: ds) {
LOG.debug(md);
md.setProcessCount(md.getProcessCount().intValue() + 1);
}
return ds;
}
示例3: process
import org.kuali.rice.kcb.bo.MessageDeliveryStatus; //導入依賴的package包/類
/**
* Implements delivery of a single MessageDelivery
* @param messageDeliverer the deliverer
* @param messageDelivery the delivery
* @return collection of strings indicating successful deliveries
*/
protected Collection<MessageDelivery> process(MessageDeliverer messageDeliverer, MessageDelivery messageDelivery, Mode mode) {
// we have our message deliverer, so tell it to deliver the message
try {
if (mode == Mode.DELIVER) {
messageDeliverer.deliver(messageDelivery);
// if processing was successful, set the count back to zero
messageDelivery.setProcessCount(Integer.valueOf(0));
// by definition we have succeeded at this point if no exception was thrown by the messageDeliverer
// so update the status of the delivery message instance to DELIVERED (and unmark as taken)
// and persist
updateStatusAndUnlock(messageDelivery, mode == Mode.DELIVER ? MessageDeliveryStatus.DELIVERED : MessageDeliveryStatus.REMOVED);
} else {
messageDeliverer.dismiss(messageDelivery, user, cause);
// don't need to set the processing count down to zero because we are just deleting the record entirely
messageDeliveryService.deleteMessageDelivery(messageDelivery);
}
} catch (MessageDeliveryProcessingException nmde) {
LOG.error("Error processing message delivery " + messageDelivery, nmde);
throw new RuntimeException(nmde);
}
LOG.debug("Message delivery '" + messageDelivery.getId() + "' for message '" + messageDelivery.getMessage().getId() + "' was successfully processed.");
//PerformanceLog.logDuration("Time to dispatch notification delivery for notification " + messageDelivery.getMessage().getId(), System.currentTimeMillis() - messageDelivery.getNotification().getSendDateTime().getTime());
List<MessageDelivery> success = new ArrayList<MessageDelivery>(1);
success.add(messageDelivery);
return success;
}
示例4: bulkProcess
import org.kuali.rice.kcb.bo.MessageDeliveryStatus; //導入依賴的package包/類
/**
* Implements bulk delivery of a collection of {@link MessageDelivery}s
* @param messageDeliverer the deliverer
* @param messageDeliveries the deliveries
* @return collection of strings indicating successful deliveries
*/
protected Collection<MessageDelivery> bulkProcess(BulkMessageDeliverer messageDeliverer, Collection<MessageDelivery> messageDeliveries, Mode mode) {
MessageDeliveryStatus targetStatus = (mode == Mode.DELIVER ? MessageDeliveryStatus.DELIVERED : MessageDeliveryStatus.REMOVED);
// we have our message deliverer, so tell it to deliver the message
try {
if (mode == Mode.DELIVER) {
messageDeliverer.bulkDeliver(messageDeliveries);
} else {
messageDeliverer.bulkDismiss(messageDeliveries);
}
} catch (MessageDeliveryProcessingException nmde) {
LOG.error("Error bulk-delivering messages " + messageDeliveries, nmde);
throw new RuntimeException(nmde);
}
// by definition we have succeeded at this point if no exception was thrown by the messageDeliverer
// so update the status of the delivery message instance to DELIVERED (and unmark as taken)
// and persist
List<MessageDelivery> successes = new ArrayList<MessageDelivery>(messageDeliveries.size());
for (MessageDelivery nmd: messageDeliveries) {
successes.add(nmd);
LOG.debug("Message delivery '" + nmd.getId() + "' for notification '" + nmd.getMessage().getId() + "' was successfully delivered.");
//PerformanceLog.logDuration("Time to dispatch notification delivery for notification " + nmd.getMessage().getId(), System.currentTimeMillis() - nmd.getNotification().getSendDateTime().getTime());
if (mode == Mode.REMOVE) {
messageDeliveryService.deleteMessageDelivery(nmd);
} else {
nmd.setProcessCount(0);
updateStatusAndUnlock(nmd, targetStatus);
}
}
return successes;
}
示例5: updateStatusAndUnlock
import org.kuali.rice.kcb.bo.MessageDeliveryStatus; //導入依賴的package包/類
/**
* Marks a MessageDelivery as having been delivered, and unlocks it
* @param messageDelivery the messageDelivery instance to mark
*/
protected void updateStatusAndUnlock(MessageDelivery messageDelivery, MessageDeliveryStatus status) {
messageDelivery.setDeliveryStatus(status);
// mark as unlocked
messageDelivery.setLockedDate(null);
dataObjectService.save(messageDelivery);
}
示例6: testUpdate
import org.kuali.rice.kcb.bo.MessageDeliveryStatus; //導入依賴的package包/類
@Test
public void testUpdate() {
MessageDelivery m = messageDeliveryService.getMessageDelivery(MESSAGE_DELIV.getId());
m.setDelivererTypeName("eagle");
m.setDeliveryStatus(MessageDeliveryStatus.UNDELIVERED);
m.setDelivererSystemId("1234");
messageDeliveryService.saveMessageDelivery(m);
MessageDelivery m2 = messageDeliveryService.getMessageDelivery(m.getId());
assertNotNull(m2);
assertEqualsMD(m, m2);
}
示例7: lockAndTakeMessageDeliveries
import org.kuali.rice.kcb.bo.MessageDeliveryStatus; //導入依賴的package包/類
public Collection<MessageDelivery> lockAndTakeMessageDeliveries(Long messageId, MessageDeliveryStatus[] statuses) {
LOG.debug("========>> ENTERING LockAndTakeMessageDeliveries: " + Thread.currentThread());
// DO WITHIN TRANSACTION: get all untaken messagedeliveries, and mark as "taken" so no other thread/job takes them
// need to think about durability of work list
// get all undelivered message deliveries
Criteria criteria = new Criteria();
criteria.addIsNull(MessageDelivery.LOCKED_DATE);
if (messageId != null) {
criteria.addEqualTo(MessageDelivery.MESSAGEID_FIELD, messageId);
}
criteria.addLessThan(MessageDelivery.PROCESS_COUNT, maxProcessAttempts);
Collection<String> statusCollection = new ArrayList<String>(statuses.length);
for (MessageDeliveryStatus status: statuses) {
statusCollection.add(status.name());
}
criteria.addIn(MessageDelivery.DELIVERY_STATUS, statusCollection);
// implement our select for update hack
Collection<MessageDelivery> messageDeliveries = dao.findMatching(MessageDelivery.class, criteria, true, RiceConstants.NO_WAIT);
//LOG.debug("Retrieved " + messageDeliveries.size() + " available message deliveries: " + System.currentTimeMillis());
// mark messageDeliveries as taken
for (MessageDelivery delivery: messageDeliveries) {
LOG.debug("Took: " + delivery);
delivery.setLockedDate(new Timestamp(System.currentTimeMillis()));
dao.save(delivery);
}
LOG.debug("<<======= LEAVING LockAndTakeMessageDeliveries: " + Thread.currentThread());
return messageDeliveries;
}
示例8: process
import org.kuali.rice.kcb.bo.MessageDeliveryStatus; //導入依賴的package包/類
/**
* Implements delivery of a single MessageDelivery
* @param deliverer the deliverer
* @param messageDelivery the delivery
* @return collection of strings indicating successful deliveries
*/
protected Collection<MessageDelivery> process(MessageDeliverer messageDeliverer, MessageDelivery messageDelivery, Mode mode) {
// we have our message deliverer, so tell it to deliver the message
try {
if (mode == Mode.DELIVER) {
messageDeliverer.deliver(messageDelivery);
// if processing was successful, set the count back to zero
messageDelivery.setProcessCount(Integer.valueOf(0));
// by definition we have succeeded at this point if no exception was thrown by the messageDeliverer
// so update the status of the delivery message instance to DELIVERED (and unmark as taken)
// and persist
updateStatusAndUnlock(messageDelivery, mode == Mode.DELIVER ? MessageDeliveryStatus.DELIVERED : MessageDeliveryStatus.REMOVED);
} else {
messageDeliverer.dismiss(messageDelivery, user, cause);
// don't need to set the processing count down to zero because we are just deleting the record entirely
messageDeliveryService.deleteMessageDelivery(messageDelivery);
}
} catch (MessageDeliveryProcessingException nmde) {
LOG.error("Error processing message delivery " + messageDelivery, nmde);
throw new RuntimeException(nmde);
}
LOG.debug("Message delivery '" + messageDelivery.getId() + "' for message '" + messageDelivery.getMessage().getId() + "' was successfully processed.");
//PerformanceLog.logDuration("Time to dispatch notification delivery for notification " + messageDelivery.getMessage().getId(), System.currentTimeMillis() - messageDelivery.getNotification().getSendDateTime().getTime());
List<MessageDelivery> success = new ArrayList<MessageDelivery>(1);
success.add(messageDelivery);
return success;
}
示例9: bulkProcess
import org.kuali.rice.kcb.bo.MessageDeliveryStatus; //導入依賴的package包/類
/**
* Implements bulk delivery of a collection of {@link MessageDelivery}s
* @param deliverer the deliverer
* @param messageDeliveries the deliveries
* @return collection of strings indicating successful deliveries
*/
protected Collection<MessageDelivery> bulkProcess(BulkMessageDeliverer messageDeliverer, Collection<MessageDelivery> messageDeliveries, Mode mode) {
MessageDeliveryStatus targetStatus = (mode == Mode.DELIVER ? MessageDeliveryStatus.DELIVERED : MessageDeliveryStatus.REMOVED);
// we have our message deliverer, so tell it to deliver the message
try {
if (mode == Mode.DELIVER) {
messageDeliverer.bulkDeliver(messageDeliveries);
} else {
messageDeliverer.bulkDismiss(messageDeliveries);
}
} catch (MessageDeliveryProcessingException nmde) {
LOG.error("Error bulk-delivering messages " + messageDeliveries, nmde);
throw new RuntimeException(nmde);
}
// by definition we have succeeded at this point if no exception was thrown by the messageDeliverer
// so update the status of the delivery message instance to DELIVERED (and unmark as taken)
// and persist
List<MessageDelivery> successes = new ArrayList<MessageDelivery>(messageDeliveries.size());
for (MessageDelivery nmd: messageDeliveries) {
successes.add(nmd);
LOG.debug("Message delivery '" + nmd.getId() + "' for notification '" + nmd.getMessage().getId() + "' was successfully delivered.");
//PerformanceLog.logDuration("Time to dispatch notification delivery for notification " + nmd.getMessage().getId(), System.currentTimeMillis() - nmd.getNotification().getSendDateTime().getTime());
if (mode == Mode.REMOVE) {
messageDeliveryService.deleteMessageDelivery(nmd);
} else {
nmd.setProcessCount(0);
updateStatusAndUnlock(nmd, targetStatus);
}
}
return successes;
}
示例10: updateStatusAndUnlock
import org.kuali.rice.kcb.bo.MessageDeliveryStatus; //導入依賴的package包/類
/**
* Marks a MessageDelivery as having been delivered, and unlocks it
* @param messageDelivery the messageDelivery instance to mark
*/
protected void updateStatusAndUnlock(MessageDelivery messageDelivery, MessageDeliveryStatus status) {
messageDelivery.setDeliveryStatus(status);
// mark as unlocked
messageDelivery.setLockedDate(null);
dao.save(messageDelivery);
}
示例11: testUpdate
import org.kuali.rice.kcb.bo.MessageDeliveryStatus; //導入依賴的package包/類
@Test
@Override
public void testUpdate() {
MessageDelivery m = messageDeliveryService.getMessageDelivery(MESSAGE_DELIV.getId());
m.setDelivererTypeName("eagle");
m.setDeliveryStatus(MessageDeliveryStatus.UNDELIVERED);
m.setDelivererSystemId("1234");
messageDeliveryService.saveMessageDelivery(m);
MessageDelivery m2 = messageDeliveryService.getMessageDelivery(m.getId());
assertNotNull(m2);
assertEqualsMD(m, m2);
}
示例12: lockAndTakeMessageDeliveries
import org.kuali.rice.kcb.bo.MessageDeliveryStatus; //導入依賴的package包/類
/**
* Locks and takes all message deliveries of a given message in the system with any of the specified statuses
* @param messageId the id of the message whose deliveries to take
* @param status the statuses of message deliveries to take
* @return a collection of message deliveries
*/
public Collection<MessageDelivery> lockAndTakeMessageDeliveries(Long messageId, MessageDeliveryStatus[] status);