final ActorSystem actorSystem = ActorSystem.create("ServerEvents"); final ActorRef actor = actorSystem.actorOf(new Props(SeverEventHandler.class)); actorSystem.eventStream().subscribe(actor,ServerMessage.class); actorSystem.eventStream().publish(new ServerMessage()); <<== add this
protected QuarantinedMonitorActor(Effect callback) { this.callback = callback; LOG.debug("Created QuarantinedMonitorActor"); getContext().system().eventStream().subscribe(getSelf(), RemotingLifecycleEvent.class); }
protected QuarantinedMonitorActor(final Effect callback) { this.callback = callback; LOG.debug("Created QuarantinedMonitorActor"); getContext().system().eventStream().subscribe(getSelf(), ThisActorSystemQuarantinedEvent.class); }
ActorRef existingActor = MyActorSystem.actorOf(Props.create(MyActor.class),"ExistingActor"); ActorRef DLH = MyActorSystem.actorOf(Props.create(DeadLettersHandler.class), "DeadLetterHandler"); MyActorSystem.eventStream().subscribe(DLH, DeadLetter.class); ActorSelection nonExist = MyActorSystem.actorSelection("akka://user/MyActorSystem/NonExistingActor"); existingActor.tell("Hello Akka", existingActor);
system.eventStream().subscribe(actorOf, DeadLetter.class);
@Override public void preStart() { getContext().system().eventStream().subscribe(getSelf(), AssociationErrorEvent.class); }
@Override public void preStart() { getContext().system().eventStream().subscribe(getSelf(), AssociationErrorEvent.class); }
@Override public void preStart() { getContext().system().eventStream().subscribe(getSelf(), AssociationErrorEvent.class); }
@Override public void preStart() { getContext().system().eventStream().subscribe(getSelf(), AssociationErrorEvent.class); }
@Override public void preStart() { getContext().system().eventStream().subscribe(self(), DeadLetter.class); }
public AkkaEmbeddedPluginOrchestrator() { maxNumberOfJobsInParallel = JobsHelper.getMaxNumberOfJobsInParallel(); index = RodaCoreFactory.getIndexService(); model = RodaCoreFactory.getModelService(); runningJobs = new HashMap<>(); stoppingJobs = new ArrayList<>(); inErrorJobs = new ArrayList<>(); Config akkaConfig = AkkaUtils.getAkkaConfiguration("application.conf"); jobsSystem = ActorSystem.create("JobsSystem", akkaConfig); // 20170105 hsilva: subscribe all dead letter so they are logged jobsSystem.eventStream().subscribe(jobsSystem.actorOf(Props.create(DeadLetterActor.class)), AllDeadLetters.class); jobsManager = jobsSystem.actorOf(Props.create(AkkaJobsManager.class, maxNumberOfJobsInParallel), "jobsManager"); }
@Override public void onReceive(Object message) throws Exception { ActorRef self = self(); ActorRef sender = sender(); if (message instanceof StartSdrService) { getContext().system().eventStream().subscribe(self, StreamEvent.class); onStartSdrService((StartSdrService) message, self, sender); } else if (message instanceof CallInfoStreamEvent) { onCallInfoStreamEvent((CallInfoStreamEvent) message, self, sender); } else if (message instanceof SmsMessage) { onSmsMessage((SmsMessage) message, self, sender); } }
private static void sendCallInfoStreamEvent(ActorSystem system, SipServletMessage message, CallStateChanged.State state) { SipSession session = message.getSession(); Object sid = session.getAttribute(CDR_SID); if (sid != null) { CallInfo callInfo = new CallInfo( (Sid) sid, (Sid) session.getAttribute(CDR_ACCOUNT_SID), state, null, (String) session.getAttribute(CDR_DIRECTION), null, null, null, (String) session.getAttribute(CDR_FROM), (String) session.getAttribute(CDR_TO), null, null, false, false, false, null, null ); system.eventStream().publish(new CallInfoStreamEvent(callInfo)); } } }
@Override public Receive createReceive() { return receiveBuilder() .match(Cmd.class, c -> { final String data = c.getData(); final Evt evt = new Evt(data + "-" + getNumEvents()); persist(evt, (Evt event) -> { state.update(event); getContext().system().eventStream().publish(event); }); }) .matchEquals("snap", s -> saveSnapshot(state.copy())) .matchEquals("print", s -> System.out.println(state)) .build(); }
config.getInt(ConfigKeys.WEBSOCKET_SUBSCRIBER_BACKPRESSURE), config.getInt(ConfigKeys.WEBSOCKET_PUBLISHER_BACKPRESSURE), actorSystem.eventStream());
@Test public void shouldSendMsgToDeadLetterWhenQueueIsFull() { final TestKit mockReceiver = new TestKit(actorSystem); actorSystem.eventStream().subscribe(mockReceiver.testActor(), 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.testActor()); } mockReceiver.expectMsgClass(twentySeconds, DeadLetter.class); } finally { lock.unlock(); } mockReceiver.receiveN(11, twentySeconds); }