小编Rod*_*ade的帖子

如何在骆驼restlet生产者请求上设置内容类型?

我需要使用简单的 Rest 服务,但是如果我的请求以 Content-type: application/x-www-form-urlencoded 发出,它们的实现就会中断。我需要将其设置为“application/json”或面临状态 415。

我正在使用 restlet 生产者组件,因为它已经在整个过程中使用了,并且到目前为止它已经达到了功能性和简单性之间的最佳位置。迄今为止。

无论如何,尝试在我的路由中设置标头似乎零效果,我的请求的内容类型仍然为 application/x-www-form-urlencoded。这是我的测试代码:

    from("direct:getImg")
            .setHeader(RestletConstants.RESTLET_LOGIN, simple("admin"))
            .setHeader(RestletConstants.RESTLET_PASSWORD, simple("admin"))
            .setHeader(Exchange.CONTENT_TYPE, simple("application/json"))
            .to("restlet:http://requestb.in/12sowlx1?restletMethod=get&throwExceptionOnFailure=false")
Run Code Online (Sandbox Code Playgroud)

我显然错过了一些东西,但我找不到任何例子。任何人都可以指出正确的方法吗?

谢谢!

java restlet apache-camel

5
推荐指数
1
解决办法
1万
查看次数

Salt-stack:在管理文件公式中替换/添加minion名称到文件

我正在使用New Relic监视我的Salt托管的EC2服务器,我试图在newrelic-sysmond confic文件中插入"hostname = minion-name",因此它们显示在New Relic的仪表板中,具有可重新调整的名称,而不是EC2默认为"ip-123-133 ......".

我使用salt-cloud旋转我的实例,然后应用以下状态(通过顶层文件)以运行New Relic sysmond:

newrelic-repo:
  pkg:
    - installed
    - require:
      - pkgrepo: <my private repo defined elsewhere, just convenient rpm storage>

newrelic-sysmond:
  pkg:
    - installed
    - require:
      - pkg: newrelic-repo
  service:
    - running
    - watch:
      - file: /etc/newrelic/nrsysmond.cfg

/etc/newrelic/nrsysmond.cfg:
  file.managed:
    - source: salt://newrelic/nrsysmond.cfg
    - user: newrelic
    - mode: 744
    - require:
      - pkg: newrelic-sysmond
Run Code Online (Sandbox Code Playgroud)

关键是:/etc/newrelic/nrsysmond.cfg托管文件是一个带有我个人帐户密钥的版本,New Relic设置所需,所以我的所有机器都是一样的.

有没有办法让我hostname=my_placeholder在那个文件中有类似的东西,然后在我的sls配置中,以便当状态被应用my_placeholder成为奴才名称?

通过states.file doc(http://docs.saltstack.com/ref/states/all/salt.states.file.html)挖掘我觉得这是可能的,但我缺少一些基础知识来计算它因为我刚刚开始用盐.主要是我认为我只需要一个关于如何引用包含minion名称的变量/ grain的方式,以及正在使用的默认值/上下文的示例.

managed amazon-ec2 newrelic salt-stack

3
推荐指数
1
解决办法
2945
查看次数

Spring Boot + Apache Camel HTTP组件在启动时崩溃:缺少EmbeddedServletContainerFactory bean

只需要使用Spring-Boot进行旋转并决定混合使用Camel,因为我需要一些神秘的Headers在我正在处理的其他客户端中工作.设置应用程序很好,直到我将camel-http组件添加到我的POM,然后我在init上得到这个:

Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
Run Code Online (Sandbox Code Playgroud)

我还没有第一个想法,从哪里开始寻找问题.我收集Spring Boot将查找类路径并尝试连接东西,那么有没有办法阻止Camel包被采取行动或类似的东西?

完成本Gist启动日志

这是我的主要应用程序代码:

@ComponentScan
@EnableAutoConfiguration
public class Application {

    private static ApplicationContext ctx;

    public static void main(String[] args) throws Exception {
        ctx = SpringApplication.run(Application.class, args);

        //Right outta Spring 4 docs
        System.out.println("Let's inspect the beans provided by Spring Boot:");
        String[] beanNames = ctx.getBeanDefinitionNames();
        Arrays.sort(beanNames);
        for (String beanName : beanNames) {
            System.out.println(beanName);
        }
        //---

        // …
Run Code Online (Sandbox Code Playgroud)

spring apache-camel spring-boot

1
推荐指数
1
解决办法
2502
查看次数