é iniciado nessa classe actorconfig.java

package worker.calculator;

import akka.actor.ActorSystem;

import br.com.totvs.tfs.fees.util.ReadFileUtil;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import core.SpringExtension;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.beanio.StreamFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import scala.concurrent.duration.FiniteDuration;
import worker.Constants;
import worker.Worker;

import javax.inject.Inject;
import java.io.File;
import java.io.InputStream;
import java.util.Properties;

/**
 * ActorConfig for akka.
 */
@Slf4j
@Configuration
@ComponentScan(basePackageClasses = Worker.class)
public class ActorConfig {

    /** applicationContext. */
    @Inject
    private ApplicationContext applicationContext;

    /** layoutDefinition. */
    @Value("classpath:/layouts/beanio.xml")
    private InputStream layoutDefinition;

    /** streamFactory. */
    @Bean
    public StreamFactory streamFactory() throws Exception {
        try {
            log.info("Initializing layout factory...");
            final StreamFactory streamFactory = StreamFactory.newInstance();
            streamFactory.load(layoutDefinition);
            log.info("Layout factory initialized.");
            return streamFactory;
        } catch (Exception e) {
            log.error("Error while initializing the stream factory", e);
            throw e;
        }
    }

    /**
     * workTimeout.
     * @return Constants.WORK_TIMEOUT the work timeout.
     */
    @Bean
    @Lazy
    public FiniteDuration workTimeout() {
        return Constants.WORK_TIMEOUT;
    }

    /**
     * registerInterval.
     * @return Constants.WORK_TIMEOUT the work timeout.
     */
    @Bean
    @Lazy
    public FiniteDuration registerInterval() {
        return Constants.WORK_TIMEOUT;
    }

    /**
     * resultsTopic.
     * @return Constants.RESULTS_TOPIC the result topic.
     */
    @Bean
    @Lazy
    public String resultsTopic() {
        return Constants.RESULTS_TOPIC;
    }

    /**
     * backendActorSystem.
     * @return ActorSystem the ActorSystem.
     */
    @Bean
    @Lazy
    public ActorSystem backendActorSystem() {
        return actorSystem(Constants.BACKEND);
    }

    /**
     * frontendActorSystem.
     * @return ActorSystem the ActorSystem.
     */
    @Bean
    @Lazy
    public ActorSystem frontendActorSystem() {
        return actorSystem(Constants.FRONTEND);
    }

    /**
     * workerActorSystem.
     * @return ActorSystem the ActorSystem.
     */
    @Bean
    @Lazy
    public ActorSystem workerActorSystem() {
        return actorSystem(Constants.WORKER);
    }

    private ActorSystem actorSystem(final String role) {
        final ActorSystem actorSystem = 
ActorSystem.create(Constants.SYSTEM_NAME, akkaConfig(role));
        
SpringExtension.INSTANCE.get(actorSystem).initialize(applicationContext);
        return actorSystem;
    }

    /**
     * Akka config.
     * @param clusterRoles the cluster roles.
     * @return config the config.
     */
    private static Config akkaConfig(final String... clusterRoles) {
        Config config = ConfigFactory.parseString("akka.cluster.roles=[" + 
StringUtils.join(clusterRoles, ", ") + "]");

        Properties props = ReadFileUtil.getProperties();
        String pathPropsAkka = props.getProperty("dir.props.akka");

        for (final String clusterRole : clusterRoles) {
            String conf = pathPropsAkka + 
System.getProperty("file.separator") + clusterRole + ".conf";
            config = config.withFallback(ConfigFactory.parseFile(new 
File(conf)));
        }

        return config.withFallback(ConfigFactory.load());
    }

}


Em quarta-feira, 24 de setembro de 2014 11h33min21s UTC-3, rkuhn escreveu:
>
> Where do you create the ActorSystem in question?
>
> Regards,
>
> Roland
>
> 23 sep 2014 kl. 16:10 skrev Tiago Canatelli <[email protected] 
> <javascript:>>:
>
> Thanks a help, the problem is solution
>
> Em sexta-feira, 19 de setembro de 2014 08h59min17s UTC-3, Tiago Canatelli 
> escreveu:
>>
>> Bom dia pessoal,
>>
>> estou iniciando no desenvolvimento Akka, estou tendo que resolver um 
>> problema aqui na empresa para uma solução akka para fazer um teste, porem 
>> ao inicializar no servelt context listener, estou tendo o seguinte erro 
>> abaixo (Alguém pode me ajudar nessa configuração?): 
>>
>> Erro está dando nesse método:
>> private Address startBackend(final Address joinAddress, final String 
>> role, final String resultsTopic) {
>> *     <NESSA LINHA>*  * final Address realJoinAddress = (joinAddress == 
>> null) ? Cluster.get(actorSystem).selfAddress() : joinAddress;*
>>         Cluster.get(actorSystem).join(realJoinAddress);
>>
>>         // Create the master actor
>>         actorSystem.actorOf(getDefaultMasterProps(role, resultsTopic), 
>> Constants.MASTER);
>>
>>         return realJoinAddress;
>>     }
>>
>> Segue meu arquivo de configuração como está (application.conf):
>> akka {
>>     actor {
>>     provider = "akka.cluster.ClusterActorRefProvider"
>>     }
>>     remote {
>>         transport = "akka.remote.netty.NettyRemoteTransport"
>>         log-remote-lifecycle-events = off
>>         netty {
>>             hostname = "totvs-00074"
>>             port = 0
>>         }
>>     }
>>
>>     cluster {
>>         seed-nodes = [
>>         "akka://Workers@TOTVS-00074:2551",
>>         "akka://Workers@TOTVS-00074:2552"]
>>         auto-down = on
>>     } 
>> }
>>
>>
>>
>>
>> [ERROR   ] SRVE0283E: Exception caught while initializing context: 
>> akka.ConfigurationException: ActorSystem [akka://Workers] needs to have 
>> a 'ClusterActorRefProvider' enabled in the configuration, currently uses 
>> [akka.actor.LocalActorRefProvider]
>>     at akka.cluster.Cluster.<init>(Cluster.scala:79)
>>     at akka.cluster.Cluster$.createExtension(Cluster.scala:42)
>>     at akka.cluster.Cluster$.createExtension(Cluster.scala:37)
>>     at akka.actor.ActorSystemImpl.registerExtension(ActorSystem.scala:711)
>>     at akka.actor.ExtensionId$class.apply(Extension.scala:79)
>>     at akka.cluster.Cluster$.apply(Cluster.scala:37)
>>     at akka.actor.ExtensionId$class.get(Extension.scala:91)
>>     at akka.cluster.Cluster$.get(Cluster.scala:38)
>>     at akka.cluster.Cluster.get(Cluster.scala)
>>     at 
>> worker.calculator.BackendNodeStarter.startBackend(BackendNodeStarter.java:46)
>>     at 
>> worker.calculator.BackendNodeStarter.startupNode(BackendNodeStarter.java:29)
>>     at 
>> worker.calculator.ClusterNodeStarter.startup(ClusterNodeStarter.java:57)
>>     at 
>> br.com.totvs.tfs.fees.web.servlet.AkkaServletContextListener.contextInitialized(AkkaServletContextListener.java:26)
>>     at 
>> com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:2228)
>>     at [internal classes]
>>
>>
> -- 
> >>>>>>>>>> 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 [email protected] <javascript:>.
> To post to this group, send email to [email protected] 
> <javascript:>.
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> *Dr. Roland Kuhn*
> *Akka Tech Lead*
> Typesafe <http://typesafe.com/> – Reactive apps on the JVM.
> twitter: @rolandkuhn
> <http://twitter.com/#%21/rolandkuhn>
>  
>

-- 
>>>>>>>>>>      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 [email protected].
To post to this group, send email to [email protected].
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