微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

org.apache.camel.component.rabbitmq.RabbitMQConstants的实例源码

项目:Camel    文件ReplyManagerSupport.java   
public void processReply(ReplyHolder holder) {
    if (holder != null && isRunAllowed()) {
        try {
            Exchange exchange = holder.getExchange();

            boolean timeout = holder.isTimeout();
            if (timeout) {
                // timeout occurred do a WARN log so its easier to spot in the logs
                if (log.isWarnEnabled()) {
                    log.warn("Timeout occurred after {} millis waiting for reply message with correlationID [{}] on destination {}."
                            + " Setting ExchangeTimedOutException on {} and continue routing.",holder.getRequestTimeout(),holder.getCorrelationId(),replyTo,ExchangeHelper.logIds(exchange));
                }

                // no response,so lets set a timed out exception
                String msg = "reply message with correlationID: " + holder.getCorrelationId() + " not received on destination: " + replyTo;
                exchange.setException(new ExchangeTimedOutException(exchange,msg));
            } else {

                messageConverter.populaterabbitExchange(exchange,null,holder.getProperties(),holder.getMessage(),true);

                // restore correlation id in case the Remote Server messed with it
                if (holder.getoriginalCorrelationId() != null) {
                    if (exchange.hasOut()) {
                        exchange.getout().setHeader(RabbitMQConstants.CORRELATIONID,holder.getoriginalCorrelationId());
                    } else {
                        exchange.getIn().setHeader(RabbitMQConstants.CORRELATIONID,holder.getoriginalCorrelationId());
                    }
                }
            }
        } finally {
            // notify callback
            AsyncCallback callback = holder.getCallback();
            callback.done(false);
        }
    }
}
项目:lumen    文件reasonerRouter.java   
@Override
    public void configure() throws Exception {
        onException(Exception.class).bean(asError).bean(toJson).handled(true);
        errorHandler(new LoggingErrorHandlerBuilder(log));
//        from("timer:hello?period=3s")
//                .process(exchange -> {
//                    exchange.getIn().setBody(new GreetingReceived("Hendy"));
//                })
//                .to("seda:greetingReceived");

//        from("timer:tell me a good story?period=1s&repeatCount=1")
//                .process(exchange -> {
//                    final AgentResponse agentResponse = aimlService.process(Locale.US,"tell me a good story",logChannel);
//                    droolsService.process(agentResponse);
//                });

        final String agentId = "arkan";
        from("rabbitmq://localhost/amq.topic?connectionFactory=#amqpConnFactory&exchangeType=topic&autoDelete=false&queue=" + AvatarChannel.CHAT_INBox.wildcard() + "&routingKey=" + AvatarChannel.CHAT_INBox.wildcard())
                .process(exchange -> {
                    final long startTime = System.currentTimeMillis();
                    final CommunicateAction inCommunicate = toJson.getMapper().readValue(
                            exchange.getIn().getBody(byte[].class),CommunicateAction.class);
                    inCommunicate.setAvatarId(AvatarChannel.getAvatarId((String) exchange.getIn().getHeader(RabbitMQConstants.ROUTING_KEY)));
                    log.info("Chat inBox for {}: {}",inCommunicate.getAvatarId(),inCommunicate);

                    final Optional<Locale> origLocale = Optional.ofNullable(inCommunicate.getInLanguage());
                    final float[] speechTruthValue = Optional.ofNullable(inCommunicate.getSpeechTruthValue()).orElse(new float[]{0f,0f,0f});
                    final boolean speechInput = speechTruthValue.length >= 2 && speechTruthValue[1] > 0f;

                    // aimL style
//                    final AgentResponse agentResponse = aimlService.process(origLocale,inCommunicate.getobject(),//                            chatChannel,speechInput);
//                    if (!agentResponse.getCommunicateActions().isEmpty()) {
//                        for (final CommunicateAction communicateAction : agentResponse.getCommunicateActions()) {
//                            chatChannel.express(inCommunicate.getAvatarId(),communicateAction,null);
//                        }
//                    } else if (agentResponse.getUnrecognizedinput() != null) {
//                        chatChannel.express(inCommunicate.getAvatarId(),Proposition.I_DONT_UNDERSTAND,true,null);
//                    }
//                    droolsService.process(agentResponse);

                    final InteractionSession session = sessionManager.getorCreate(chatChannel,inCommunicate.getAvatarId());
                    session.receiveUtterance(origLocale,factService,taskRepo,scriptRepo);
                    session.update(chatChannel,inCommunicate.getAvatarId());

                    // FIXME: re-implement SocialJournal
//                    final SocialJournal socialJournal = new SocialJournal();
//                    socialJournal.setFromresponse(origLocale,//                            inCommunicate.getobject(),SocialChannel.DIRECT,//                            agentResponse,Duration.millis(System.currentTimeMillis() - startTime));
//                    socialJournalRepo.save(socialJournal);

                    exchange.getIn().setBody(new Status());
                })
                .bean(toJson);
    }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。