Examples of Inbox


Examples of akka.actor.Inbox

        // Create the 'greeter' actor
        final ActorRef greeter = system.actorOf(Props.create(Greeter.class), "greeter");

        // Create the "actor-in-a-box"
        final Inbox inbox = Inbox.create(system);

        // Tell the 'greeter' to change its 'greeting' message
        greeter.tell(new WhoToGreet("akka"), ActorRef.noSender());

        // Ask the 'greeter for the latest 'greeting'
        // Reply should go to the "actor-in-a-box"
        inbox.send(greeter, new Greet());

        // Wait 5 seconds for the reply with the 'greeting' message
        Greeting greeting1 = (Greeting) inbox.receive(Duration.create(5, TimeUnit.SECONDS));
        System.out.println("Greeting: " + greeting1.message);

        // Change the greeting and ask for it again
        greeter.tell(new WhoToGreet("typesafe"), ActorRef.noSender());
        inbox.send(greeter, new Greet());
        Greeting greeting2 = (Greeting) inbox.receive(Duration.create(5, TimeUnit.SECONDS));
        System.out.println("Greeting: " + greeting2.message);

        // after zero seconds, send a Greet message every second to the greeter with a sender of the GreetPrinter
        ActorRef greetPrinter = system.actorOf(Props.create(GreetPrinter.class));
        system.scheduler().schedule(Duration.Zero(), Duration.create(1, TimeUnit.SECONDS), greeter, new Greet(), system.dispatcher(), greetPrinter);
View Full Code Here

Examples of akka.actor.Inbox

  @Test
  public void demonstrateInbox() {
    final JavaTestKit probe = new JavaTestKit(system);
    final ActorRef target = probe.getRef();
    //#inbox
    final Inbox inbox = Inbox.create(system);
    inbox.send(target, "hello");
    //#inbox
    probe.expectMsgEquals("hello");
    probe.send(probe.getLastSender(), "world");
    //#inbox
    try {
      assert inbox.receive(Duration.create(1, TimeUnit.SECONDS)).equals("world");
    } catch (java.util.concurrent.TimeoutException e) {
      // timeout
    }
    //#inbox
  }
View Full Code Here

Examples of akka.actor.Inbox

  @Test
  public void demonstrateWatch() {
    final JavaTestKit probe = new JavaTestKit(system);
    final ActorRef target = probe.getRef();
    //#watch
    final Inbox inbox = Inbox.create(system);
    inbox.watch(target);
    target.tell(PoisonPill.getInstance(), ActorRef.noSender());
    try {
      assert inbox.receive(Duration.create(1, TimeUnit.SECONDS)) instanceof Terminated;
    } catch (java.util.concurrent.TimeoutException e) {
      // timeout
    }
    //#watch
  }
View Full Code Here

Examples of com.m4f.business.domain.Inbox

  @RequestMapping(value="/sendInboxResponse", method=RequestMethod.POST)
  public @ResponseBody String sendInboxResponseEmail(
      @RequestParam(required=true) Long inboxId) {
    try {
      Locale locale = this.getAvailableLanguages().get(0);
      Inbox messageRes = inboxService.getInbox(inboxId, locale);
      Inbox messageReq = null;
      if(messageRes != null) {
        messageReq = inboxService.getInbox(messageRes.getRelatedId(), locale);
      }
      Properties props = new Properties();
      Session session = Session.getDefaultInstance(props, null);   
      try {
        Message msg = new MimeMessage(session);
        msg.setFrom(new InternetAddress(new StringBuffer("admin").append(EMAIL_DOMAIN_SUFFIX).toString(),
            this.getMessage("suggestion.problem.response.from")));
        msg.addRecipient(Message.RecipientType.TO,
                         new InternetAddress(messageReq.getFrom(), messageReq.getName()));
        msg.setSubject(this.getMessage("suggestion.problem.response.subject", messageReq.getId()));
        msg.setText(new StringBuffer(messageRes.getContent()).append("\n\n\n").append(this.getMessage("suggestion.problem.response.advice")).toString());
            Transport.send(msg);
      } catch (AddressException e) {
        LOGGER.log(Level.SEVERE, StackTraceUtil.getStackTrace(e));
          } catch (MessagingException e) {
            LOGGER.log(Level.SEVERE, StackTraceUtil.getStackTrace(e));
          }
         
      LOGGER.info("SENDING SEARCH RESULT TO EMAIL -> " + messageReq.getFrom());
    } catch(Exception e) {
      LOGGER.log(Level.SEVERE, StackTraceUtil.getStackTrace(e));
      return "common.error";
    }
    return "task.launched";
View Full Code Here

Examples of com.m4f.business.domain.Inbox

    if(result.hasErrors()) {
      return "suggestion.inbox.form";
    }
    try {
      String remoteHost = request.getRemoteAddr() != null ? request.getRemoteAddr() : "";
      Inbox inbox = this.serviceLocator.getInboxService().createInbox();
      inbox.setType(form.getType());
      inbox.setRemoteHost(remoteHost);
      inbox.setUser(Inbox.USER.INTERNAL);
      inbox.setContent(form.getContent());
      inbox.setFrom(principal.getName());
      inbox.setName(principal.getName());
      inbox.setCreated(new Date());
      this.serviceLocator.getInboxService().save(inbox, locale);
    } catch(Exception e) {
      LOGGER.severe(StackTraceUtil.getStackTrace(e));
      return "common.error";
    }
View Full Code Here

Examples of com.m4f.business.domain.Inbox

  @Secured("ROLE_ADMIN")
  @RequestMapping(value="/delete/{inboxId}", method=RequestMethod.GET)
  public String delete(@PathVariable Long inboxId, Locale locale,
      @RequestHeader("referer") String referer, @RequestHeader("Host") String host) {
    try {
      Inbox inbox = this.serviceLocator.getInboxService().getInbox(inboxId, locale);
      this.serviceLocator.getInboxService().delete(inbox, locale);     
    } catch(Exception e) {
      LOGGER.severe(StackTraceUtil.getStackTrace(e));
      return "common.error";
    }
View Full Code Here

Examples of com.m4f.business.domain.Inbox

 
  @Secured("ROLE_ADMIN")
  @RequestMapping(value="/detail/{inboxId}", method=RequestMethod.GET)
  public String detail(@PathVariable Long inboxId, Model model, Locale locale) {
    try {
      Inbox inbox = this.serviceLocator.getInboxService().getInbox(inboxId, locale);
      inbox.setReaded(Boolean.TRUE);
      this.serviceLocator.getInboxService().save(inbox, locale);
      model.addAttribute("inbox", inbox);
    } catch(Exception e) {
      LOGGER.severe(StackTraceUtil.getStackTrace(e));
      return "common.error";
View Full Code Here

Examples of com.m4f.business.domain.Inbox

 
  @Secured("ROLE_ADMIN")
  @RequestMapping(value="/response/{inboxId}", method=RequestMethod.GET)
  public String responseToInboxMessage(Principal principal, @PathVariable Long inboxId, Model model, Locale locale) {
    try {
      Inbox inboxReq = this.serviceLocator.getInboxService().getInbox(inboxId, locale);
      InboxForm inbox = new InboxForm();
      inbox.setFrom(principal.getName());
      model.addAttribute("inboxReq", inboxReq);
      model.addAttribute("inbox", inbox);
    } catch(Exception e) {
View Full Code Here

Examples of com.m4f.business.domain.Inbox

  @RequestMapping(value="/response/{inboxId}", method=RequestMethod.POST)
  public String sendResponseToInboxMessage(@ModelAttribute("inbox") @Valid Inbox inboxRes, BindingResult result,
      @PathVariable Long inboxId, Model model, Locale locale, @RequestHeader("Host") String host) {
   
    try {
      Inbox inboxReq = this.serviceLocator.getInboxService().getInbox(inboxId, locale);
      if(inboxReq != null) {
        // Some hand setting.
        inboxRes.setRelatedId(inboxReq.getId());
        inboxRes.setFrom("admin@hirubila.m4f.es");
        inboxRes.setUser(USER.INTERNAL);
        inboxRes.setOrigin(ORIGIN.RESPONSE);
        // Save
        this.serviceLocator.getInboxService().save(inboxRes, locale);
View Full Code Here

Examples of com.m4f.business.domain.Inbox

      model.addAttribute("sent", false);
      return "search.results.error";
    }
    try {
      String host = request.getRemoteAddr() != null ? request.getRemoteAddr() : "";
      Inbox inbox = this.serviceLocator.getInboxService().createInbox();
      inbox.setType(Inbox.TYPE.PROBLEM);
      inbox.setRemoteHost(host);
      inbox.setUser(Inbox.USER.EXTERNAL);
      inbox.setContent(form.getContent());
      inbox.setFrom(form.getFrom());
      inbox.setName(form.getName());
      inbox.setCreated(new Date());
      this.serviceLocator.getInboxService().save(inbox, locale);
    } catch(Exception e) {
      LOGGER.log(Level.SEVERE, StackTraceUtil.getStackTrace(e));
      return "common.error";
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.