当前位置: 首页 > news >正文

怎样给自己的店做网站win7配置不能运行wordpress

怎样给自己的店做网站,win7配置不能运行wordpress,建设银行手机查询网站,哪里有机械加工活akka和rabbitmq在前两部分#xff08; 一 #xff0c; 二 #xff09;中#xff0c;我们简要讨论了Actor以及消息传递的工作方式。 在这一部分中#xff0c;让我们看一下如何修复并记录我们的TeacherActor 。 回顾 这就是我们上一部分中的Actor的样子#xff1a; class… akka和rabbitmq 在前两部分 一 二 中我们简要讨论了Actor以及消息传递的工作方式。 在这一部分中让我们看一下如何修复并记录我们的TeacherActor 。 回顾 这就是我们上一部分中的Actor的样子 class TeacherActor extends Actor {val quotes List(Moderation is for cowards,Anything worth doing is worth overdoing,The trouble is you think you have time,You never gonna know if you never even try)def receive {case QuoteRequest {import util.Random//Get a random Quote from the list and construct a responseval quoteResponseQuoteResponse(quotes(Random.nextInt(quotes.size)))println (quoteResponse)}} }使用SLF4J记录Akka 您会注意到在代码中我们正在将quoteResponse打印到标准输出您显然同意这是一个坏主意。 让我们通过SLF4J Facade启用日志记录来解决此问题。 1.修复类以使用日志记录 Akka提供了一个很好的小特征ActorLogging来实现它。 让我们混合 class TeacherLogActor extends Actor with ActorLogging {val quotes List(Moderation is for cowards,Anything worth doing is worth overdoing,The trouble is you think you have time,You never gonna know if you never even try)def receive {case QuoteRequest {import util.Random//get a random element (for now)val quoteResponseQuoteResponse(quotes(Random.nextInt(quotes.size)))log.info(quoteResponse.toString())}}//Well cover the purpose of this method in the Testing sectiondef quoteListquotes} 绕道而行 在内部当我们记录一条消息时ActorLogging中的记录方法最终将日志消息发布到EventStream 。 是的我确实说过publish 。 那么EventStream实际上是什么 EventStream和记录 EventStream行为就像可以向其发布和接收消息的消息代理一样。 与常规MOM的一个细微区别是EventStream的订阅者只能是Actor。 在记录消息的情况下所有日志消息都将发布到EventStream。 默认情况下订阅这些消息的Actor是DefaultLogger 它仅将消息打印到标准输出中。 class DefaultLogger extends Actor with StdOutLogger { override def receive: Receive {...case event: LogEvent ⇒ print(event)} } 因此这就是我们尝试启动StudentSimulatorApp的原因我们看到写入控制台的日志消息。 也就是说Eve​​ntStream不仅适合于记录。 它是VM内ActorWorld内部可用的通用发布订阅机制稍后会详细介绍。 返回SLF4J设置 2.将Akka配置为使用SLF4J akka{ loggers [akka.event.slf4j.Slf4jLogger]loglevel DEBUGlogging-filter akka.event.slf4j.Slf4jLoggingFilter } 我们将此信息存储在名为application.conf的文件中该文件应位于您的类路径中。 在我们的sbt文件夹结构中我们将其放在您的main/resources目录中。 从配置中我们可以得出 loggers属性指示要订阅日志事件的Actor。 Slf4jLogger所做的只是简单地使用日志消息并将其委托给SLF4J Logger外观。 loglevel属性仅指示记录日志时应考虑的最低级别。 logging-filter比较当前配置的日志loglevel和传入的日志消息级别并在发布到EventStream之前剔除配置的日志级别以下的任何日志消息。 但是为什么前面的示例没有提供application.conf 仅仅是因为Akka提供了一些合理的默认值所以我们在开始使用它之前不需要构建配置文件。 为了自定义各种内容我们将在此频繁地重新访问此文件。 您可以在application.conf内部使用一堆很棒的参数来单独记录日志。 它们在这里详细解释。 3.放入logback.xml 现在我们将配置一个由logback支持的SLF4J记录器。 ?xml version1.0 encodingUTF-8? configuration appender nameFILEclassch.qos.logback.core.rolling.RollingFileAppenderencoderpattern%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n/pattern/encoderrollingPolicy classch.qos.logback.core.rolling.TimeBasedRollingPolicyfileNamePatternlogs\akka.%d{yyyy-MM-dd}.%i.log/fileNamePatterntimeBasedFileNamingAndTriggeringPolicy classch.qos.logback.core.rolling.SizeAndTimeBasedFNATPmaxFileSize50MB/maxFileSize/timeBasedFileNamingAndTriggeringPolicy/rollingPolicy/appenderroot levelDEBUGappender-ref refFILE //root /configuration 我也将它与application.conf一起放入了main/resources文件夹中。 请确保main/resources现在位于eclipse或其他IDE的类路径中。 还应将logback和slf4j-api包含到build.sbt中 。 而当我们揭开序幕我们StudentSimulatorApp和发送邮件到我们的新TeacherLogActor 该akkaxxxxx.log文件我们配置看起来像这样。 测试Akka 请注意这绝不是Test Akka的详尽介绍。 我们将在以下各部分中相应标题下的“测试”的更多功能上构建测试。 这些测试用例旨在覆盖我们之前编写的Actor。 当StudentSimulatorApp我们的需求时您将同意应将其从测试用例中删除。 为了减轻测试的痛苦Akka提出了一个了不起的测试工具包使用它我们可以做一些神奇的事情例如直接探查Actor实现的内部。 聊够了让我们看看测试用例。 首先让我们尝试将StudentSimulatorApp映射到测试用例。 现在让我们单独看一下声明。 class TeacherPreTest extends TestKit(ActorSystem(UniversityMessageSystem)) with WordSpecLikewith MustMatcherswith BeforeAndAfterAll { 因此从TestCase类的定义中我们看到 TestKit特性接受一个ActorSystem 我们将通过该ActorSystem创建Actor。 在内部TestKit装饰ActorSystem并替换默认的调度程序。 我们使用WordSpec 这是使用ScalaTest编写测试用例的众多有趣方式之一。 MustMatchers提供方便的方法来使测试用例看起来像自然语言 在测试用例完成之后我们混合使用BeforeAndAfterAll来关闭ActorSystem。 特质提供的afterAll方法更像我们在JUnit中的tearDown 1、2 –向演员发送消息 第一个测试用例只是向PrintActor发送一条消息。 它没有断言 第二种情况将消息发送到Log actor后者使用ActorLogging的log字段将消息发布到EventStream。 这也没有断言 //1. Sends message to the Print Actor. Not even a testcase actuallyA teacher must {print a quote when a QuoteRequest message is sent in {val teacherRef TestActorRef[TeacherActor]teacherRef ! QuoteRequest}}//2. Sends message to the Log Actor. Again, not a testcase per seA teacher with ActorLogging must {log a quote when a QuoteRequest message is sent in {val teacherRef TestActorRef[TeacherLogActor]teacherRef ! QuoteRequest}3 –维护参与者的内部状态 第三种情况使用TestActorRef的underlyingActor quoteList方法并调用TeacherActor的quoteList方法。 quoteList方法返回引号列表。 我们使用此列表来声明其大小。 如果对quoteList引用使您退缩请参考上面列出的TeacherLogActor代码并查找 //From TeacherLogActor //Well cover the purpose of this method in the Testing sectiondef quoteListquotes//3. Asserts the internal State of the Log Actor. have a quote list of size 4 in {val teacherRef TestActorRef[TeacherLogActor]teacherRef.underlyingActor.quoteList must have size (4)teacherRef.underlyingActor.quoteList must have size (4)}4 –声明日志消息 正如我们前面在EventStream和Logging部分上文中讨论的那样所有日志消息都进入EventStream 并且SLF4JLogger订阅并使用其附加程序将其写入日志文件/控制台等。直接在我们的测试用例中使用EventStream并断言日志消息本身的存在 看起来我们也可以做到。 这涉及两个步骤 您需要像这样向您的TestKit添加额外的配置 class TeacherTest extends TestKit(ActorSystem(UniversityMessageSystem, ConfigFactory.parseString(akka.loggers [akka.testkit.TestEventListener]))) with WordSpecLikewith MustMatcherswith BeforeAndAfterAll { 现在我们已经订阅了EventStream我们可以从测试用例中将其声明为 //4. Verifying log messages from eventStreambe verifiable via EventFilter in response to a QuoteRequest that is sent in {val teacherRef TestActorRef[TeacherLogActor]EventFilter.info(pattern QuoteResponse*, occurrences 1) intercept {teacherRef ! QuoteRequest}} EventFilter.info块仅截获1条以QuoteResponse patternQuoteResponse* 开头的日志消息。 您也可以通过使用startQuoteResponse 。如果没有消息发送给TeacherLogActor则该测试用例将失败。 5 –使用构造函数参数测试Actor 请注意我们在测试用例中创建Actor的方式是通过TestActorRef[TeacherLogActor]而不是通过system.actorOf 。 这只是为了使我们可以通过TeacherActorRef中的underlyingActor Actor方法访问Actor的内部。 我们将无法通过在常规运行时可以访问的ActorRef来实现此ActorRef 。 这并没有给我们在生产中使用TestActorRef的任何借口。您会被追捕的。 如果Actor接受参数那么我们创建TestActorRef的方式将是 val teacherRef TestActorRef(new TeacherLogParameterActor(quotes)) 整个测试用例将如下所示 //5. have a quote list of the same size as the input parameter have a quote list of the same size as the input parameter in {val quotes List(Moderation is for cowards,Anything worth doing is worth overdoing,The trouble is you think you have time,You never gonna know if you never even try)val teacherRef TestActorRef(new TeacherLogParameterActor(quotes))//val teacherRef TestActorRef(Props(new TeacherLogParameterActor(quotes)))teacherRef.underlyingActor.quoteList must have size (4)EventFilter.info(pattern QuoteResponse*, occurrences 1) intercept {teacherRef ! QuoteRequest}}关闭ActorSystem 最后 afterAll生命周期方法 override def afterAll() { super.afterAll()system.shutdown()}码 与往常一样可以从github这里下载整个项目。 翻译自: https://www.javacodegeeks.com/2014/10/akka-notes-actor-logging-and-testing.htmlakka和rabbitmq
http://wiki.neutronadmin.com/news/307243/

相关文章:

  • 网站改版后 搜索不到房产中介如何找客源
  • 点击网站wordpress轻博客
  • 商会网站模板建设银行网站登录密码
  • 校友录网站开发设计服务企业网站建设的IT
  • ps中网站页面做多大的qq小程序搭建
  • 免费简单网站阿里云免费企业邮箱申请
  • 可以做配音兼职的网站wordpress 中文包
  • 广州致格广告有限公司网站wordpress 随机一句话
  • 自己做的网站地址手机怎么打不开创意设计网
  • 北京公司网站深圳广告公司名录
  • 网站如何做一张轮播图企业登录
  • 网站建设推广扬州2024微信最新版本下载
  • 论坛网站开发 go2345浏览器
  • 如何开通自己的网站站嗨免费建站系统
  • 教育网站建设的意义桂林做网站公司有哪些
  • seo网站建设公司哪家好wordpress微博图床怎么用
  • 想做网站python 兼职网站开发
  • 深圳网站制作公司兴田德润官方网站全国信息企业公示系统官网
  • 南京装饰公司网站建设网址导航123
  • 外国网站上做Task做专业网站
  • ip段访问网站代码医院 网站源码
  • 国内个人网站欣赏广州地铁最新
  • 什么网站可以做问卷调查金螳螂装饰公司
  • 成都网站ico wordpress
  • 工商注册查询平台谷歌关键词排名优化
  • 求免费的那种网站有哪些网页版qq登录入口是什么
  • 软件开发找谁seo技术教程
  • 网站策划 ppt2017wordpress广告插件
  • 智能免费建站wordpress描述怎么写
  • 哪里有做区块链网站的住房和城乡建设网官网八大员报名