本文整理汇总了Java中akka.actor.DeadLetter类的典型用法代码示例。如果您正苦于以下问题:Java DeadLetter类的具体用法?Java DeadLetter怎么用?Java DeadLetter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeadLetter类属于akka.actor包,在下文中一共展示了DeadLetter类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onReceive
import akka.actor.DeadLetter; //导入依赖的package包/类
@Override
public void onReceive(Object message) {
if (message instanceof DeadLetter) {
Object innerMessage = ((DeadLetter) message).message();
logger.warn(".onReceive: encountered dead letter: {}", innerMessage);
if (innerMessage instanceof RegisterWorker){
logger.error("worker could not register to supervisor, shutting down");
BatchApplication.exit();
}
}
}
开发者ID:nationalarchives,项目名称:taxonomy,代码行数:12,代码来源:DeadLetterActor.java
示例2: createReceive
import akka.actor.DeadLetter; //导入依赖的package包/类
@Override
public Receive createReceive() {
return ReceiveBuilder.create().match(DeadLetter.class, msg -> {
System.out.println(msg);
}).matchAny(msg -> {
System.out.println(msg);
}).build();
}
开发者ID:zerosoft,项目名称:CodeBroker,代码行数:9,代码来源:CodeDeadLetter.java
示例3: testDataChangedWithNoSender
import akka.actor.DeadLetter; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testDataChangedWithNoSender() {
new JavaTestKit(getSystem()) {
{
final AsyncDataChangeEvent mockChangeEvent = Mockito.mock(AsyncDataChangeEvent.class);
final AsyncDataChangeListener mockListener = Mockito.mock(AsyncDataChangeListener.class);
final Props props = DataChangeListener.props(mockListener, TEST_PATH);
final ActorRef subject = getSystem().actorOf(props, "testDataChangedWithNoSender");
getSystem().eventStream().subscribe(getRef(), DeadLetter.class);
subject.tell(new DataChanged(mockChangeEvent), ActorRef.noSender());
// Make sure no DataChangedReply is sent to DeadLetters.
while (true) {
DeadLetter deadLetter;
try {
deadLetter = expectMsgClass(duration("1 seconds"), DeadLetter.class);
} catch (AssertionError e) {
// Timed out - got no DeadLetter - this is good
break;
}
// We may get DeadLetters for other messages we don't care
// about.
Assert.assertFalse("Unexpected DataChangedReply", deadLetter.message() instanceof DataChangedReply);
}
}
};
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:32,代码来源:DataChangeListenerTest.java
示例4: testDataChangedWithNoSender
import akka.actor.DeadLetter; //导入依赖的package包/类
@Test
public void testDataChangedWithNoSender() {
new JavaTestKit(getSystem()) {
{
final DataTreeCandidate mockTreeCandidate = Mockito.mock(DataTreeCandidate.class);
final ImmutableList<DataTreeCandidate> mockCandidates = ImmutableList.of(mockTreeCandidate);
final DOMDataTreeChangeListener mockListener = Mockito.mock(DOMDataTreeChangeListener.class);
final Props props = DataTreeChangeListenerActor.props(mockListener, TEST_PATH);
final ActorRef subject = getSystem().actorOf(props, "testDataTreeChangedWithNoSender");
getSystem().eventStream().subscribe(getRef(), DeadLetter.class);
subject.tell(new DataTreeChanged(mockCandidates), ActorRef.noSender());
// Make sure no DataChangedReply is sent to DeadLetters.
while (true) {
DeadLetter deadLetter;
try {
deadLetter = expectMsgClass(duration("1 seconds"), DeadLetter.class);
} catch (AssertionError e) {
// Timed out - got no DeadLetter - this is good
break;
}
// We may get DeadLetters for other messages we don't care
// about.
Assert.assertFalse("Unexpected DataTreeChangedReply",
deadLetter.message() instanceof DataTreeChangedReply);
}
}
};
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:33,代码来源:DataTreeChangeListenerActorTest.java
示例5: shouldSendMsgToDeadLetterWhenQueueIsFull
import akka.actor.DeadLetter; //导入依赖的package包/类
@Test
public void shouldSendMsgToDeadLetterWhenQueueIsFull() throws InterruptedException {
final JavaTestKit mockReceiver = new JavaTestKit(actorSystem);
actorSystem.eventStream().subscribe(mockReceiver.getRef(), DeadLetter.class);
final FiniteDuration twentySeconds = new FiniteDuration(20, TimeUnit.SECONDS);
ActorRef pingPongActor = actorSystem.actorOf(PingPongActor.props(lock).withMailbox(config.getMailBoxName()),
"pingpongactor");
actorSystem.mailboxes().settings();
lock.lock();
try {
//queue capacity = 10
//need to send 12 messages; 1 message is dequeued and actor waits on lock,
//2nd to 11th messages are put on the queue
//12th message is sent to dead letter.
for (int i = 0; i < 12; i++) {
pingPongActor.tell("ping", mockReceiver.getRef());
}
mockReceiver.expectMsgClass(twentySeconds, DeadLetter.class);
} finally {
lock.unlock();
}
mockReceiver.receiveN(11, twentySeconds);
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:29,代码来源:MeteredBoundedMailboxTest.java
示例6: DeadLetterActor
import akka.actor.DeadLetter; //导入依赖的package包/类
public DeadLetterActor() {
receive(ReceiveBuilder.match(DeadLetter.class, msg -> {
LOGGER.warn("Following message fail to be distributed from {} to {} : {}", msg.sender().path(), msg.recipient().path(), msg.message().toString());
}).build());
}
开发者ID:kodokojo,项目名称:kodokojo,代码行数:6,代码来源:DeadLetterActor.java
示例7: onReceive
import akka.actor.DeadLetter; //导入依赖的package包/类
@Override
public void onReceive(Object message) throws Exception {
if (message instanceof DeadLetter) {
DeadLetter deadLetter = (DeadLetter) message;
writeDeadLetterToFile(deadLetter);
} else {
String className = message != null ? message.getClass().getName() : "NULL";
String value = message != null ? message.toString() : "NULL";
log.error(String.format("Message sent to DeadLetter but it is not one (Class: %s, Value: %s)", className, value));
}
}
开发者ID:theAgileFactory,项目名称:app-framework,代码行数:12,代码来源:DeadLetterManager.java
示例8: writeDeadLetterToFile
import akka.actor.DeadLetter; //导入依赖的package包/类
/**
* Write the dead letters to the file system
*
* @param deadLetter
* a dead letter
*/
private void writeDeadLetterToFile(DeadLetter deadLetter) {
String fileName = String.format(OUTPUT_FILE_NAME_TEMPLATE, deadLetter.recipient().path().name(), new Date(), ".log");
BufferedWriter bWriter = null;
try {
bWriter = new BufferedWriter(new FileWriter(new File(getDeadLetterFileSystem(), fileName)));
// Serialize the message as XML
ByteArrayOutputStream baOut = new ByteArrayOutputStream();
XMLEncoder encoder = new XMLEncoder(baOut);
if (deadLetter.message() != null) {
encoder.writeObject(deadLetter.message());
}
encoder.flush();
encoder.close();
// Write it to a file
// First line is actor path
bWriter.write(deadLetter.recipient().path().toString());
bWriter.newLine();
// Then write the message
bWriter.write(baOut.toString());
bWriter.flush();
} catch (Exception e) {
log.error("Error while writing the dead letter info the dead letters folder", e);
} finally {
IOUtils.closeQuietly(bWriter);
}
}
开发者ID:theAgileFactory,项目名称:app-framework,代码行数:33,代码来源:DeadLetterManager.java
示例9: initializeTheDeadLetterActor
import akka.actor.DeadLetter; //导入依赖的package包/类
/**
* Initialize the dead letter actor (which is actually this class)
*
* @throws ActorSystemPluginException
*/
private void initializeTheDeadLetterActor(final File deadLetterFileSystem, final File reprocessedDeadLetters) throws ActorSystemPluginException {
final ActorRef actor = getActorSystem().actorOf(Props.create(new DeadLetterManager.DeadLetterCreator(deadLetterFileSystem, reprocessedDeadLetters)));
getActorSystem().eventStream().subscribe(actor, DeadLetter.class);
}
开发者ID:theAgileFactory,项目名称:app-framework,代码行数:10,代码来源:ActorSystemPluginImpl.java
注:本文中的akka.actor.DeadLetter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论