Hi,

I have the following method which creates a FixInitiator which is part of 
another multi-threaded framework I have no control, the client is started 
inside an actor which its children are named and located by a generated 
UUID.

I have read that passing the context to another thread is not safe but when 
you look at the Scala code, the context is lazily initialized, if it was 
initialized already, doesn't that make this code OK?

The method fromApp(...) is re-actively called back from another thread when 
a FIX message comes into the system, so far this is working for me without 
any issues, but maybe it is because I have called context() already for 
this actor before I reach the anonymous class declaration at the preStart() 
method?

*Note:* The call to super.preStart() is because the actor is inheriting 
from another Abstract type of actor with some template methods pattern.
  
  @Override
  public void preStart() throws Exception {
    initiator = new FixInitiator(entity, log, "order") {
      @Override
      public void fromApp(Message message, SessionID sessionId) throws 
FieldNotFound {
        if (message instanceof ExecutionReport) {
          final String uuid = message.getString(ClOrdID.FIELD);
          final Option<ActorRef> orderPersistor = *context**()*.child(uuid);
          if (orderPersistor.isDefined()) {
            orderPersistor.get().tell(message, noSender());
          } else {
            log.error("Order persistor for " + uuid + " doesn't exist or 
has expired");
          }
        } else {
          unhandled(message);
        }
      }
    };
    initiator.start();
    super.preStart();
  }

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to