简体   繁体   English

Spring boot,apache camel和hawtio:无法向端点发送消息

[英]Spring boot , apache camel and hawtio: cannot send message to endpoint

I'm trying to integrate hawtio in a spring-boot application using apache camel. 我正在尝试使用apache camel在一个spring-boot应用程序中集成hawtio。 I followed Spring-Boot Embedded Wars and added HawtioConfiguration from How to run hawt.io in spring boot application with embedded tomcat (except for the kubeservice and kubepod which are not in io.hawt.web package) 我按照Spring-Boot Embedded Wars添加了HawtioConfiguration, 如何在带有嵌入式tomcat的spring boot应用程序中运行hawt.io (除了kubeservice和kubepod,它们不在io.hawt.web包中)

So, that works, up to the point where I try to manualy send a message to a direct endpoint from the hawtio interface ( http://localhost:8080/hawtio/index.html#/camel/sendMessage?tab=camel&nid=root-org.apache.camel-camel-1-endpoints-%22direct:%2F%2Fdummy%22 ) . 所以,这是有效的,直到我尝试从hawtio接口手动发送消息到直接端点( http:// localhost:8080 / hawtio / index.html#/ camel / sendMessage?tab = camel&nid = root -org.apache.camel-camel-1-endpoints-%22direct:%2F%2Fdummy%22 )。 The following warning appears, and no message is sent: 出现以下警告,并且不发送任何消息:

Camel does not support sending to this endpoint.

So, did I forget anything ? 那么,我忘了什么吗? Here is my set up : springboot 1.3.3.RELEASE with the following dependencies : 这是我的设置:springboot 1.3.3.RELEASE具有以下依赖项:

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring-boot-starter</artifactId>
        <version>2.17.0</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jersey</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-actuator</artifactId>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.hawt</groupId>
        <artifactId>hawtio-springboot</artifactId>
        <version>1.4.64</version>
    </dependency>
    <dependency>
        <groupId>io.hawt</groupId>
        <artifactId>hawtio-core</artifactId>
        <version>1.4.64</version>
    </dependency>

and the Application.java : 和Application.java:

@SpringBootApplication
@EnableHawtio
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
public class Application {

    @Autowired
    private ServletContext servletContext;

    public static void main(String[] args) {
         System.setProperty(AuthenticationFilter.HAWTIO_AUTHENTICATION_ENABLED, "false");
        SpringApplication.run(Application.class, args);
    }
    @PostConstruct
    public void init() {
        final ConfigManager configManager = new ConfigManager();
        configManager.init();
        servletContext.setAttribute("ConfigManager", configManager);
    }
}

Thanks ! 谢谢 !

edit: using hawtio as a standalone app and connecting to springboot works fine 编辑:使用hawtio作为独立的应用程序并连接到springboot工作正常

edit2: moving on, I used hawtio as a war on another project (same version) , deployed on a tomcat 7. Same issue, cannot send to a direct endpoint. edit2:继续前进,我将hawtio用作另一个项目(相同版本)的战争,部署在tomcat 7上。同样的问题,无法发送到直接端点。 go figure. 去搞清楚。

The option of using hawtio as war works very well with application using spring boot and camel, I am already using it successfully. 使用hawtio作为战争的选项非常适合使用弹簧靴和骆驼的应用程序,我已经成功使用它。 check the hawtio github code example, it contains good samples to try https://github.com/hawtio/hawtio 检查hawtio github代码示例,它包含很好的示例来尝试https://github.com/hawtio/hawtio

Also I will share my github link with sample's of using hawtio wat or as maven plug-in. 此外,我将与使用hawtio wat或maven插件的样本分享我的github链接。

I had the same problem: I could not use hawt.io to send to a direct endpoint (nor any other endpoint). 我遇到了同样的问题:我无法使用hawt.io发送到直接端点(也没有任何其他端点)。 Maybe it is a general Bug/ unimplemented feature in hawt.io? 也许它是hawt.io中的一般Bug /未实现的功能?

However, the following was possible: 但是,以下是可能的:

  • Copy the Endpoint URL 复制端点URL
  • Select the context node in hawt.io 在hawt.io中选择上下文节点
  • Click on "Operations" 点击“操作”
  • Use the method sendStringBody(java.lang.String,java.lang.String) to send a string to that endpoint 使用sendStringBody(java.lang.String,java.lang.String)方法将字符串发送到该端点
  • First parameter is the endpoint URI that you can paste in 第一个参数是您可以粘贴的端点URI

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM